예제 #1
0
def displayUser(user, assignment=None, brief=True, master=False):
    """
    Displays the work of the given user.  
    
    If the name of the assignment is specified, it displays only that 
    assignment. Otherwise, displays an assignmentSubmissions view for every 
    assignment for this user. In other words, shows all the work this user 
    has submitted (or not).
    
    A brief assignmentSubmissions view is on by default for this function.
    
    """
    #get assignment list
    if assignment:
        assignment = Assignment(assignment)
        assignments = [assignment.name]
    else:
        assignments = tamarin.getAssignments()
    
    #print user table
    details = tamarin.getUserDetails(user)
    print('<div class="user">')
    print('<table class="user"><tr>')
    print('<td class="user"><b>' + user.lower() + '</b>')
    print('&nbsp; <small>(' + str(details[2]) + ' ' + str(details[1]) + 
          ')</small></td>')
    print('<td class="section">Section: ' + str(details[0]) + '</td>')
    print('</tr></table>')
      
    for assign in assignments:
        displayAssignmentSubmissions(user, assign, brief, master)      
    print('</div>')
예제 #2
0
def displayGradeSheet(comma=False):
    """
    Produces a grade sheet view for all users and assignments.
    
    Rows correspond to users, sorted by username.  Rows contain the Tamarin 
    adjusted scores for each assignment followed by the total adjusted score. 
    
    By default, uses tabs as delimiters, with the user column padded to 14 
    characters to maintain a readable format even when faced with slightly 
    longer usernames.  If comma is True, just uses commas and no padding. 

    Unverified grades (and any totals depending on them) are marked
    with an appended ?. 
    
    Missing/unsubmitted grades are left blank.  Submitted but ungraded
    submissions are ignored (so blank if no other submissions for that 
    assignment).
    
    The total score is the sum of all numeric values, ignoring any 
    OK, X, or ERR grades.  If there are no numeric values, the total
    is ERR, X, or OK (in that order) if such a value is a component grade.
    Otherwise, the total is blank.  If at least one score is 
    tentative (unverified), the total is also tentative.

    """
    users = tamarin.getUsers()
    delim = ',' if comma else '\t'
    
    # build data structure 
    sheet = dict()
    for user in users:
        sheet[user] = {}  # scores keyed by assignment name
    
    # now process each assignment
    assignments = tamarin.getAssignments()  # already sorted
    for assign in assignments:
        subs = tamarin.getSubmissions(assignment=assign, submitted=False)
        # overwrite until last sub for each user, keyed by lower username
        submissions = {}
        for sub in subs:
            sub = os.path.basename(sub)
            usr = re.match(r"(\w+)" + assign, sub).group(1).lower()
            submissions[usr] = sub
        
        for user in users:
            if user in submissions:
                sub = GradedFile(submissions[user])
                grd = sub.getAdjustedGrade()

                # add to total grade list: (grade, verified?)
                if 'Total' not in sheet[user]:
                    sheet[user]['Total'] = [grd, True]
                elif isinstance(grd, float) or isinstance(grd, int):
                    # grd is a number, so overwrite/adds to whatever is there
                    if isinstance(sheet[user]['Total'][0], str):
                        sheet[user]['Total'][0] = grd
                    else:
                        sheet[user]['Total'][0] += grd
                else:
                    # grd is a string, so maybe replace any str or else ignore
                    if isinstance(sheet[user]['Total'][0], str):
                        if sheet[user]['Total'][0] == 'OK':
                            sheet[user]['Total'][0] = grd
                        elif sheet[user]['Total'][0] == 'X' and grd != 'OK':
                            sheet[user]['Total'][0] = grd
                        else:
                            pass  # grade is already ERR
                    else:
                        pass  # grade is a number, so ignore this string grd

                grd = str(grd)
                if not sub.humanVerified:
                    grd += '?'
                    sheet[user]['Total'][1] = False
                sheet[user][assign] = grd 
            else:
                sheet[user][assign] = ''  # blank
            
    # print details    
    # header
    print(',' if comma else '{:14}\t'.format(' '), end='')
    for assign in assignments:
        print(assign + delim, end='')
    print('Total')

    for user in users:
        print(user + ',' if comma else '{:14}\t'.format(user), end='')
        for assign in assignments:
            print(sheet[user][assign] + delim, end='')
        # print final total
        if 'Total' in sheet[user]:
            if isinstance(sheet[user]['Total'][0], float):
                sheet[user]['Total'][0] = round(sheet[user]['Total'][0], 
                                                tamarin.GRADE_PRECISION)
            print(sheet[user]['Total'][0], end='')
            if not sheet[user]['Total'][1]:
                print('?', end='')
        print('')
