Ejemplo n.º 1
0
def remark_exam(exam, student):
    """Re-mark the exam using the latest marking. """
    qtemplates = Exams.get_qts(exam)
    examtotal = 0.0
    end = Exams.get_mark_time(exam, student)
    for qtemplate in qtemplates:
        question = DB.get_exam_q_by_qt_student(exam, qtemplate, student)
        answers = DB.get_q_guesses_before_time(question, end)
        try:
            marks = mark_q(question, answers)
        except OaMarkerError:
            L.warn("Marker Error, question %d while re-marking exam %s for student %s!" % (question, exam, student))
            marks = {}
        parts = [int(var[1:]) for var in marks.keys() if re.search("^A([0-9]+)$", var) > 0]
        parts.sort()
        total = 0.0
        for part in parts:
            if marks['C%d' % part] == 'Correct':
                marks['C%d' % part] = "<b><font color='darkgreen'>Correct</font></b>"
            try:
                mark = float(marks['M%d' % part])
            except (ValueError, TypeError, KeyError):
                mark = 0
            total += mark
        DB.update_q_score(question, total)
        #        OaDB.setQuestionStatus(question, 3)    # 3 = marked
        examtotal += total
    Exams.save_score(exam, student, examtotal)
    return examtotal
Ejemplo n.º 2
0
def remark_exam(exam, student):
    """Re-mark the exam using the latest marking. """
    qtemplates = Exams.get_qts(exam)
    examtotal = 0.0
    end = Exams.get_mark_time(exam, student)
    for qtemplate in qtemplates:
        question = DB.get_exam_q_by_qt_student(exam, qtemplate, student)
        answers = DB.get_q_guesses_before_time(question, end)
        try:
            marks = mark_q(question, answers)
        except OaMarkerError:
            L.warn(
                "Marker Error, question %d while re-marking exam %s for student %s!"
                % (question, exam, student))
            marks = {}
        parts = [
            int(var[1:]) for var in marks.keys()
            if re.search("^A([0-9]+)$", var) > 0
        ]
        parts.sort()
        total = 0.0
        for part in parts:
            if marks['C%d' % part] == 'Correct':
                marks['C%d' %
                      part] = "<b><font color='darkgreen'>Correct</font></b>"
            try:
                mark = float(marks['M%d' % part])
            except (ValueError, TypeError, KeyError):
                mark = 0
            total += mark
        DB.update_q_score(question, total)
        #        OaDB.setQuestionStatus(question, 3)    # 3 = marked
        examtotal += total
    Exams.save_score(exam, student, examtotal)
    return examtotal
Ejemplo n.º 3
0
def mark_exam(user_id, exam_id):
    """ Submit the assessment and mark it.
        Returns True if it went well, or False if a problem.
    """
    numquestions = Exams.get_num_questions(exam_id)
    status = Exams.get_user_status(user_id, exam_id)
    L.info("Marking assessment %s for %s, status is %s" %
           (exam_id, user_id, status))
    examtotal = 0.0
    errors = 0
    for position in range(1, numquestions + 1):
        q_id = General.get_exam_q(exam_id, position, user_id)
        if not q_id:
            L.critical(
                "Unable to retrieve exam question page %s, exam %s, for user %s"
                % (position, exam_id, user_id))
            errors += 1
            continue
        answers = DB.get_q_guesses(q_id)
        # There's a small chance they got here without ever seeing a question,
        # make sure it exists.
        DB.add_exam_q(user_id, exam_id, q_id, position)

        # First, mark the question
        try:
            marks = General.mark_q(q_id, answers)
            DB.set_q_status(q_id, 3)  # 3 = marked
            DB.set_q_marktime(q_id)
        except OaMarkerError:
            L.warn("Marker Error in question %s, exam %s, student %s!" %
                   (q_id, exam_id, user_id))
            return False
        parts = [
            int(var[1:]) for var in marks.keys()
            if re.search("^A([0-9]+)$", var) > 0
        ]
        parts.sort()

        # Then calculate the mark
        total = 0.0
        for part in parts:
            try:
                mark = float(marks['M%d' % (part, )])
            except (KeyError, ValueError):
                mark = 0
            total += mark
            DB.update_q_score(q_id, total)
        examtotal += total
    if not errors:
        Exams.set_user_status(user_id, exam_id, 5)
        Exams.set_submit_time(user_id, exam_id)
        Exams.save_score(exam_id, user_id, examtotal)
        Exams.touchuserexam(exam_id, user_id)

    if errors:
        return False
    L.info("user %s scored %s total on exam %s" %
           (user_id, examtotal, exam_id))
    return True
