コード例 #1
0
ファイル: app.py プロジェクト: NizarBerjawi/auscats
def user_module_list():
    """ Default user page: displays list of modules in progress,
	completed, or scheduled. """

    active_modules = db.get_module_info()
    active_module_ids = [x['MODULE_ID'] for x in active_modules]
    modules_completed = db.modules_completed_by_user(g.username)
    modules_completed = [x for x in modules_completed if x in active_module_ids]
    modules_started = db.get_modules_started_by_user(g.username)
    modules_started = [x for x in modules_started if x in active_module_ids]
    last_viewed_slide = db.get_last_viewed_slide_by_user(g.username)
    modules_in_progress = [x for x in modules_started if x not in modules_completed]
    num_active_modules = len(active_modules)
    num_complete = len(modules_completed)
    num_started = len(modules_started)
    num_in_progress = len(modules_in_progress)
    num_scheduled = num_active_modules - num_complete - num_in_progress
    
    if g.username not in g.admins:
	return render_template('user_module_list.html', 
		pagetitle = g.appname + " - My Modules",
		subtitle = "My Modules", 
		user_id = g.username, name = g.user,
		active_modules = active_modules, 
		modules_completed = modules_completed,
		modules_started = modules_started,
		modules_in_progress = modules_in_progress,
		num_active_modules = num_active_modules,
                num_complete = num_complete,
		num_started = num_started,
		num_in_progress = num_in_progress,
		num_scheduled = num_scheduled,
		last_viewed_slide = last_viewed_slide, is_admin = False)
    return redirect(url_for('admin_dashboard'))
コード例 #2
0
ファイル: app.py プロジェクト: NizarBerjawi/auscats
def admin_dashboard():
    """ main admin user page """

    modules = db.get_module_info()
    org_units = db.get_org_unit_info()
    last_updated = db.get_last_updated_module()

    if g.username in g.admins:
	return render_template('admin_dashboard.html', 
		pagetitle = g.appname + " - My Dashboard",
		subtitle = "Administrator Dashboard", 
		name = g.user,
		modules = modules,
		last_updated = last_updated,
		org_units = org_units, 
		is_admin = True)
    return render_template('unauthorized.html', name=g.user, 
	    subtitle = "Not Authorized", is_admin = False)
コード例 #3
0
ファイル: app.py プロジェクト: NizarBerjawi/auscats
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'))
コード例 #4
0
ファイル: app.py プロジェクト: NizarBerjawi/auscats
def user_grade_list():
    """ displays grades to the user for all the modules they have completed. """

    modules = db.get_module_info()
    grades = completed_module_ids = db.modules_completed_by_user(g.username)
    completed_modules = []
    for module in modules:
	if module['MODULE_ID'] in completed_module_ids:
	    number_of_questions = db.get_total_number_of_questions(module['NAME'])
	    correct_answers = db.get_number_of_correct_answers(g.username, module['NAME'])
	    module['GRADE'] = int(correct_answers / float(number_of_questions) * 100)
	    completed_modules.append(module)
    if g.username not in g.admins:
	return render_template('user_gradebook.html', 
		pagetitle = g.appname + " - My Grades",
		subtitle = "My Grades", 
		name = g.user,
		completed_modules = completed_modules,
		is_admin = False)
    return redirect(url_for('admin_dashboard'))