예제 #3
0
def displayForm():
    """
    Displays the initial/default masterview form.  Does not include header
    or footers.
    """
    #get sorted user and assignment lists
    users = tamarin.getUsers()
    assignments = tamarin.getAssignments()
        
    print("""<h2>Masterview</h2>  
<div class="masterview">
<h3>Views</h3>
    """)
    print('<form action="' + tamarin.CGI_URL + 'masterview.py" method="get">')
    print('Assignment: <select name="assignment">')
    for a in assignments:
        print('<option>' + a + '</option>')
    print('</select>')
  
    print("""
<select name="brief">
<option value="1" selected>Brief</option>
<option value="">Full</option>
</select>
<input type="submit" value="View">
</form>
    """)
    print('<form action="' + tamarin.CGI_URL + 'masterview.py" method="get">')
    print('User: <select name="user"><option></option>')
    for u in users:
        print('<option>' + u + '</option>')
    print('</select>')
  
    print('<select name="assignment">')
    print('<option value="">(All assignments)</option>')
    for a in assignments:
        print('<option>' + a + '</option>')
    print('</select>')
    print("""
<select name="brief">
<option value="1" selected>Brief</option>
<option value="">Full</option>
</select>
<input type="submit" value="View">
</form>

<h4>Grade sheet view</h4>
    """)
    print('<form action="' + tamarin.CGI_URL + 'masterview.py" method="get">')
    print("""
<p>
Produces a tab-separated plain-text view of adjusted Tamarin scores for all 
users across all assignments.  This can easily be copy-and-pasted into a 
spreadsheet program.  
<p>
<input type="hidden" name="gradesheet" value="1">
<input type="checkbox" name="comma"> 
Use commas instead of tabs and suppress username-column padding.
<p>
<input type="submit" value="Generate"
title="You may need to paste into a text editor first and then copy again 
from there before your spreadsheet will accept it correctly.">
</p>
</form>
</div>

<div class="masterview">
<h3>Tools</h3>
<h4>Mark as human-verified</h4>
    """)
    print('<form action="' + tamarin.CGI_URL + 'masterview.py" method="get">')
    print('<p>Mark all graded files in:')
    print('<select name="verifyAll"><option></option>')
    for a in assignments:
        print('<option>' + a + '</option>')
    print('</select>')
  
    print('<input type="submit" value="Verify"></p>')
    print('</form>')

    print('<h4>Start grader</h4>')
    print('<form action="' + tamarin.CGI_URL + 'masterview.py"', end=' ')
    print('method="post" enctype="multipart/form-data">')
    print("""<p>
If the pipeline is OFF but submissions are still sitting in the grading queue, 
as shown by 
    """)
    print('<a href="' + tamarin.CGI_URL + 'status.py">status</a>,')
    print("""you can:
<input type="hidden" name="startGrader" value="1">
<p>
<input type="submit" value="Start Grader">
</p>
</form>
    """)

    print('<h4>Strip timestamps from filenames</h4>')
    print('<form action="' + tamarin.CGI_URL + 'masterview.py" method="get">')
    print('<p>From assignment/directory: ')
    print('<select name="strip"><option>submitted</option>')
    for a in assignments:
        print('<option>' + a + '</option>')
    print('</select>')
    print('&nbsp; (copying into ' + tamarin.STRIPPED_ROOT + ')')
    print('<p>Strip only files with names containing (blank for all):')
    print('<input type="text" name="only">')
    print('<p><input type="submit" value="Strip"></p>')
    print('</form>')
    print('</div>')