def displayWork(form): """ Provides the student-requested view of previously submitted work. """ tamarin.printHeader() try: # Validate that this person is really capable of seeing this stuff # (throws exception if not) tamarin.authenticate(form.getfirst('user'), form.getfirst('pass')) if 'submission' in form: #wants to see a specific submission print('<br>') core_view.displaySubmission(form.getfirst('submission')) else: #show them all their work #start form print('<form action="' + tamarin.CGI_URL + 'view.py" ' 'method="post">') print('<input type="hidden" name="user" value="' + form.getfirst('user') + '">') print('<input type="hidden" name="pass" value="' + form.getfirst('pass') + '">') print('<div class="logout">[Close your browser to logout]</div>') core_view.displayUser(form.getfirst('user'), brief=True) print('</form>') except tamarin.TamarinError as err: tamarin.printError(err) except: tamarin.printError('UNHANDLED_ERROR') finally: tamarin.printFooter()
def main(form=None): if not form: form = cgi.FieldStorage() try: if not form: tamarin.printHeader('Tamarin Masterview') displayForm() elif 'modify' in form: # modify a submission's grade if 'submission' not in form or 'grade' not in form: # may have a comment too, but that can be blank tamarin.printHeader('Masterview: Modify error') raise TamarinError('BAD_SUBMITTED_FORM') tamarin.printHeader("Masterview: Modified " + form.getfirst('submission')) modifySubmission(form.getfirst('submission'), form.getfirst('grade'), form.getfirst('verify'), form.getfirst('comment')) core_view.displaySubmission(form.getfirst('submission'), master=True) elif 'deleteComment' in form: # delete a comment from a submission if 'submission' not in form: tamarin.printHeader('Masterview: Delete comment error') raise TamarinError('BAD_SUBMITTED_FORM') tamarin.printHeader('Masterview: Deleted comment #' + form.getfirst('deleteComment')) deleteComment(form.getfirst('submission'), form.getfirst('deleteComment')) print('<br>') core_view.displaySubmission(form.getfirst('submission'), master=True) elif 'submission' in form: # view a single specific submission # (without modify or deleteComment, caught above) tamarin.printHeader('Masterview: ' + form.getfirst('submission')) print('<br>') core_view.modifySubmission(form.getfirst('submission')) elif 'user' in form: # view all of a user's submissions tamarin.printHeader('Masterview: ' + form.getfirst('user')) core_view.displayUser(form.getfirst('user'), assignment=form.getfirst('assignment'), brief=form.getfirst('brief'), master=True) elif 'assignment' in form: # without user given, or would have been caught above tamarin.printHeader('Masterview: ' + form.getfirst('assignment')) core_view.displayAssignment(form.getfirst('assignment'), form.getfirst('brief'), master=True) elif 'strip' in form: tamarin.printHeader('Masterview: Stripping ' + form.getfirst('strip')) stripFiles(form.getfirst('strip'), form.getfirst('only')) elif 'verifyAll' in form: tamarin.printHeader('Masterview: Verifying ' + form.getfirst('verifyAll')) markAllAsVerified(form.getfirst('verifyAll')) elif 'startGrader' in form: tamarin.printHeader('Masterview: Start grading pipeline') started = submit.startGradePipe(printStatus=False) if started: print('<p><br>Grading pipeline started.</p>') else: print('<p><br>Grader pipeline <b>not</b> started.') print('This is either because it is disabled or is already ' 'running.') print('<p>See <a href="' + tamarin.CGI_URL + 'status.py">status</a> ' + 'for more.</p>') elif 'gradesheet' in form: print("Content-Type: text/plain") print() displayGradeSheet(form.getfirst('comma')) else: tamarin.printHeader('Masterview: No valid option submitted') raise TamarinError('BAD_SUBMITTED_FORM') except TamarinError as err: tamarin.printError(err) except: tamarin.printError('UNHANDLED_ERROR') finally: if not (form and 'gradesheet' in form): tamarin.printFooter()