Ejemplo n.º 4
0
def mark_exam(user_id, exam_id):
    """ Submit the assessment and mark it.
        Returns True if it went well, or False if a problem.
    """
    numquestions = Exams.get_num_questions(exam_id)
    status = Exams.get_user_status(user_id, exam_id)
    L.info("Marking assessment %s for %s, status is %s" % (exam_id, user_id, status))
    examtotal = 0.0
    errors = 0
    for position in range(1, numquestions + 1):
        q_id = General.get_exam_q(exam_id, position, user_id)
        if not q_id:
            L.critical("Unable to retrieve exam question page %s, exam %s, for user %s" % (position, exam_id, user_id
                                                                                           )
                       )
            errors += 1
            continue
        answers = DB.get_q_guesses(q_id)
        # There's a small chance they got here without ever seeing a question,
        # make sure it exists.
        DB.add_exam_q(user_id, exam_id, q_id, position)

        # First, mark the question
        try:
            marks = General.mark_q(q_id, answers)
            DB.set_q_status(q_id, 3)    # 3 = marked
            DB.set_q_marktime(q_id)
        except OaMarkerError:
            L.warn("Marker Error in question %s, exam %s, student %s!" %
                   (q_id, exam_id, user_id))
            return False
        parts = [int(var[1:])
                 for var in marks.keys()
                 if re.search("^A([0-9]+)$", var) > 0]
        parts.sort()

        # Then calculate the mark
        total = 0.0
        for part in parts:
            try:
                mark = float(marks['M%d' % (part,)])
            except (KeyError, ValueError):
                mark = 0
            total += mark
            DB.update_q_score(q_id, total)
        examtotal += total
    if not errors:
        Exams.set_user_status(user_id, exam_id, 5)
        Exams.set_submit_time(user_id, exam_id)
        Exams.save_score(exam_id, user_id, examtotal)
        Exams.touchuserexam(exam_id, user_id)

    if errors:
        return False
    L.info("user %s scored %s total on exam %s" %
           (user_id, examtotal, exam_id))
    return True
Ejemplo n.º 5
0
def remark_prac(question):
    """ Re-mark the practice question and store the score back
        in the questions table.
    """
    answers = DB.get_q_guesses(question)
    try:
        marks = mark_q(question, answers)
    except OaMarkerError:
        return None
    parts = [int(var[1:])
             for var in marks.keys()
             if re.search("^A([0-9]+)$", var) > 0]
    parts.sort()
    total = 0.0
    for part in parts:
        try:
            mark = float(marks['M%d' % part])
        except (ValueError, TypeError, KeyError):
            mark = 0
        total += mark
    DB.update_q_score(question, total)
    DB.set_q_status(question, 3)    # 3 = marked
    return total
Ejemplo n.º 6
0
def remark_prac(question):
    """ Re-mark the practice question and store the score back
        in the questions table.
    """
    answers = DB.get_q_guesses(question)
    try:
        marks = mark_q(question, answers)
    except OaMarkerError:
        return None
    parts = [
        int(var[1:]) for var in marks.keys()
        if re.search("^A([0-9]+)$", var) > 0
    ]
    parts.sort()
    total = 0.0
    for part in parts:
        try:
            mark = float(marks['M%d' % part])
        except (ValueError, TypeError, KeyError):
            mark = 0
        total += mark
    DB.update_q_score(question, total)
    DB.set_q_status(question, 3)  # 3 = marked
    return total