[8911] | 1 | ## $Id: browser.py 14354 2016-12-16 17:36:07Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | import grok |
---|
[13937] | 19 | import csv |
---|
[13964] | 20 | import textwrap |
---|
[13937] | 21 | from cStringIO import StringIO |
---|
[8911] | 22 | from zope.i18n import translate |
---|
[13900] | 23 | from zope.component import getUtility, queryUtility |
---|
[14113] | 24 | from zope.schema.interfaces import TooBig, TooSmall |
---|
[13523] | 25 | from zope.security import checkPermission |
---|
[13900] | 26 | from zope.catalog.interfaces import ICatalog |
---|
[13351] | 27 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[11597] | 28 | from waeup.kofa.browser.layout import UtilityView |
---|
[8911] | 29 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
[14288] | 30 | from waeup.kofa.interfaces import ( |
---|
[14306] | 31 | IKofaUtils, academic_sessions_vocab, ICSVExporter, IKofaObject) |
---|
| 32 | from waeup.kofa.students.interfaces import ( |
---|
| 33 | IStudentsUtils, IStudent, IStudentRequestPW) |
---|
[14000] | 34 | from waeup.kofa.students.workflow import PAID, REGISTERED, RETURNING |
---|
[14354] | 35 | from waeup.kofa.students.studylevel import getGradeWeightFromScore |
---|
[9914] | 36 | from waeup.kofa.students.browser import ( |
---|
[11846] | 37 | StartClearancePage, |
---|
[9914] | 38 | StudentBasePDFFormPage, |
---|
| 39 | CourseTicketAddFormPage, |
---|
| 40 | StudyLevelDisplayFormPage, |
---|
[13834] | 41 | StudyLevelManageFormPage, |
---|
| 42 | StudyLevelEditFormPage, |
---|
[13059] | 43 | ExportPDFTranscriptSlip, |
---|
| 44 | ExportPDFAdmissionSlip, |
---|
[13353] | 45 | BedTicketAddPage, |
---|
[13380] | 46 | StudentFilesUploadPage, |
---|
[13523] | 47 | PaymentsManageFormPage, |
---|
[13770] | 48 | CourseTicketDisplayFormPage, |
---|
| 49 | CourseTicketManageFormPage, |
---|
[13900] | 50 | EditScoresPage, |
---|
[14165] | 51 | ExportPDFScoresSlip, |
---|
| 52 | StudyCourseTranscriptPage, |
---|
[14288] | 53 | DownloadScoresView, |
---|
[14306] | 54 | StudentRequestPasswordPage |
---|
[10269] | 55 | ) |
---|
[8911] | 56 | from kofacustom.nigeria.students.browser import ( |
---|
| 57 | NigeriaOnlinePaymentDisplayFormPage, |
---|
| 58 | NigeriaOnlinePaymentAddFormPage, |
---|
[13059] | 59 | NigeriaExportPDFPaymentSlip, |
---|
| 60 | NigeriaExportPDFCourseRegistrationSlip, |
---|
[13351] | 61 | NigeriaStudentPersonalDisplayFormPage, |
---|
| 62 | NigeriaStudentPersonalEditFormPage, |
---|
| 63 | NigeriaStudentPersonalManageFormPage, |
---|
[14084] | 64 | NigeriaStudentClearanceDisplayFormPage, |
---|
| 65 | NigeriaExportPDFClearanceSlip, |
---|
| 66 | NigeriaStudentClearanceManageFormPage, |
---|
[13362] | 67 | NigeriaStudentClearanceEditFormPage, |
---|
[13462] | 68 | NigeriaAccommodationManageFormPage, |
---|
[13795] | 69 | NigeriaStudentBaseDisplayFormPage, |
---|
[14165] | 70 | NigeriaStudentBaseManageFormPage |
---|
[10269] | 71 | ) |
---|
[9496] | 72 | from waeup.aaue.students.interfaces import ( |
---|
[9914] | 73 | ICustomStudentOnlinePayment, |
---|
[11607] | 74 | ICustomStudentStudyLevel, |
---|
[13351] | 75 | ICustomStudent, |
---|
| 76 | ICustomStudentPersonal, |
---|
[13362] | 77 | ICustomStudentPersonalEdit, |
---|
[13770] | 78 | ICustomUGStudentClearance, |
---|
[14298] | 79 | ICustomUGStudentClearanceEdit, |
---|
[14084] | 80 | ICustomPGStudentClearance, |
---|
[13795] | 81 | ICustomCourseTicket, |
---|
| 82 | ICustomStudentBase) |
---|
[13414] | 83 | from waeup.aaue.interswitch.browser import gateway_net_amt |
---|
[9914] | 84 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
[8911] | 85 | |
---|
[14306] | 86 | grok.context(IKofaObject) # Make IKofaObject the default context |
---|
| 87 | |
---|
[13795] | 88 | class CustomStudentBaseDisplayFormPage(NigeriaStudentBaseDisplayFormPage): |
---|
| 89 | """ Page to display student base data |
---|
| 90 | """ |
---|
| 91 | form_fields = grok.AutoFields(ICustomStudentBase).omit( |
---|
| 92 | 'password', 'suspended', 'suspended_comment', 'flash_notice') |
---|
| 93 | form_fields[ |
---|
| 94 | 'financial_clearance_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 95 | |
---|
| 96 | class CustomStudentBaseManageFormPage(NigeriaStudentBaseManageFormPage): |
---|
| 97 | """ View to manage student base data |
---|
| 98 | """ |
---|
| 99 | form_fields = grok.AutoFields(ICustomStudentBase).omit( |
---|
| 100 | 'student_id', 'adm_code', 'suspended', |
---|
| 101 | 'financially_cleared_by', 'financial_clearance_date') |
---|
| 102 | |
---|
[13351] | 103 | class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage): |
---|
| 104 | """ Page to display student personal data |
---|
| 105 | """ |
---|
| 106 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 107 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 108 | form_fields['father_address'].custom_widget = BytesDisplayWidget |
---|
| 109 | form_fields['mother_address'].custom_widget = BytesDisplayWidget |
---|
| 110 | form_fields['next_kin_address'].custom_widget = BytesDisplayWidget |
---|
| 111 | form_fields[ |
---|
| 112 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 113 | |
---|
| 114 | class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage): |
---|
| 115 | """ Page to edit personal data |
---|
| 116 | """ |
---|
| 117 | form_fields = grok.AutoFields(ICustomStudentPersonalEdit).omit('personal_updated') |
---|
| 118 | |
---|
| 119 | class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage): |
---|
| 120 | """ Page to edit personal data |
---|
| 121 | """ |
---|
| 122 | form_fields = grok.AutoFields(ICustomStudentPersonal) |
---|
| 123 | form_fields['personal_updated'].for_display = True |
---|
| 124 | form_fields[ |
---|
| 125 | 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 126 | |
---|
[14084] | 127 | class CustomStudentClearanceDisplayFormPage(NigeriaStudentClearanceDisplayFormPage): |
---|
| 128 | """ Page to display student clearance data |
---|
| 129 | """ |
---|
| 130 | |
---|
| 131 | @property |
---|
| 132 | def form_fields(self): |
---|
| 133 | if self.context.is_postgrad: |
---|
| 134 | form_fields = grok.AutoFields( |
---|
| 135 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
| 136 | else: |
---|
| 137 | form_fields = grok.AutoFields( |
---|
| 138 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
| 139 | if not getattr(self.context, 'officer_comment'): |
---|
| 140 | form_fields = form_fields.omit('officer_comment') |
---|
| 141 | else: |
---|
| 142 | form_fields['officer_comment'].custom_widget = BytesDisplayWidget |
---|
[14104] | 143 | form_fields = form_fields.omit('def_adm') |
---|
[14084] | 144 | return form_fields |
---|
| 145 | |
---|
| 146 | class CustomStudentClearanceManageFormPage(NigeriaStudentClearanceManageFormPage): |
---|
| 147 | """ Page to edit student clearance data |
---|
| 148 | """ |
---|
| 149 | |
---|
| 150 | @property |
---|
| 151 | def form_fields(self): |
---|
| 152 | if self.context.is_postgrad: |
---|
| 153 | form_fields = grok.AutoFields( |
---|
| 154 | ICustomPGStudentClearance).omit('clr_code') |
---|
| 155 | else: |
---|
| 156 | form_fields = grok.AutoFields( |
---|
| 157 | ICustomUGStudentClearance).omit('clr_code') |
---|
[14104] | 158 | form_fields = form_fields.omit('def_adm') |
---|
[14084] | 159 | return form_fields |
---|
| 160 | |
---|
[13362] | 161 | class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): |
---|
| 162 | """ View to edit student clearance data by student |
---|
| 163 | """ |
---|
| 164 | |
---|
| 165 | @property |
---|
| 166 | def form_fields(self): |
---|
| 167 | if self.context.is_postgrad: |
---|
| 168 | form_fields = grok.AutoFields(ICustomPGStudentClearance).omit( |
---|
| 169 | 'clearance_locked', 'nysc_location', 'clr_code', 'officer_comment', |
---|
| 170 | 'physical_clearance_date') |
---|
| 171 | else: |
---|
[14298] | 172 | form_fields = grok.AutoFields(ICustomUGStudentClearanceEdit).omit( |
---|
[13362] | 173 | 'clearance_locked', 'clr_code', 'officer_comment', |
---|
[14104] | 174 | 'physical_clearance_date', 'date_of_birth', 'nationality', 'lga') |
---|
| 175 | form_fields = form_fields.omit('def_adm') |
---|
[13362] | 176 | return form_fields |
---|
| 177 | |
---|
[11846] | 178 | class CustomStartClearancePage(StartClearancePage): |
---|
[13360] | 179 | with_ac = False |
---|
[11846] | 180 | |
---|
[13351] | 181 | @property |
---|
| 182 | def all_required_fields_filled(self): |
---|
| 183 | if not self.context.email: |
---|
| 184 | return _("Email address is missing."), 'edit_base' |
---|
| 185 | if not self.context.phone: |
---|
| 186 | return _("Phone number is missing."), 'edit_base' |
---|
| 187 | if not self.context.father_name: |
---|
| 188 | return _("Personal data form is not properly filled."), 'edit_personal' |
---|
| 189 | return |
---|
| 190 | |
---|
[8911] | 191 | class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): |
---|
| 192 | """ Page to view an online payment ticket |
---|
| 193 | """ |
---|
| 194 | grok.context(ICustomStudentOnlinePayment) |
---|
[9853] | 195 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9990] | 196 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 197 | form_fields[ |
---|
| 198 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 199 | form_fields[ |
---|
| 200 | 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 201 | |
---|
| 202 | class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): |
---|
| 203 | """ Page to add an online payment ticket |
---|
| 204 | """ |
---|
| 205 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( |
---|
| 206 | 'p_category') |
---|
| 207 | |
---|
[14296] | 208 | alumni_payment_cats = { |
---|
| 209 | 'transcript_local': 'Transcript Fee Local', |
---|
| 210 | 'transcript_inter': 'Transcript Fee International', |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | @property |
---|
| 214 | def selectable_categories(self): |
---|
| 215 | if 'alumni' in self.application_url(): |
---|
| 216 | return self.alumni_payment_cats.items() |
---|
| 217 | categories = getUtility(IKofaUtils).SELECTABLE_PAYMENT_CATEGORIES |
---|
| 218 | return sorted(categories.items()) |
---|
| 219 | |
---|
[13523] | 220 | class CustomPaymentsManageFormPage(PaymentsManageFormPage): |
---|
| 221 | """ Page to manage the student payments. |
---|
| 222 | |
---|
| 223 | This manage form page is for both students and students officers. |
---|
| 224 | """ |
---|
| 225 | @property |
---|
| 226 | def manage_payments_allowed(self): |
---|
| 227 | return checkPermission('waeup.manageStudent', self.context) |
---|
| 228 | |
---|
[13059] | 229 | class CustomExportPDFPaymentSlip(NigeriaExportPDFPaymentSlip): |
---|
[8911] | 230 | """Deliver a PDF slip of the context. |
---|
| 231 | """ |
---|
| 232 | grok.context(ICustomStudentOnlinePayment) |
---|
[9853] | 233 | form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( |
---|
[9990] | 234 | 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') |
---|
[8911] | 235 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9496] | 236 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
[9914] | 237 | |
---|
[11625] | 238 | @property |
---|
| 239 | def note(self): |
---|
[13408] | 240 | p_session = self.context.p_session |
---|
[13405] | 241 | try: |
---|
[13408] | 242 | academic_session = grok.getSite()['configuration'][str(p_session)] |
---|
[13405] | 243 | except KeyError: |
---|
| 244 | academic_session = None |
---|
[13425] | 245 | text = '\n\n The Amount Authorized is inclusive of: ' |
---|
[13512] | 246 | if self.context.p_category in ('schoolfee_incl', 'schoolfee_1') \ |
---|
| 247 | and academic_session: |
---|
[13414] | 248 | welfare_fee = gateway_net_amt(academic_session.welfare_fee) |
---|
| 249 | union_fee = gateway_net_amt(academic_session.union_fee) |
---|
[14244] | 250 | if self.context.student.entry_session == 2016 \ |
---|
| 251 | and self.context.student.entry_mode == 'ug_ft' \ |
---|
| 252 | and self.context.p_session == 2016: |
---|
| 253 | # Add student id card fee to first school fee payment. |
---|
| 254 | # Attention: The payment slip does not contain any information |
---|
| 255 | # whether the fee was added or not. |
---|
| 256 | # We can only draw conclusions from from the student's entry |
---|
| 257 | # session whether the fee had been included. |
---|
| 258 | id_card_fee = gateway_net_amt(academic_session.id_card_fee) |
---|
| 259 | text += ('School Fee, ' |
---|
| 260 | '%s Naira Student ID Card Fee, ' |
---|
| 261 | '%s Naira Student Union Dues, ' |
---|
| 262 | '%s Naira Student Welfare Assurance Fee and ' |
---|
| 263 | % (id_card_fee, union_fee, welfare_fee)) |
---|
| 264 | else: |
---|
| 265 | text += ('School Fee, ' |
---|
| 266 | '%s Naira Student Union Dues, ' |
---|
| 267 | '%s Naira Student Welfare Assurance Fee and ' |
---|
| 268 | % (union_fee, welfare_fee)) |
---|
[13410] | 269 | elif self.context.p_category in ( |
---|
| 270 | 'clearance_incl', 'clearance_medical_incl') and academic_session: |
---|
[13414] | 271 | matric_gown_fee = gateway_net_amt(academic_session.matric_gown_fee) |
---|
| 272 | lapel_fee = gateway_net_amt(academic_session.lapel_fee) |
---|
[13437] | 273 | text += ('Acceptance Fee, ' |
---|
| 274 | '%s Naira Matriculation Gown Fee, ' |
---|
| 275 | '%s Naira Lapel/File Fee and ' |
---|
[14239] | 276 | % (matric_gown_fee, lapel_fee)) |
---|
[13437] | 277 | return text + '250.0 Naira Transaction Charge.' |
---|
[11625] | 278 | |
---|
[9914] | 279 | class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage): |
---|
| 280 | """ Page to display student study levels |
---|
| 281 | """ |
---|
| 282 | grok.context(ICustomStudentStudyLevel) |
---|
[10480] | 283 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( |
---|
[14206] | 284 | 'total_credits', 'gpa', 'level', 'imported_gpa', 'imported_cgpa') |
---|
[9914] | 285 | form_fields[ |
---|
| 286 | 'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
| 287 | |
---|
[14000] | 288 | @property |
---|
| 289 | def show_results(self): |
---|
| 290 | isStudent = getattr( |
---|
| 291 | self.request.principal, 'user_type', None) == 'student' |
---|
[14302] | 292 | # Temporarily disabled on 1/12/2016 |
---|
| 293 | if isStudent: |
---|
[14000] | 294 | return False |
---|
[14302] | 295 | #if isStudent and self.context.student.state != RETURNING \ |
---|
| 296 | # and self.context.student.current_level == self.context.level: |
---|
| 297 | # return False |
---|
[14000] | 298 | return True |
---|
| 299 | |
---|
[13834] | 300 | class CustomStudyLevelManageFormPage(StudyLevelManageFormPage): |
---|
| 301 | """ Page to edit the student study level data |
---|
| 302 | """ |
---|
| 303 | grok.context(ICustomStudentStudyLevel) |
---|
| 304 | |
---|
| 305 | class CustomStudyLevelEditFormPage(StudyLevelEditFormPage): |
---|
| 306 | """ Page to edit the student study level data by students |
---|
| 307 | """ |
---|
| 308 | grok.context(ICustomStudentStudyLevel) |
---|
| 309 | |
---|
[13059] | 310 | class CustomExportPDFCourseRegistrationSlip( |
---|
| 311 | NigeriaExportPDFCourseRegistrationSlip): |
---|
[9914] | 312 | """Deliver a PDF slip of the context. |
---|
| 313 | """ |
---|
| 314 | grok.context(ICustomStudentStudyLevel) |
---|
| 315 | form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit( |
---|
[10102] | 316 | 'level_session', 'level_verdict', |
---|
[14206] | 317 | 'validated_by', 'validation_date', 'gpa', 'level', |
---|
| 318 | 'imported_gpa', 'imported_cgpa') |
---|
[9914] | 319 | |
---|
[10269] | 320 | omit_fields = ('password', 'suspended', 'suspended_comment', |
---|
[10689] | 321 | 'phone', 'adm_code', 'sex', 'email', 'date_of_birth', |
---|
[13713] | 322 | 'department', 'current_mode', 'current_level', 'flash_notice') |
---|
[10269] | 323 | |
---|
[14000] | 324 | @property |
---|
| 325 | def show_results(self): |
---|
| 326 | isStudent = getattr( |
---|
| 327 | self.request.principal, 'user_type', None) == 'student' |
---|
[14302] | 328 | # Temporarily disabled on 1/12/2016 |
---|
| 329 | if isStudent: |
---|
| 330 | return False |
---|
| 331 | #if isStudent and self.context.student.state != RETURNING \ |
---|
| 332 | # and self.context.student.current_level == self.context.level: |
---|
| 333 | # return False |
---|
| 334 | return True |
---|
[14000] | 335 | |
---|
[13038] | 336 | def update(self): |
---|
| 337 | if self.context.student.state != REGISTERED \ |
---|
[13051] | 338 | and self.context.student.current_level == self.context.level: |
---|
[13038] | 339 | self.flash(_('Forbidden'), type="warning") |
---|
| 340 | self.redirect(self.url(self.context)) |
---|
[14000] | 341 | return |
---|
[13038] | 342 | |
---|
[9914] | 343 | @property |
---|
| 344 | def label(self): |
---|
| 345 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 346 | lang = self.request.cookies.get('kofa.language', portal_language) |
---|
| 347 | level_title = translate(self.context.level_title, 'waeup.kofa', |
---|
| 348 | target_language=lang) |
---|
| 349 | line0 = '' |
---|
[13788] | 350 | if self.context.student.is_postgrad: |
---|
| 351 | line0 = 'SCHOOL OF POSTGRADUATE STUDIES\n' |
---|
| 352 | elif self.context.student.current_mode.endswith('_pt'): |
---|
[9914] | 353 | line0 = 'DIRECTORATE OF PART-TIME DEGREE PROGRAMMES\n' |
---|
[13866] | 354 | line1 = translate(_('Course Registration Slip'), |
---|
| 355 | target_language=portal_language) \ |
---|
[9914] | 356 | + ' %s' % level_title |
---|
[13866] | 357 | line2 = translate(_('Session'), |
---|
| 358 | target_language=portal_language) \ |
---|
[9914] | 359 | + ' %s' % self.context.getSessionString |
---|
| 360 | return '%s%s\n%s' % (line0, line1, line2) |
---|
| 361 | |
---|
| 362 | @property |
---|
| 363 | def title(self): |
---|
| 364 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 365 | return translate(_('Units Registered'), target_language=portal_language) |
---|
[9914] | 366 | |
---|
| 367 | def _signatures(self): |
---|
[13647] | 368 | if self.context.student.current_mode.endswith('_pt') \ |
---|
| 369 | or self.context.student.current_mode == 'found': |
---|
| 370 | return ( |
---|
| 371 | [('I have selected the course on the advise of my Head of ' |
---|
| 372 | 'Department. <br>', _('Student\'s Signature'), '<br>')], |
---|
| 373 | [('This student has satisfied the department\'s requirements. ' |
---|
| 374 | 'I recommend to approve the course registration. <br>', |
---|
| 375 | _('Head of Department\'s Signature'), '<br>')], |
---|
[13946] | 376 | [('' , _('Deputy Registrar\'s Signature'), '<br>')], |
---|
[13647] | 377 | [('', _('Director\'s Signature'))] |
---|
| 378 | ) |
---|
| 379 | if self.context.student.current_mode in ( |
---|
| 380 | 'de_ft', 'ug_ft', 'dp_ft', 'transfer'): |
---|
[13649] | 381 | return ([_('Academic Adviser\'s Signature'), |
---|
| 382 | _('Faculty Officer\'s Signature'), |
---|
| 383 | _('Student\'s Signature')],) |
---|
| 384 | |
---|
[13647] | 385 | if self.context.student.current_mode in ('special_pg_ft', 'special_pg_pt'): |
---|
| 386 | return ( |
---|
[13676] | 387 | [('I declare that all items of information supplied above are correct:' , |
---|
[13680] | 388 | _('Student\'s Signature'), '<br>')], |
---|
[13676] | 389 | [('We approved the above registration:', |
---|
[13680] | 390 | _('Major Supervisor (Name / Signature)'), '')], |
---|
| 391 | [('', _('Co-Supervisor (Name / Signature)'), '')], |
---|
[13676] | 392 | [('', _('Head of Department'), '<br>')], |
---|
| 393 | [('The student has satisfied the conditions for renewal of ' |
---|
| 394 | 'registration for graduate school programme in this university:', |
---|
[13680] | 395 | _('Secretary <br /> (School of Postgraduate Studies)'), '')], |
---|
| 396 | [('', _('Dean <br /> (School of Postgraduate Studies)'), '')], |
---|
[13647] | 397 | ) |
---|
| 398 | return None |
---|
[9914] | 399 | |
---|
[13647] | 400 | |
---|
[9914] | 401 | def render(self): |
---|
| 402 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 403 | Sem = translate(_('Sem.'), target_language=portal_language) |
---|
| 404 | Code = translate(_('Code'), target_language=portal_language) |
---|
| 405 | Title = translate(_('Title'), target_language=portal_language) |
---|
| 406 | Cred = translate(_('Cred.'), target_language=portal_language) |
---|
[14000] | 407 | if self.show_results: |
---|
| 408 | Score = translate(_('Score'), target_language=portal_language) |
---|
| 409 | #CA = translate(_('CA'), target_language=portal_language) |
---|
| 410 | Grade = translate(_('Grade'), target_language=portal_language) |
---|
[13866] | 411 | Signature = translate(_('Lecturer\'s Signature'), 'waeup.aaue', |
---|
[9914] | 412 | target_language=portal_language) |
---|
| 413 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 414 | self.request, self.omit_fields) |
---|
| 415 | students_utils = getUtility(IStudentsUtils) |
---|
[10442] | 416 | |
---|
| 417 | tabledata = [] |
---|
| 418 | tableheader = [] |
---|
| 419 | contenttitle = [] |
---|
| 420 | for i in range(1,7): |
---|
| 421 | tabledata.append(sorted( |
---|
| 422 | [value for value in self.context.values() if value.semester == i], |
---|
| 423 | key=lambda value: str(value.semester) + value.code)) |
---|
[14000] | 424 | if self.show_results: |
---|
| 425 | tableheader.append([(Code,'code', 2.0), |
---|
| 426 | (Title,'title', 7), |
---|
| 427 | (Cred, 'credits', 1.5), |
---|
| 428 | (Score, 'score', 1.4), |
---|
| 429 | #(CA, 'ca', 1.4), |
---|
| 430 | (Grade, 'grade', 1.4), |
---|
| 431 | (Signature, 'dummy', 3), |
---|
| 432 | ]) |
---|
| 433 | else: |
---|
| 434 | tableheader.append([(Code,'code', 2.0), |
---|
| 435 | (Title,'title', 7), |
---|
| 436 | (Cred, 'credits', 1.5), |
---|
| 437 | (Signature, 'dummy', 3), |
---|
| 438 | ]) |
---|
[9914] | 439 | if len(self.label.split('\n')) == 3: |
---|
| 440 | topMargin = 1.9 |
---|
| 441 | elif len(self.label.split('\n')) == 2: |
---|
| 442 | topMargin = 1.7 |
---|
| 443 | else: |
---|
| 444 | topMargin = 1.5 |
---|
| 445 | return students_utils.renderPDF( |
---|
| 446 | self, 'course_registration_slip.pdf', |
---|
| 447 | self.context.student, studentview, |
---|
[10442] | 448 | tableheader=tableheader, |
---|
| 449 | tabledata=tabledata, |
---|
[9914] | 450 | signatures=self._signatures(), |
---|
[10269] | 451 | topMargin=topMargin, |
---|
| 452 | omit_fields=self.omit_fields |
---|
[9914] | 453 | ) |
---|
[10566] | 454 | |
---|
[14165] | 455 | class CustomStudyCourseTranscriptPage(StudyCourseTranscriptPage): |
---|
| 456 | """ Page to display the student's transcript. |
---|
| 457 | """ |
---|
| 458 | grok.require('waeup.viewStudent') |
---|
| 459 | |
---|
[13059] | 460 | class CustomExportPDFTranscriptSlip(ExportPDFTranscriptSlip): |
---|
[10566] | 461 | """Deliver a PDF slip of the context. |
---|
| 462 | """ |
---|
[14315] | 463 | # grok.require('waeup.viewStudent') |
---|
[10566] | 464 | |
---|
[14267] | 465 | note = _(""" |
---|
| 466 | <br /><br /><br /><br /> |
---|
| 467 | <font size='10'> |
---|
| 468 | <strong>Note:</strong> This copy is subject to correction for typographical errors and ratification by the departmental board. |
---|
| 469 | </font> |
---|
| 470 | """) |
---|
| 471 | |
---|
[10566] | 472 | def _sigsInFooter(self): |
---|
| 473 | return [] |
---|
| 474 | |
---|
| 475 | def _signatures(self): |
---|
| 476 | return ([( |
---|
[14136] | 477 | 'Mrs. Uniamikogbo, S.O., mnim, manupa <br /> Prin. Asst Registrar <br /> ' |
---|
[11555] | 478 | 'Exams, Records and Data Processing Division <br /> For: Registrar')],) |
---|
[10922] | 479 | |
---|
[13834] | 480 | def render(self): |
---|
| 481 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 482 | Term = translate(_('Sem.'), target_language=portal_language) |
---|
| 483 | Code = translate(_('Code'), target_language=portal_language) |
---|
| 484 | Title = translate(_('Title'), target_language=portal_language) |
---|
| 485 | Cred = translate(_('Credits'), target_language=portal_language) |
---|
| 486 | Score = translate(_('Score'), target_language=portal_language) |
---|
| 487 | Grade = translate(_('Grade'), target_language=portal_language) |
---|
[13834] | 488 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 489 | self.request, self.omit_fields) |
---|
| 490 | students_utils = getUtility(IStudentsUtils) |
---|
| 491 | |
---|
| 492 | tableheader = [(Code,'code', 2.5), |
---|
| 493 | (Title,'title', 7), |
---|
| 494 | (Term, 'semester', 1.5), |
---|
| 495 | (Cred, 'credits', 1.5), |
---|
[14136] | 496 | (Score, 'total_score', 1.5), |
---|
[13834] | 497 | (Grade, 'grade', 1.5), |
---|
| 498 | ] |
---|
| 499 | |
---|
| 500 | return students_utils.renderPDFTranscript( |
---|
| 501 | self, 'transcript.pdf', |
---|
| 502 | self.context.student, studentview, |
---|
| 503 | omit_fields=self.omit_fields, |
---|
| 504 | tableheader=tableheader, |
---|
| 505 | signatures=self._signatures(), |
---|
| 506 | sigs_in_footer=self._sigsInFooter(), |
---|
[14295] | 507 | note = self.note, |
---|
| 508 | no_passport=True |
---|
[13834] | 509 | ) |
---|
| 510 | |
---|
[13059] | 511 | class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip): |
---|
[10922] | 512 | """Deliver a PDF Admission slip. |
---|
| 513 | """ |
---|
| 514 | |
---|
| 515 | @property |
---|
| 516 | def label(self): |
---|
| 517 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 518 | return translate(_('e-Admission Slip \n'), |
---|
| 519 | target_language=portal_language) \ |
---|
[10922] | 520 | + ' %s' % self.context.display_fullname |
---|
[11597] | 521 | |
---|
[13059] | 522 | class CustomExportPDFClearanceSlip(NigeriaExportPDFClearanceSlip): |
---|
[11606] | 523 | """Deliver a PDF slip of the context. |
---|
| 524 | """ |
---|
| 525 | |
---|
| 526 | @property |
---|
| 527 | def label(self): |
---|
| 528 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[14114] | 529 | return translate(_('Verification/Clearance Slip\n'), |
---|
[13866] | 530 | target_language=portal_language) \ |
---|
[11606] | 531 | + ' %s' % self.context.display_fullname |
---|
| 532 | |
---|
[14084] | 533 | @property |
---|
| 534 | def form_fields(self): |
---|
| 535 | if self.context.is_postgrad: |
---|
| 536 | form_fields = grok.AutoFields( |
---|
| 537 | ICustomPGStudentClearance).omit('clearance_locked') |
---|
| 538 | else: |
---|
| 539 | form_fields = grok.AutoFields( |
---|
| 540 | ICustomUGStudentClearance).omit('clearance_locked') |
---|
| 541 | if not getattr(self.context, 'officer_comment'): |
---|
| 542 | form_fields = form_fields.omit('officer_comment') |
---|
[14104] | 543 | form_fields = form_fields.omit('def_adm') |
---|
[14084] | 544 | return form_fields |
---|
| 545 | |
---|
[11597] | 546 | class StudentGetMatricNumberPage(UtilityView, grok.View): |
---|
| 547 | """ Construct and set the matriculation number. |
---|
| 548 | """ |
---|
| 549 | grok.context(IStudent) |
---|
| 550 | grok.name('get_matric_number') |
---|
| 551 | grok.require('waeup.viewStudent') |
---|
| 552 | |
---|
| 553 | def update(self): |
---|
| 554 | students_utils = getUtility(IStudentsUtils) |
---|
| 555 | msg, mnumber = students_utils.setMatricNumber(self.context) |
---|
| 556 | if msg: |
---|
| 557 | self.flash(msg, type="danger") |
---|
| 558 | else: |
---|
| 559 | self.flash(_('Matriculation number %s assigned.' % mnumber)) |
---|
[11602] | 560 | self.context.writeLogMessage(self, '%s assigned' % mnumber) |
---|
[11597] | 561 | self.redirect(self.url(self.context)) |
---|
| 562 | return |
---|
| 563 | |
---|
| 564 | def render(self): |
---|
[11607] | 565 | return |
---|
| 566 | |
---|
[13059] | 567 | class ExportPDFMatricNumberSlip(UtilityView, grok.View): |
---|
[11607] | 568 | """Deliver a PDF notification slip. |
---|
| 569 | """ |
---|
| 570 | grok.context(ICustomStudent) |
---|
| 571 | grok.name('matric_number_slip.pdf') |
---|
| 572 | grok.require('waeup.viewStudent') |
---|
| 573 | prefix = 'form' |
---|
| 574 | |
---|
| 575 | form_fields = grok.AutoFields(ICustomStudent).select( |
---|
| 576 | 'student_id', 'matric_number') |
---|
[13713] | 577 | omit_fields = ('date_of_birth', 'current_level', 'flash_notice') |
---|
[11607] | 578 | |
---|
| 579 | @property |
---|
[13489] | 580 | def title(self): |
---|
| 581 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 582 | return translate(_('Matriculation Number'), 'waeup.kofa', |
---|
[13489] | 583 | target_language=portal_language) |
---|
| 584 | |
---|
| 585 | @property |
---|
[11607] | 586 | def label(self): |
---|
| 587 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 588 | return translate(_('Matriculation Number Slip\n'), |
---|
| 589 | target_language=portal_language) \ |
---|
[11607] | 590 | + ' %s' % self.context.display_fullname |
---|
| 591 | |
---|
| 592 | def render(self): |
---|
| 593 | if self.context.state not in (PAID,) or not self.context.is_fresh \ |
---|
| 594 | or not self.context.matric_number: |
---|
| 595 | self.flash('Not allowed.', type="danger") |
---|
| 596 | self.redirect(self.url(self.context)) |
---|
| 597 | return |
---|
| 598 | students_utils = getUtility(IStudentsUtils) |
---|
[11609] | 599 | pre_text = _('Congratulations! Your acceptance fee and school fees ' + |
---|
| 600 | 'payments have been received and your matriculation ' + |
---|
| 601 | 'number generated with details as follows.') |
---|
[11607] | 602 | return students_utils.renderPDFAdmissionLetter(self, |
---|
| 603 | self.context.student, omit_fields=self.omit_fields, |
---|
[13353] | 604 | pre_text=pre_text, post_text='') |
---|
| 605 | |
---|
[13489] | 606 | class ExportPersonalDataSlip(UtilityView, grok.View): |
---|
| 607 | """Deliver a PDF notification slip. |
---|
| 608 | """ |
---|
| 609 | grok.context(ICustomStudent) |
---|
| 610 | grok.name('personal_data_slip.pdf') |
---|
| 611 | grok.require('waeup.viewStudent') |
---|
| 612 | prefix = 'form' |
---|
| 613 | note = None |
---|
| 614 | |
---|
| 615 | form_fields = grok.AutoFields(ICustomStudentPersonal).omit('personal_updated') |
---|
[13713] | 616 | omit_fields = ('suspended', 'suspended_comment', 'adm_code', |
---|
| 617 | 'certificate', 'flash_notice') |
---|
[13489] | 618 | |
---|
| 619 | @property |
---|
| 620 | def title(self): |
---|
| 621 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 622 | return translate(_('Personal Data'), 'waeup.kofa', |
---|
[13489] | 623 | target_language=portal_language) |
---|
| 624 | |
---|
| 625 | @property |
---|
| 626 | def label(self): |
---|
| 627 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
[13866] | 628 | return translate(_('Personal Data Slip\n'), |
---|
| 629 | target_language=portal_language) \ |
---|
[13489] | 630 | + ' %s' % self.context.display_fullname |
---|
| 631 | |
---|
| 632 | def render(self): |
---|
| 633 | studentview = StudentBasePDFFormPage(self.context.student, |
---|
| 634 | self.request, self.omit_fields) |
---|
| 635 | students_utils = getUtility(IStudentsUtils) |
---|
| 636 | return students_utils.renderPDF(self, 'personal_data_slip.pdf', |
---|
| 637 | self.context.student, studentview, note=self.note, |
---|
| 638 | omit_fields=self.omit_fields) |
---|
| 639 | |
---|
[13462] | 640 | class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage): |
---|
| 641 | """ Page to manage bed tickets. |
---|
| 642 | This manage form page is for both students and students officers. |
---|
| 643 | """ |
---|
| 644 | with_hostel_selection = True |
---|
| 645 | |
---|
[13353] | 646 | class CustomBedTicketAddPage(BedTicketAddPage): |
---|
[13360] | 647 | with_ac = False |
---|
[13380] | 648 | |
---|
| 649 | class CustomStudentFilesUploadPage(StudentFilesUploadPage): |
---|
| 650 | """ View to upload files by student. Inherit from same class in |
---|
| 651 | base package, not from kofacustom.nigeria which |
---|
| 652 | requires that no application slip exists. |
---|
[13770] | 653 | """ |
---|
| 654 | |
---|
| 655 | class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): |
---|
| 656 | """ Page to display course tickets |
---|
| 657 | """ |
---|
| 658 | form_fields = grok.AutoFields(ICustomCourseTicket) |
---|
| 659 | |
---|
| 660 | class CustomCourseTicketManageFormPage(CourseTicketManageFormPage): |
---|
| 661 | """ Page to manage course tickets |
---|
| 662 | """ |
---|
| 663 | form_fields = grok.AutoFields(ICustomCourseTicket) |
---|
| 664 | form_fields['title'].for_display = True |
---|
| 665 | form_fields['fcode'].for_display = True |
---|
| 666 | form_fields['dcode'].for_display = True |
---|
| 667 | form_fields['semester'].for_display = True |
---|
| 668 | form_fields['passmark'].for_display = True |
---|
| 669 | form_fields['credits'].for_display = True |
---|
| 670 | form_fields['mandatory'].for_display = False |
---|
| 671 | form_fields['automatic'].for_display = True |
---|
| 672 | form_fields['carry_over'].for_display = True |
---|
| 673 | |
---|
| 674 | class CustomEditScoresPage(EditScoresPage): |
---|
| 675 | """Page that filters and lists students. |
---|
| 676 | """ |
---|
| 677 | grok.template('editscorespage') |
---|
| 678 | |
---|
[13937] | 679 | |
---|
| 680 | def _extract_uploadfile(self, uploadfile): |
---|
| 681 | """Get a mapping of student-ids to scores. |
---|
| 682 | |
---|
| 683 | The mapping is constructed by reading contents from `uploadfile`. |
---|
| 684 | |
---|
| 685 | We expect uploadfile to be a regular CSV file with columns |
---|
| 686 | ``student_id``, ``score`` and ``ca`` (other cols are ignored). |
---|
| 687 | """ |
---|
| 688 | result = dict() |
---|
| 689 | data = StringIO(uploadfile.read()) # ensure we have something seekable |
---|
| 690 | reader = csv.DictReader(data) |
---|
| 691 | for row in reader: |
---|
| 692 | if not ('student_id' in row and 'score' in row and 'ca' in row): |
---|
| 693 | continue |
---|
| 694 | result[row['student_id']] = (row['score'], row['ca']) |
---|
| 695 | return result |
---|
| 696 | |
---|
[14288] | 697 | def _update_scores(self, form): |
---|
[13937] | 698 | ob_class = self.__implemented__.__name__.replace('waeup.kofa.', '') |
---|
[14288] | 699 | error = '' |
---|
[13937] | 700 | if 'UPDATE_FILE' in form: |
---|
| 701 | if form['uploadfile']: |
---|
| 702 | try: |
---|
| 703 | formvals = self._extract_uploadfile(form['uploadfile']) |
---|
| 704 | except: |
---|
| 705 | self.flash( |
---|
| 706 | _('Uploaded file contains illegal data. Ignored'), |
---|
| 707 | type="danger") |
---|
[14288] | 708 | return False |
---|
[13937] | 709 | else: |
---|
| 710 | self.flash( |
---|
| 711 | _('No file provided.'), type="danger") |
---|
[14288] | 712 | return False |
---|
[13937] | 713 | else: |
---|
| 714 | formvals = dict(zip(form['sids'], zip(form['scores'], form['cas']))) |
---|
[14149] | 715 | for ticket in self.editable_tickets: |
---|
[13937] | 716 | ticket_error = False |
---|
| 717 | score = ticket.score |
---|
| 718 | ca = ticket.ca |
---|
| 719 | sid = ticket.student.student_id |
---|
| 720 | if formvals[sid][0] == '': |
---|
| 721 | score = None |
---|
| 722 | if formvals[sid][1] == '': |
---|
| 723 | ca = None |
---|
| 724 | try: |
---|
| 725 | if formvals[sid][0]: |
---|
| 726 | score = int(formvals[sid][0]) |
---|
| 727 | if formvals[sid][1]: |
---|
| 728 | ca = int(formvals[sid][1]) |
---|
| 729 | except ValueError: |
---|
| 730 | error += '%s, ' % ticket.student.display_fullname |
---|
| 731 | ticket_error = True |
---|
| 732 | if not ticket_error and ticket.score != score: |
---|
[14113] | 733 | try: |
---|
| 734 | ticket.score = score |
---|
| 735 | except TooBig: |
---|
| 736 | error += '%s, ' % ticket.student.display_fullname |
---|
| 737 | ticket_error = True |
---|
| 738 | pass |
---|
[13937] | 739 | ticket.student.__parent__.logger.info( |
---|
| 740 | '%s - %s %s/%s score updated (%s)' % |
---|
| 741 | (ob_class, ticket.student.student_id, |
---|
| 742 | ticket.level, ticket.code, score)) |
---|
| 743 | if not ticket_error and ticket.ca != ca: |
---|
[14113] | 744 | try: |
---|
| 745 | ticket.ca = ca |
---|
| 746 | except TooBig: |
---|
| 747 | error += '%s, ' % ticket.student.display_fullname |
---|
| 748 | pass |
---|
[13937] | 749 | ticket.student.__parent__.logger.info( |
---|
| 750 | '%s - %s %s/%s ca updated (%s)' % |
---|
| 751 | (ob_class, ticket.student.student_id, |
---|
| 752 | ticket.level, ticket.code, ca)) |
---|
| 753 | if error: |
---|
| 754 | self.flash(_('Error: Score(s) and CA(s) of %s have not be updated. ' |
---|
[14113] | 755 | % error.strip(', ')), type="danger") |
---|
[14288] | 756 | return True |
---|
| 757 | |
---|
| 758 | class EditPreviousSessionScoresPage(CustomEditScoresPage): |
---|
| 759 | |
---|
| 760 | grok.name('edit_prev_scores') |
---|
| 761 | |
---|
| 762 | def update(self, *args, **kw): |
---|
| 763 | form = self.request.form |
---|
| 764 | self.current_academic_session = grok.getSite()[ |
---|
| 765 | 'configuration'].current_academic_session |
---|
| 766 | if self.context.__parent__.__parent__.score_editing_disabled: |
---|
| 767 | self.flash(_('Score editing disabled.'), type="warning") |
---|
| 768 | self.redirect(self.url(self.context)) |
---|
[13939] | 769 | return |
---|
[14288] | 770 | if not self.current_academic_session: |
---|
| 771 | self.flash(_('Current academic session not set.'), type="warning") |
---|
| 772 | self.redirect(self.url(self.context)) |
---|
| 773 | return |
---|
| 774 | previous_session = self.current_academic_session - 1 |
---|
| 775 | self.session_title = academic_sessions_vocab.getTerm( |
---|
| 776 | previous_session).title |
---|
| 777 | self.tickets = self._searchCatalog(previous_session) |
---|
| 778 | if not self.tickets: |
---|
| 779 | self.flash(_('No student found.'), type="warning") |
---|
| 780 | self.redirect(self.url(self.context)) |
---|
| 781 | return |
---|
| 782 | self.editable_tickets = [ |
---|
| 783 | ticket for ticket in self.tickets if ticket.editable_by_lecturer] |
---|
| 784 | if not 'UPDATE_TABLE' in form and not 'UPDATE_FILE' in form: |
---|
| 785 | return |
---|
| 786 | if not self.editable_tickets: |
---|
| 787 | return |
---|
| 788 | success = self._update_scores(form) |
---|
| 789 | if success: |
---|
| 790 | self.flash(_('You successfully updated course results.')) |
---|
[13900] | 791 | return |
---|
| 792 | |
---|
| 793 | class CustomExportPDFScoresSlip(ExportPDFScoresSlip): |
---|
| 794 | """Deliver a PDF slip of course tickets for a lecturer. |
---|
| 795 | """ |
---|
| 796 | |
---|
[14315] | 797 | def data(self, session): |
---|
[13900] | 798 | cat = queryUtility(ICatalog, name='coursetickets_catalog') |
---|
| 799 | coursetickets = cat.searchResults( |
---|
| 800 | session=(session, session), |
---|
| 801 | code=(self.context.code, self.context.code) |
---|
| 802 | ) |
---|
[14149] | 803 | # In AAUE only editable tickets can be printed |
---|
| 804 | editable_tickets = [ |
---|
| 805 | ticket for ticket in coursetickets if ticket.editable_by_lecturer] |
---|
[13963] | 806 | header = [[_(''), |
---|
| 807 | _('Matric No.'), |
---|
[13900] | 808 | _('Reg. No.'), |
---|
| 809 | _('Fullname'), |
---|
| 810 | _('Status'), |
---|
[13963] | 811 | _('Course of\nStudies'), |
---|
[13900] | 812 | _('Level'), |
---|
[13963] | 813 | _('Exam\nScore'), |
---|
[13964] | 814 | _(' CA '), |
---|
| 815 | _('Total '), |
---|
[13963] | 816 | _('Grade'), |
---|
| 817 | ],] |
---|
[14288] | 818 | sorted_tickets = sorted(editable_tickets, |
---|
| 819 | key=lambda ticket: ticket.student.certcode + |
---|
| 820 | ticket.student.display_fullname + str(ticket.level)) |
---|
| 821 | no = 1 |
---|
[13907] | 822 | tickets = [] |
---|
[14315] | 823 | passed = 0 |
---|
| 824 | failed = 0 |
---|
[14149] | 825 | # In AAUE only editable tickets can be printed |
---|
[14288] | 826 | for ticket in sorted_tickets: |
---|
[13963] | 827 | if None in (ticket.score, ticket.ca): |
---|
| 828 | total = 'n/a' |
---|
[13964] | 829 | grade = 'n/a' |
---|
[13963] | 830 | else: |
---|
| 831 | total = ticket.score + ticket.ca |
---|
[14316] | 832 | grade = getGradeWeightFromScore(total, ticket.student)[0] |
---|
[14315] | 833 | if grade == 'F': |
---|
| 834 | failed += 1 |
---|
| 835 | else: |
---|
| 836 | passed += 1 |
---|
[13964] | 837 | fullname = textwrap.fill(ticket.student.display_fullname, 30) |
---|
[13963] | 838 | row = [no, |
---|
| 839 | ticket.student.matric_number, |
---|
[13900] | 840 | ticket.student.reg_number, |
---|
[13964] | 841 | fullname, |
---|
[13900] | 842 | ticket.student.translated_state, |
---|
| 843 | ticket.student.certcode, |
---|
| 844 | ticket.level, |
---|
[13963] | 845 | ticket.ca, |
---|
[13900] | 846 | ticket.score, |
---|
[13963] | 847 | total, |
---|
[13964] | 848 | grade, |
---|
[13963] | 849 | ] |
---|
[13907] | 850 | tickets.append(row) |
---|
[13963] | 851 | no += 1 |
---|
[14317] | 852 | total = passed + failed |
---|
[14320] | 853 | passed_perc = 0 |
---|
| 854 | failed_perc = 0 |
---|
[14317] | 855 | if total: |
---|
[14320] | 856 | passed_perc = 100 * passed / total |
---|
| 857 | failed_perc = 100 * failed / total |
---|
| 858 | return header + tickets, [ |
---|
| 859 | total, passed, passed_perc, failed, failed_perc] |
---|
[14288] | 860 | |
---|
| 861 | class DownloadPreviousSessionScoresView(DownloadScoresView): |
---|
| 862 | """View that exports scores. |
---|
| 863 | """ |
---|
| 864 | grok.name('download_prev_scores') |
---|
| 865 | |
---|
| 866 | def update(self): |
---|
| 867 | self.current_academic_session = grok.getSite()[ |
---|
| 868 | 'configuration'].current_academic_session |
---|
| 869 | if self.context.__parent__.__parent__.score_editing_disabled: |
---|
| 870 | self.flash(_('Score editing disabled.'), type="warning") |
---|
| 871 | self.redirect(self.url(self.context)) |
---|
| 872 | return |
---|
| 873 | if not self.current_academic_session: |
---|
| 874 | self.flash(_('Current academic session not set.'), type="warning") |
---|
| 875 | self.redirect(self.url(self.context)) |
---|
| 876 | return |
---|
| 877 | site = grok.getSite() |
---|
| 878 | exporter = getUtility(ICSVExporter, name='lecturer') |
---|
| 879 | self.csv = exporter.export_filtered(site, filepath=None, |
---|
| 880 | catalog='coursetickets', |
---|
| 881 | session=self.current_academic_session-1, |
---|
| 882 | level=None, |
---|
| 883 | code=self.context.code) |
---|
[14306] | 884 | return |
---|
| 885 | |
---|
| 886 | class AlumniRequestPasswordPage(StudentRequestPasswordPage): |
---|
| 887 | """Captcha'd request password page for students. |
---|
| 888 | """ |
---|
| 889 | grok.name('alumni_requestpw') |
---|
| 890 | grok.require('waeup.Anonymous') |
---|
| 891 | grok.template('alumni_requestpw') |
---|
| 892 | form_fields = grok.AutoFields(IStudentRequestPW).select( |
---|
| 893 | 'lastname','number','email') |
---|
| 894 | label = _('Search student record and send password for first-time login') |
---|
| 895 | |
---|
| 896 | def _redirect_no_student(self): |
---|
| 897 | self.flash(_('No student record found.'), type="warning") |
---|
| 898 | self.redirect(self.application_url() + '/applicants/trans2017/register') |
---|
[14288] | 899 | return |
---|