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'))
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)
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)
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'))