Esempio n. 1
0
def user_module_slideshow(module_title):
    """ Displays a module to the user from the database."""
    modules_list = db.get_module_names()

    # check url is valid
    if module_title.lower() not in modules_list:
	flash("Invalid module title.", "invalid")
	return redirect(url_for('user_module_list'))

    # get module content
    module_id = db.get_module_id_from_name(module_title)
    module_content = db.get_module_content(module_id)
    if (module_content != ""):
	slides = json.loads(module_content)
    else:
	slides = []
    quizzes = db.get_quiz_questions_by_module(module_id)
    answers = db.get_quiz_answers()
    interactive_questions = db.get_int_questions_by_module(module_id)
    interactive_answers = db.get_int_answers() 
 
    if g.username not in g.admins:
	return render_template('user_module.html', 
		module_id = module_id,
		pagetitle = g.appname + " - " + module_title,
		subtitle = "Module: " + module_title, 
		name = g.user,
		module_title = module_title, slides = slides,
		quizzes = quizzes, answers = answers, 
		interactive_questions = interactive_questions,
		interactive_answers = interactive_answers,
		is_admin = False)
    return redirect(url_for('admin_dashboard'))
Esempio n. 2
0
def user_grade_details(module_title):
    """ displays grades to the user by the requested module. """
    modules_list = db.get_module_names()

    # check url is valid
    if module_title.lower() not in modules_list:
	flash("Invalid module title.", "invalid")
	return redirect(url_for('user_module_list'))

    modules = db.get_module_info()
    num_correct_answers = db.get_number_of_correct_answers(g.username, module_title)
    number_of_questions = db.get_total_number_of_questions(module_title)
    module_id = db.get_module_id_from_name(module_title)    
    quizzes = db.get_quiz_questions_by_module(module_id)
    answers = db.get_quiz_answers()
    correct_answers = db.get_correct_answers()
    user_answers= db.get_quiz_answers_by_user(g.username)
    stats = db.get_question_statistics()
    for quiz in quizzes:
	for stat in stats:
	    if stat['QUESTION_ID'] == quiz['QUESTION_ID']:
		if ("SUCCESS" not in quiz or quiz['SUCCESS'] == 0):
		    quiz['SUCCESS'] = int(stat['PERCENT_SUCCESS'])
	    else:
		if ("SUCCESS" not in quiz):
		    quiz['SUCCESS'] = 0

    try:
	percentage_correct = int((num_correct_answers /float( number_of_questions)) * 100)
    except ZeroDivisionError:
	percentage_correct = 0

    if g.username not in g.admins:
        return render_template('user_grades.html', name = g.user, 
		subtitle = "My Grades: " + module_title,
		correct_answers = correct_answers, user_answers = user_answers,
		num_correct_answers = num_correct_answers,
                number_of_questions = number_of_questions, 
		percentage_correct = percentage_correct,
		quizzes = quizzes, answers = answers, 
		module_title = module_title, modules = modules, is_admin = False)
    return redirect(url_for('admin_dashboard'))
Esempio n. 3
0
def user_module_review(module_title):
    """ Displays a module to review for the user from the database. """
    modules_list = db.get_module_names()

    # check url is valid
    if module_title.lower() not in modules_list:
	flash("Invalid module title.", "invalid")
	return redirect(url_for('user_module_list'))

    # get module content
    module_id = db.get_module_id_from_name(module_title)
    module_content = db.get_module_content(module_id)
    if (module_content != ""):
	slides = json.loads(module_content)
    else:
	slides = []
    
    if g.username not in g.admins:
	return render_template('user_module_review.html', name = g.user, 
		slides = slides, subtitle = "Review: " + module_title,
		is_admin = False)
    return redirect(url_for('admin_dashboard'))