Esempio n. 1
0
 def GET(self,choice):
     """
     The student sends the answer choice as a url. 
     The figures out what to pass to the toggleChoice method 
     and returns the entry in the daabase (either 0 or 1).
     """
     user = validateStudent()#this is potentially sensitive
     session = control.getStudentSession(user)
     qnumber = control.getSessionPage(session)
     state = control.getStudentState(user)
     if state == "open" or state == "ultimatum":
         return gradebook.toggleChoice(user,session,qnumber,choice)
     else:
         return "-1"
Esempio n. 2
0
    def GET(self,username):
        student = validateStudent()#ensures credentials are okay
        if not student==username:
            raise web.seeother("/logout/?msg=unauthorized")
        sess = control.getStudentSession(username)
        page = control.getSessionPage(sess)
        if page == None:
            return render.studentFinished()
        state = control.getSessionState(sess)
        if state == "finished":
            return render.studentFinished() 
        tally = gradebook.tallyAnswers(sess,page)
        clkq = questions.giveClickerQuestion(sess,page)

        #STATE SWITCH
        if state == "init":
            content = render.notReady()
            title = "Get ready"
        elif state == "open" or state =="ultimatum":
            title="Question"
            content = clkq.getRendered()
        elif state == "closed":
            title = "Question closed"
            content = clkq.getRendered()
        elif state == "showResp":
            title = "Class responses"
            content = clkq.showResponses(tally)
        elif state == "showAns":
            title = "Correct answer"
            content = clkq.showCorrect()

        selections = gradebook.getStudentSelections(student,sess,page)#makes sure student is shown responses in case of reload
        if state == "closed":
            return render.questionClosed(mathpre,title,content,page+1,state,selections)
        else:
            return render.question(mathpre,title,content,page+1,state,selections)