Ignore:
Timestamp:
14 Jun 2016, 08:53:30 (8 years ago)
Author:
Henrik Bettermann
Message:

Divide editscorespage.pt into two parts, one for file upload and one for table form.

Add Help modal.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/fileupload.pt

    r12447 r13936  
    2121                <div class="input-group" tal:condition="not: viewlet/file_exists">
    2222                        <div class="input-group-btn">
    23                                 <div class="btn btn-default btn-file">
     23                                <div class="btn btn-default btn-file" i18n:translate="">
    2424          Select new file&hellip;
    2525          <input type="file" tal:attributes="name viewlet/input_name" />
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r13935 r13936  
    30873087    grok.template('editscorespage')
    30883088    pnav = 1
     3089    doclink = DOCLINK + '/students/browser.html#batch-editing-scores-by-lecturers'
    30893090
    30903091    def label(self):
     
    31393140            self.redirect(self.url(self.context))
    31403141            return
    3141         if not 'UPDATE' in form:
     3142        if not 'UPDATE_TABLE' in form and not 'UPDATE_FILE' in form:
    31423143            return
    31433144        error = ''
    31443145        if not editable_tickets:
    31453146            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:
    31513157                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']))
    31543162        for ticket in editable_tickets:
    31553163            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
    110<form  i18n:domain="waeup.kofa"  method="POST" enctype="multipart/form-data">
    211  <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&hellip;
     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">&times;</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 />
    351
    452  <table class="kofa-data-table dataTable">
    553    <thead>
    6         <tr>
     54    <tr>
    755      <th i18n:translate="">Matric No.</th>
    856      <th i18n:translate="">Student Id</th>
     
    1260      <th i18n:translate="">Level</th>
    1361      <th i18n:translate="">Score</th>
    14         </tr>
     62    </tr>
    1563    </thead>
    1664    <tbody>
     
    1866      <td tal:content="ticket/student/matric_number">MATRIC_NUMBER</td>
    1967      <td tal:content="ticket/student/student_id">STUDENT ID</td>
    20           <td tal:content="ticket/student/display_fullname">FULLNAME</td>
     68      <td tal:content="ticket/student/display_fullname">FULLNAME</td>
    2169      <td tal:content="ticket/student/translated_state">STATE</td>
    2270      <td tal:content="ticket/student/certcode">CERTCODE</td>
    2371      <td tal:content="ticket/level">LEVEL</td>
    2472
    25           <td tal:condition="ticket/editable_by_lecturer" style="width: 65px;">
     73      <td tal:condition="ticket/editable_by_lecturer" style="width: 65px;">
    2674          <input type="text" name="scores:list" class="form-control"
    27                      tal:attributes="value ticket/score" />
     75                 tal:attributes="value ticket/score" />
    2876          <input type="hidden" name="sids:list"
    2977                 tal:attributes="value ticket/student/student_id" />
     
    3179      <td tal:condition="not: ticket/editable_by_lecturer"
    3280          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&hellip;
    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>
    5282    </tbody>
    5383  </table>
    5484
    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"
    5787         />
    5888</form>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r13935 r13936  
    40554055        self.login_as_lecturer()
    40564056        self.browser.open(self.edit_scores_url)
    4057         self.browser.getLink("Download editable tickets").click()
     4057        self.browser.getLink("Download csv file").click()
    40584058        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    40594059        self.assertEqual(self.browser.headers['Content-Type'],
     
    40724072        upload_file = StringIO(UPLOAD_CSV_TEMPLATE % '65')
    40734073        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()
    40754075        # value changed
    40764076        self.assertEqual(
     
    41204120            upload_ctrl = self.browser.getControl(name='uploadfile:file')
    41214121            upload_ctrl.add_file(StringIO(content), mimetype, name)
    4122             self.browser.getControl("Update scores").click()
     4122            self.browser.getControl("Update editable scores").click()
    41234123            self.assertEqual(
    41244124                self.student['studycourse']['100']['COURSE1'].score, 55)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r13935 r13936  
    869869    grok.require('waeup.editScores')
    870870    icon = 'actionicon_down.png'
    871     text = _('Download editable tickets')
     871    text = _('Download csv file (editable scores only)')
    872872    target = 'download_scores'
    873873    grok.order(1)
Note: See TracChangeset for help on using the changeset viewer.