Esempio n. 1
0
def makeSession(sname, qid):
    """makes a table called sname+RESPONSES.Tables have a username
    column, a column corresponding to a question to record a grade
    and and columns to record responses.
    quiz id: Q+<integer>
    quiz question: Qqq <-- concatenate digit
    quiz choice Qqq "choice" IDC <-- concatenate choice id
    """
    if isInTable("sessions", "name", sname):
        return False

    # I'm not sure why these lines aren't already applied,
    # but they're added here to speed things up
    gdbk.query("PRAGMA journal_mode=off")
    gdbk.query("PRAGMA synchronous=off")
    #
    qblocks = questions.getQblocks(qid)
    qlist = map(cq.clkrQuestion, qblocks)
    sqlstring = "CREATE TABLE {0}(username TEXT)".format(sname)
    gdbk.query(sqlstring)

    qcounter = 0
    for clq in qlist:
        basename = "Q" + str(qcounter)
        totcol = basename + "total"
        addFloatCol(sname, basename)  # new check if works
        addFloatCol(sname, totcol)
        cd = clq.getChoiceDict()
        for i in cd:
            colname = basename + i
            addIntCol(sname, colname)
        qcounter += 1

    qstr = questions.getQuizQuestions(qid)
    gdbk.insert("sessions", name=sname, quiz=qid, questions=qstr)
Esempio n. 2
0
 def GET(self):
     validateInstructor()
     username = getUsername()
     #return username
     i = web.input()
     if not 'quiz' in i:
         qlist = questions.getQuizzes()
         return render.quizChoser(username,qlist)
     else:
         quizlist = questions.getQuizQuestions(i['quiz'])
         return render.assemble(mathpre,i['quiz'],[],quizlist)
Esempio n. 3
0
 def POST(self):
     validateInstructor()
     i=web.input()
     tag = i['tag']
     quiz = i['quiz']
     newqlist = i['quizlist']
     newqlist = newqlist.replace(' ','')
     questions.setQuizQuestions(quiz,newqlist)
     quizlist = questions.getQuizQuestions(i['quiz'])
     hits = questions.getWithTag(tag)
     qresults = map(cq.clkrQuestion,hits)
     return render.assemble(mathpre,quiz,qresults,quizlist)