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 admin_edit_course_content(module_title):
    """ return information about the content of the course to be edited"""

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

    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 = []
    questions = db.get_quiz_questions_by_module(module_id);
    answers = db.get_quiz_answers();
    correct_answers = db.get_correct_answers();
    int_questions = db.get_int_questions_by_module(module_id);
    int_answers = db.get_int_answers();
    int_correct_answers = db.get_int_correct_answers();

    if g.username in g.admins:
	    modules = db.get_admin_module_info()
	    return render_template('admin_drawingboard.html', 
		    pagetitle = g.appname + " - Edit Module Content",
		    subtitle = "Drawingboard: " + module_title, 
		    name = g.user, questions = questions,
		    answers = answers, correct_answers = correct_answers,
		    int_questions = int_questions, int_answers = int_answers,
		    int_correct_answers = int_correct_answers,
		    module_id = module_id, slides = list(enumerate(slides, 1)),
		    is_admin = True)
    return render_template('unauthorized.html', name=g.user, 
	    subtitle = "Not Authorized", is_admin = False)
Esempio n. 3
0
def admin_preview_module(module_title):
    """ Displays a module to the user. Currently content is stored in .txt
	files and parsed, will eventually shift to using database. """
    modules_list = db.get_all_module_names()

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

    # 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 in g.admins:
	return render_template('admin_preview.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 = True)
    return render_template('unauthorized.html', name=g.user, 
	    subtitle = "Not Authorized", is_admin = False)
Esempio n. 4
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'))