示例#1
0
def submission_upload_info(courseId, user, assignment):
    """Return a string explaining the submission upload time, deadline
    and the late submission penalty
    """
    vmcfg = CourseConfig(CourseList().course_config(courseId))
    vmpaths = paths.VmcheckerPaths(vmcfg.root_path())
    sbroot = vmpaths.dir_cur_submission_root(assignment, user)
    grade_file = paths.submission_results_grade(sbroot)
    sbcfg = paths.submission_config_file(sbroot)
    if not os.path.exists(sbcfg):
        return "Tema nu a fost încă trimisă"

    late_penalty = update_db.compute_late_penalty(assignment, user, vmcfg)
    ta_penalty = update_db.compute_TA_penalty(grade_file)
    deadline_str = vmcfg.assignments().get(assignment, 'Deadline')
    total_points = int(vmcfg.assignments().get(assignment, 'TotalPoints'))
    deadline_struct = time.strptime(
        vmcfg.assignments().get(assignment, 'Deadline'), penalty.DATE_FORMAT)
    sss = submissions.Submissions(vmpaths)
    upload_time_str = sss.get_upload_time_str(assignment, user)
    upload_time_struct = sss.get_upload_time_struct(assignment, user)

    # XXX hack, we should move this
    language = 'ro'
    deadline_explanation = penalty.verbose_time_difference(
        upload_time_struct, deadline_struct, language)

    ret = ""

    if language is 'ro':
        ret += "Data trimiterii temei : " + upload_time_str + "\n"
        ret += "Deadline temă         : " + deadline_str + "\n"
        ret += deadline_explanation + "\n"
        ret += "\n"
        ret += "Depunctare întârziere : " + str(late_penalty) + "\n"
        ret += "Depunctare corectare  : " + str(ta_penalty) + "\n"
        ret += "Total depunctări      : " + str(ta_penalty +
                                                late_penalty) + "\n"
        ret += "-----------------------\n"
        ret += "Nota                  : " + str(total_points + ta_penalty +
                                                late_penalty) + "\n"
    else:
        # another language
        ret += "Submision date           : " + upload_time_str + "\n"
        ret += "Assignment deadline      : " + deadline_str + "\n"
        ret += deadline_explanation + "\n"
        ret += "\n"
        ret += "Penalty (late submission): " + str(late_penalty) + "\n"
        ret += "Penalty (grading)        : " + str(ta_penalty) + "\n"
        ret += "Penalty (total)          : " + str(ta_penalty +
                                                   late_penalty) + "\n"
        ret += "---------------------------\n"
        ret += "Grade                    : " + str(total_points + ta_penalty +
                                                   late_penalty) + "\n"

    ret += "\n"

    return ret
示例#2
0
def submission_upload_info(courseId, user, assignment):
    """Return a string explaining the submission upload time, deadline
    and the late submission penalty
    """
    vmcfg = CourseConfig(CourseList().course_config(courseId))
    vmpaths = paths.VmcheckerPaths(vmcfg.root_path())
    sbroot = vmpaths.dir_cur_submission_root(assignment, user)
    grade_file = paths.submission_results_grade(sbroot)
    sbcfg = paths.submission_config_file(sbroot)
    if not os.path.exists(sbcfg):
        return "Tema nu a fost încă trimisă"

    late_penalty = update_db.compute_late_penalty(assignment, user, vmcfg)
    ta_penalty   = update_db.compute_TA_penalty(grade_file)
    deadline_str = vmcfg.assignments().get(assignment, 'Deadline')
    total_points = int(vmcfg.assignments().get(assignment, 'TotalPoints'))
    deadline_struct = time.strptime(vmcfg.assignments().get(assignment, 'Deadline'),
                                    penalty.DATE_FORMAT)
    sss = submissions.Submissions(vmpaths)
    upload_time_str = sss.get_upload_time_str(assignment, user)
    upload_time_struct = sss.get_upload_time_struct(assignment, user)

    # XXX hack, we should move this
    language = 'ro'
    deadline_explanation = penalty.verbose_time_difference(upload_time_struct, deadline_struct, language)

    ret = ""

    if language is 'ro':
        ret += "Data trimiterii temei : " + upload_time_str + "\n"
        ret += "Deadline temă         : " + deadline_str    + "\n"
        ret += deadline_explanation + "\n"
        ret += "\n"
        ret += "Depunctare întârziere : " + str(late_penalty) + "\n"
        ret += "Depunctare corectare  : " + str(ta_penalty)   + "\n"
        ret += "Total depunctări      : " + str(ta_penalty + late_penalty) + "\n"
        ret += "-----------------------\n"
        ret += "Nota                  : " + str(total_points + ta_penalty + late_penalty) + "\n"
    else:
        # another language
        ret += "Submision date           : " + upload_time_str + "\n"
        ret += "Assignment deadline      : " + deadline_str    + "\n"
        ret += deadline_explanation + "\n"
        ret += "\n"
        ret += "Penalty (late submission): " + str(late_penalty) + "\n"
        ret += "Penalty (grading)        : " + str(ta_penalty)   + "\n"
        ret += "Penalty (total)          : " + str(ta_penalty + late_penalty) + "\n"
        ret += "---------------------------\n"
        ret += "Grade                    : " + str(total_points + ta_penalty + late_penalty) + "\n"

    ret += "\n"

    return ret
