Changeset 13936
- Timestamp:
- 14 Jun 2016, 08:53:30 (9 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r13908 r13936 4 4 1.4.2.dev0 (unreleased) 5 5 ======================= 6 7 * Add file upload functionality to `EditScoresPage`. 6 8 7 9 * Add `LecturerLandingPage` and `LecturerCourses` `ManageLink` -
main/waeup.kofa/trunk/layout/static/css/base.css
r13513 r13936 143 143 input.btn { 144 144 padding: 6px 12px; 145 margin-right: 4px;146 145 } 147 146 -
main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/fileupload.pt
r12447 r13936 21 21 <div class="input-group" tal:condition="not: viewlet/file_exists"> 22 22 <div class="input-group-btn"> 23 <div class="btn btn-default btn-file" >23 <div class="btn btn-default btn-file" i18n:translate=""> 24 24 Select new file… 25 25 <input type="file" tal:attributes="name viewlet/input_name" /> -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r13935 r13936 3087 3087 grok.template('editscorespage') 3088 3088 pnav = 1 3089 doclink = DOCLINK + '/students/browser.html#batch-editing-scores-by-lecturers' 3089 3090 3090 3091 def label(self): … … 3139 3140 self.redirect(self.url(self.context)) 3140 3141 return 3141 if not 'UPDATE ' in form:3142 if not 'UPDATE_TABLE' in form and not 'UPDATE_FILE' in form: 3142 3143 return 3143 3144 error = '' 3144 3145 if not editable_tickets: 3145 3146 return 3146 formvals = dict(zip(form['sids'], form['scores'])) 3147 if form['uploadfile']: 3148 try: 3149 formvals = self._extract_uploadfile(form['uploadfile']) 3150 except: 3147 if 'UPDATE_FILE' in form: 3148 if form['uploadfile']: 3149 try: 3150 formvals = self._extract_uploadfile(form['uploadfile']) 3151 except: 3152 self.flash( 3153 _('Uploaded file contains illegal data. Ignored'), 3154 type="danger") 3155 return 3156 else: 3151 3157 self.flash( 3152 _('Uploaded file contains illegal data. Ignored'), 3153 type="danger") 3158 _('No file provided.'), type="danger") 3159 return 3160 else: 3161 formvals = dict(zip(form['sids'], form['scores'])) 3154 3162 for ticket in editable_tickets: 3155 3163 score = ticket.score -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/editscorespage.pt
r13935 r13936 1 <p i18n:domain="waeup.kofa" i18n:translate="edit_scores_info"> 2 This page helps you to update your students' course results. 3 You can either update scores by importing a csv file 4 (press 'Help' for further information) or by 5 changing score values in the table below. Only scores of students 6 in state 'courses validated' and current academic session 7 can be modified. 8 </p> 9 1 10 <form i18n:domain="waeup.kofa" method="POST" enctype="multipart/form-data"> 2 11 <br /> 12 <div class="input-group"> 13 <div class="input-group-btn"> 14 <div class="btn btn-default btn-file" i18n:translate=""> 15 Select file… 16 <input type="file" name="uploadfile:file" /> 17 </div> 18 </div> 19 <input type="text" class="form-control" readonly> 20 <div class="input-group-btn"> 21 <input type="submit" name="UPDATE_FILE" i18n:translate="" 22 value="Update editable scores from csv file" 23 class="btn btn-primary" /> 24 <button class="btn btn-warning" data-toggle="modal" 25 data-target="#myModal" i18n:translate=""> 26 Help 27 </button> 28 </div> 29 </div> 30 31 <!-- Modal --> 32 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" 33 aria-labelledby="myModalLabel" aria-hidden="true"> 34 <div class="modal-dialog"> 35 <div class="modal-content"> 36 <div class="modal-header"> 37 <button type="button" class="close" data-dismiss="modal" 38 aria-hidden="true">×</button> 39 <h4 class="modal-title" id="myModalLabel" i18n:translate=""> 40 Instructions for File Upload 41 </h4> 42 </div> 43 <div class="modal-body" i18n:translate="lecturer_help"> 44 ... 45 </div> 46 </div><!-- /.modal-content --> 47 </div><!-- /.modal-dialog --> 48 </div><!-- /.modal --> 49 50 <br /><br /> 3 51 4 52 <table class="kofa-data-table dataTable"> 5 53 <thead> 6 54 <tr> 7 55 <th i18n:translate="">Matric No.</th> 8 56 <th i18n:translate="">Student Id</th> … … 12 60 <th i18n:translate="">Level</th> 13 61 <th i18n:translate="">Score</th> 14 62 </tr> 15 63 </thead> 16 64 <tbody> … … 18 66 <td tal:content="ticket/student/matric_number">MATRIC_NUMBER</td> 19 67 <td tal:content="ticket/student/student_id">STUDENT ID</td> 20 68 <td tal:content="ticket/student/display_fullname">FULLNAME</td> 21 69 <td tal:content="ticket/student/translated_state">STATE</td> 22 70 <td tal:content="ticket/student/certcode">CERTCODE</td> 23 71 <td tal:content="ticket/level">LEVEL</td> 24 72 25 73 <td tal:condition="ticket/editable_by_lecturer" style="width: 65px;"> 26 74 <input type="text" name="scores:list" class="form-control" 27 75 tal:attributes="value ticket/score" /> 28 76 <input type="hidden" name="sids:list" 29 77 tal:attributes="value ticket/student/student_id" /> … … 31 79 <td tal:condition="not: ticket/editable_by_lecturer" 32 80 tal:content="ticket/score">SCORE</td> 33 </tr> 34 35 <tr> 36 <td i18n:translate=""> 37 Set scores from CSV file: 38 </td> 39 <td> 40 <div class="input-group half"> 41 <div class="input-group-btn"> 42 <div class="btn btn-default btn-file"> 43 Select… 44 <input type="file" name="uploadfile:file" /> 45 </div> 46 </div> 47 <input type="text" class="form-control" readonly /> 48 </div> 49 </td> 50 </tr> 51 81 </tr> 52 82 </tbody> 53 83 </table> 54 84 55 <input type="submit" name="UPDATE "56 value="Update scores " class="btn btn-primary"85 <input type="submit" name="UPDATE_TABLE" i18n:translate="" 86 value="Update scores from table" class="btn btn-primary" 57 87 /> 58 88 </form> -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r13935 r13936 4055 4055 self.login_as_lecturer() 4056 4056 self.browser.open(self.edit_scores_url) 4057 self.browser.getLink("Download editable tickets").click()4057 self.browser.getLink("Download csv file").click() 4058 4058 self.assertEqual(self.browser.headers['Status'], '200 Ok') 4059 4059 self.assertEqual(self.browser.headers['Content-Type'], … … 4072 4072 upload_file = StringIO(UPLOAD_CSV_TEMPLATE % '65') 4073 4073 upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv') 4074 self.browser.getControl("Update scores").click()4074 self.browser.getControl("Update editable scores from").click() 4075 4075 # value changed 4076 4076 self.assertEqual( … … 4120 4120 upload_ctrl = self.browser.getControl(name='uploadfile:file') 4121 4121 upload_ctrl.add_file(StringIO(content), mimetype, name) 4122 self.browser.getControl("Update scores").click()4122 self.browser.getControl("Update editable scores").click() 4123 4123 self.assertEqual( 4124 4124 self.student['studycourse']['100']['COURSE1'].score, 55) -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r13935 r13936 869 869 grok.require('waeup.editScores') 870 870 icon = 'actionicon_down.png' 871 text = _('Download editable tickets')871 text = _('Download csv file (editable scores only)') 872 872 target = 'download_scores' 873 873 grok.order(1)
Note: See TracChangeset for help on using the changeset viewer.