Ejemplo n.º 1
0
def gen_exam_q(exam, position, student):
    """ Generate an exam question instance for the given student and exam.
        If there are multiple qtemplates listed in a given position, one will
        be chosen at random.
    """
    qtemplates = DB.get_exam_qts_in_pos(exam, position)
    if not qtemplates:
        L.warn("DB.get_exam_qts_in_pos(%s,%s) returned a non list." %
            (exam, position))
        return False
    if len(qtemplates) < 1:
        L.warn("DB.get_exam_qts_in_pos(%s,%s) returned an empty list." %
            (exam, position))
        return False
    whichqtemplate = random.randint(1, len(qtemplates))
    qtid = qtemplates[whichqtemplate - 1]   # lists count from 0
    return gen_q(qtid, student, exam, position)
Ejemplo n.º 2
0
def gen_exam_q(exam, position, student):
    """ Generate an exam question instance for the given student and exam.
        If there are multiple qtemplates listed in a given position, one will
        be chosen at random.
    """
    qtemplates = DB.get_exam_qts_in_pos(exam, position)
    if not qtemplates:
        L.warn("DB.get_exam_qts_in_pos(%s,%s) returned a non list." %
               (exam, position))
        return False
    if len(qtemplates) < 1:
        L.warn("DB.get_exam_qts_in_pos(%s,%s) returned an empty list." %
               (exam, position))
        return False
    whichqtemplate = random.randint(1, len(qtemplates))
    qtid = qtemplates[whichqtemplate - 1]  # lists count from 0
    return gen_q(qtid, student, exam, position)