示例#3
0
def submission_upload_info(vmcfg, courseId, assignment, account, isTeamAccount, isGraded):
    """Return a string explaining the submission upload time, deadline
    and the late submission penalty
    """

    vmpaths = paths.VmcheckerPaths(vmcfg.root_path())
    sbroot = vmpaths.dir_cur_submission_root(assignment, account)
    grade_file = paths.submission_results_grade(sbroot)
    sbcfg = paths.submission_config_file(sbroot)
    if not os.path.exists(sbcfg):
        return _("No submission exists for this assignment")

    late_penalty = update_db.compute_late_penalty(assignment, account, vmcfg)
    ta_penalty   = update_db.compute_TA_penalty(grade_file)
    deadline_str = vmcfg.assignments().get(assignment, 'Deadline')
    total_points = int(vmcfg.assignments().get(assignment, 'TotalPoints'))
    deadline_struct = time.strptime(vmcfg.assignments().get(assignment, 'Deadline'),
                                    penalty.DATE_FORMAT)
    sss = submissions.Submissions(vmpaths)
    upload_time_str = sss.get_upload_time_str(assignment, account)
    upload_time_struct = sss.get_upload_time_struct(assignment, account)

    deadline_explanation = penalty.verbose_time_difference(upload_time_struct, deadline_struct)

    submitter_explanation = None
    if isTeamAccount:
        submitting_user = sss.get_submitting_user(assignment, account)
        if submitting_user is not None:
            submitter_explanation = _("Submitted by") + ": " + submitting_user

    max_line_width = 0
    rows_to_print = []

    if submitter_explanation is not None:
        rows_to_print += [
            [ submitter_explanation ],
            [ '' ]
        ]

    rows_to_print += [
        [ _("Submission date"), upload_time_str ],
        [ _("Assignment deadline"), deadline_str ],
        [ deadline_explanation ]
    ]

    if isGraded or not vmcfg.assignments().is_deadline_hard(assignment):
        rows_to_print += [
            [ '' ]
        ]

    if not vmcfg.assignments().is_deadline_hard(assignment):
        rows_to_print += [
            [ _("Penalty (late submission)"), str(late_penalty) ],
        ]

    if isGraded:
        rows_to_print += [
            [ _("Penalty (grading)"), str(ta_penalty) ],
            [ _("Penalty (total)"), str(ta_penalty + late_penalty) ],
            [ '' ],
            [ _("Grade"), str(total_points + ta_penalty + late_penalty) ]
        ]

    for row in rows_to_print:
        row[0] = row[0].decode("utf-8")
        if len(row) == 2 and len(row[0]) > max_line_width:
            max_line_width = len(row[0])

    if isGraded:
        # Put a dashed line just above the 'Grade' line
        rows_to_print[len(rows_to_print) - 2][0] = '-' * max_line_width

    ret = u""
    for row in rows_to_print:
        if len(row) == 1:
            ret += row[0] + "\n"
        elif len(row) == 2:
            ret += unicode("{0[0]:<" + str(max_line_width) + "} : {0[1]}\n").format(row)

    ret += "\n"

    return ret
示例#4
0
def submission_upload_info(vmcfg, courseId, assignment, account, isTeamAccount,
                           isGraded):
    """Return a string explaining the submission upload time, deadline
    and the late submission penalty
    """

    vmpaths = paths.VmcheckerPaths(vmcfg.root_path())
    sbroot = vmpaths.dir_cur_submission_root(assignment, account)
    grade_file = paths.submission_results_grade(sbroot)
    sbcfg = paths.submission_config_file(sbroot)
    if not os.path.exists(sbcfg):
        return _("No submission exists for this assignment")

    late_penalty = update_db.compute_late_penalty(assignment, account, vmcfg)
    ta_penalty = update_db.compute_TA_penalty(grade_file)
    deadline_str = vmcfg.assignments().get(assignment, 'Deadline')
    total_points = int(vmcfg.assignments().get(assignment, 'TotalPoints'))
    deadline_struct = time.strptime(
        vmcfg.assignments().get(assignment, 'Deadline'), penalty.DATE_FORMAT)
    sss = submissions.Submissions(vmpaths)
    upload_time_str = sss.get_upload_time_str(assignment, account)
    upload_time_struct = sss.get_upload_time_struct(assignment, account)

    deadline_explanation = penalty.verbose_time_difference(
        upload_time_struct, deadline_struct)

    submitter_explanation = None
    if isTeamAccount:
        submitting_user = sss.get_submitting_user(assignment, account)
        if submitting_user is not None:
            submitter_explanation = _("Submitted by") + ": " + submitting_user

    max_line_width = 0
    rows_to_print = []

    if submitter_explanation is not None:
        rows_to_print += [[submitter_explanation], ['']]

    rows_to_print += [[_("Submission date"), upload_time_str],
                      [_("Assignment deadline"), deadline_str],
                      [deadline_explanation]]

    if isGraded or not vmcfg.assignments().is_deadline_hard(assignment):
        rows_to_print += [['']]

    if not vmcfg.assignments().is_deadline_hard(assignment):
        rows_to_print += [
            [_("Penalty (late submission)"),
             str(late_penalty)],
        ]

    if isGraded:
        rows_to_print += [
            [_("Penalty (grading)"), str(ta_penalty)],
            [_("Penalty (total)"),
             str(ta_penalty + late_penalty)], [''],
            [_("Grade"),
             str(total_points + ta_penalty + late_penalty)]
        ]

    for row in rows_to_print:
        row[0] = row[0].decode("utf-8")
        if len(row) == 2 and len(row[0]) > max_line_width:
            max_line_width = len(row[0])

    if isGraded:
        # Put a dashed line just above the 'Grade' line
        rows_to_print[len(rows_to_print) - 2][0] = '-' * max_line_width

    ret = u""
    for row in rows_to_print:
        if len(row) == 1:
            ret += row[0] + "\n"
        elif len(row) == 2:
            ret += unicode("{0[0]:<" + str(max_line_width) +
                           "} : {0[1]}\n").format(row)

    ret += "\n"

    return ret