Beispiel #1
0
def build_feedback(partnum, total, mcq, coding, subscores):
    subscores = [x for x in subscores if 'Not Applicable' not in str(x)]
    comment = 'Part {}: '.format(partnum + 1) if partnum >= 0 else ''
    if mcq is None:
        comment += '{} points'.format(int(total))
    else:
        comment += '{}mcq+{}code'.format(Grade.drop_decimals(mcq),
                                         Grade.drop_decimals(coding))
    if sum(1 for x in subscores if x is not None) > 1:
        subs = (Grade.drop_decimals(x) if x is not None else '-'
                for x in subscores)
        comment += '; per-Q: ' + ':'.join(subs)
    return comment
Beispiel #2
0
def process_shuffle_assessment(submissions,
                               rubric_def,
                               rubric_grades,
                               submit_grades,
                               assessors,
                               submit_points,
                               course,
                               verbose=False):
    if verbose:
        print(len(submissions), 'total submissions retrieved')
    for sub in submissions:
        if sub['id'] not in assessors:
            continue
        pts = submit_points
        remarks = ''
        attachments = []
        if 'submission_comments' in sub:
            for com in sub['submission_comments']:
                if 'attachments' in com and com['attachments'] and com[
                        'author']['display_name'] not in COURSE_STAFF:
                    for a in com['attachments']:
                        ctype = 'unknown'
                        if 'content-type' in a:
                            ctype = a['content-type']
                        attachments += (a['filename'], ctype, a['mime_class'],
                                        a['url'])
        if verbose:
            print('Attachments:', attachments)
        uid = sub['user_id']
        reviewer, _, criteria = assessors[sub['id']]
        crit_points = {}
        for crit in criteria:
            if 'points' not in crit or 'criterion_id' not in crit or crit[
                    'points'] < 0.0:
                continue  # N/A or non-scored criterion
            points = crit['points']
            c_id = crit['criterion_id']
            name = rubric_def.get_name(c_id)
            if not name:
                continue
            if name[0] == 'Q' and name[2] == ':':
                name = name[4:]
            if 'Suggestions' in name:
                if len(crit['comments']) < 8:
                    pts = pts - (0.05 * submit_points)
                    remarks += 'Did not provide suggested improvements (-{})\n'.format(
                        Grade.drop_decimals(0.05 * submit_points))
                continue
            if 'Location' in name:
                if len(crit['comments']) < 8:
                    pts = pts - (0.05 * submit_points)
                    remarks += 'Did not specify location/time (-{})\n'.format(
                        Grade.drop_decimals(0.05 * submit_points))
                continue
            if name in crit_points:
                crit_points[name] = crit_points[name] + [points]
            else:
                crit_points[name] = [points]
        total_points = 0
        possible = 0
        if verbose:
            print('crit_points:', crit_points)
        for itemname, pointlist in crit_points.items():
            total_points += mean(pointlist)
            possible += 3
        if total_points == 0:
            print('!  {} ({}) received a zero score'.format(
                course.student_login(uid), uid))
        if possible > 0:
            grade = 12.0 * (total_points / possible)
            rubric_grades[uid] = 12.0 * (total_points / possible)
        else:
            grade = None
            print('empty rubric for {} ({})'.format(course.student_login(uid),
                                                    uid))
        if reviewer is not None:
            if attachments == []:  ##FIXME
                pts = pts - (0.30 * submit_points)
                remarks += 'Did not upload photo (-{})'.format(
                    Grade.drop_decimals(0.30 * submit_points))
            submit_grades[reviewer] = Grade(pts, remarks)
            if verbose or True:  ##DEBUG
                print(' ', course.student_login(reviewer), 'entered', grade,
                      'for', course.student_login(uid))
    return