Ejemplo n.º 1
0
def get_q_list(tid, uid=None, numdone=True):
    """ Return a list of dicts with question template information for the topic.
        [{ qtid: int      QTemplate ID
          name: string   Name of Question
          position: int  Position of Question in topic
          done:  Number of times the given user has submitted a question
                 for practice
        },]
    """
    qlist = []
    qtemplates = Topics.get_qts(int(tid))
    for qtid in qtemplates:
        if uid and numdone:
            num = DB.get_student_q_practice_num(uid, qtid)
        else:
            num = 0
        qlist.append({
            'qtid': qtid,
            'name': qtemplates[qtid]['name'],
            'position': qtemplates[qtid]['position'],
            'done': num
        })
        # Sort them by position
    qlist.sort(lambda f, s: cmp(f["position"], s["position"]))
    return qlist
Ejemplo n.º 2
0
def get_q_list(tid, uid=None, numdone=True):
    """ Return a list of dicts with question template information for the topic.
        [{ qtid: int      QTemplate ID
          name: string   Name of Question
          position: int  Position of Question in topic
          done:  Number of times the given user has submitted a question
                 for practice
        },]
    """
    qlist = []
    qtemplates = Topics.get_qts(int(tid))
    for qtid in qtemplates:
        if uid and numdone:
            num = DB.get_student_q_practice_num(uid, qtid)
        else:
            num = 0
        qlist.append({'qtid': qtid,
                      'name': qtemplates[qtid]['name'],
                      'position': qtemplates[qtid]['position'],
                      'done': num})
        # Sort them by position
    qlist.sort(lambda f, s: cmp(f["position"], s["position"]))
    return qlist