Example #1
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)
Example #2
0
    def GET(self):
        username = validateInstructor()
        wi = web.input()
        #return str(wi)
        action = wi['action']
        if action == "setsession":
            sess = wi['session']
            control.setInstrSession(username,sess)
        session = control.getUserSession(username)
        sess=session #lazyness
        page = control.getSessionPage(session)
        length = control.getQuizLength(session)
        clkq = questions.giveClickerQuestion(session,page)
        state = control.getSessionState(session)
        print str(wi) #debug

        ###############
        # Issue:
        # There is a strange bug that the correct pages aren't always 
        # served. E.g. click on "next" but the url indicates another
        # action. This is annoying, but I don't know how to fix it.
        # For now, however, here is a clause that pervents
        # immediately showing the answers or skipping to the next
        # answer. The fix seems to work but buttons don't work very well
        #################

        ####
        # Weird redirect bug fix, to pervent passing to next,
        # showAns, showResp.
        ###
        if (state == "init" or state == "ultimatum" or state=="open"):blocked=True
        else: blocked=False
        
        if action == "setsession":
            return render.ask(mathpre,clkq.showCorrect(),page+1,length,state)        
        elif action == "next":
            #if blocked:#bypass
            #    return render.ask(mathpre,clkq.showCorrect(),page+1,length,state) 
            state = "init"
            another = control.advanceSession(session)
            page = page+1 #To ensure that the correct page is displayed
            clkq = questions.giveClickerQuestion(session,page)#update clickerquestion
            if another:
                return render.ask(mathpre,clkq.showCorrect(),page+1,length,state)        
            else:
                return "<a href=\"/\">quiz finished</a>"

        elif action == "answers":
            return render.ask(mathpre,clkq.showCorrect(),page+1,length,state)

        elif action =="scores":
            tally = gradebook.tallyAnswers(sess,page)
            return render.ask(mathpre,clkq.showResponses(tally),page+1,length,state)

        elif (action == "closed") or (action == "open"):
            #print "ACTION:"+action#debug
            #return str(wi)
            control.setSessionState(sess,action)
            state = action
            return render.ask(mathpre,clkq.showCorrect(),page+1,length,state)        

        elif action == "showAns":
            if blocked:#bypass
                return render.ask(mathpre,clkq.showCorrect(),page+1,length,state) 
            control.setSessionState(sess,action)
            print "Return answers"
            return render.ask(mathpre,clkq.showCorrect(),page+1,length,state)

        elif action == "showResp":
            if blocked:#bypass
                return render.ask(mathpre,clkq.showCorrect(),page+1,length,state) 
            control.setSessionState(sess,action)
            tally = gradebook.tallyAnswers(sess,page)
            print "retrun tally"
            return render.ask(mathpre,clkq.showResponses(tally),page+1,length,state)
        
        return "gurgle"