예제 #1
0
파일: views.py 프로젝트: R-Ramana/Knewbie
def result(quizID=None):
    if not current_user.check_student():
        return render_template('errors/error403.html'), 403
    form = ReattemptForm()
    quiz = None
    if quizID:
        quiz = validate_quiz_stu(quizID)
    correct, questions = get_response_answer(current_user, quizID)
    return render_template('quiz/result.html', questions=questions, correct=correct, quiz=quiz, form=form)
예제 #2
0
파일: views.py 프로젝트: R-Ramana/Knewbie
def reattempt_edu(quizID):
    '''Reattempt educator quiz'''
    if not current_user.check_student():
        return render_template('errors/error403.html'), 403
    quiz = validate_quiz_stu_edu(current_user, quizID)

    form = ReattemptForm()
    if form.validate_on_submit():
        remove_quiz_responses(current_user, quiz)

    return redirect(url_for('quiz.edu_quiz', quizID=quizID, qnNum=1))
예제 #3
0
def settings_knewbie_id():
    """Routing to update Knewbie ID"""

    if not current_user.check_student():
        return render_template('errors/error403.html'), 403
    form = UpdateProfileForm(prefix='profile')
    knewbieForm = ChangeKnewbieForm(prefix='knewbie')
    if knewbieForm.validate_on_submit():
        set_knewbie_id(current_user)
        db.session.commit()
        flash('Your profile has been successfully updated!', 'success')
    return redirect(url_for('main.settings'))
예제 #4
0
파일: views.py 프로젝트: R-Ramana/Knewbie
def reattempt():
    '''Reattempt tailored quiz'''
    if not current_user.check_student():
        return render_template('errors/error403.html'), 403

    form = ReattemptForm()
    if form.validate_on_submit():
        remove_incorrect_responses(current_user)
        correct, questions = get_response_answer(current_user)   

        return redirect(url_for('quiz.quiz', attempt=correct+4))

    return redirect(url_for('main.dashboard'))
예제 #5
0
파일: views.py 프로젝트: R-Ramana/Knewbie
def edu_quiz(quizID, qnNum):
    '''Renders user-created quiz'''
    if not current_user.check_student():
        return render_template('errors/error403.html'), 403
    quiz = validate_quiz_stu(quizID)

    if len(quiz.questions) < qnNum:
        return redirect(url_for('quiz.result', quizID=quizID))

    # If attempting the quiz, get the question to display
    if request.method == 'GET':
        question, options = get_question(current_user, quiz, qnNum - 1)
        if question:
            return render_template('quiz/quiz.html', quiz=quiz, qnNum=qnNum, question=question, options=options, edu=True)

    # If submitting an attempted question
    elif request.method == 'POST':
        submit_response(current_user, request.form)
    return redirect(url_for('quiz.edu_quiz',quizID=quizID,qnNum=qnNum+1))