def studentreport(): data_analyzer = DashboardDataAnalyzer(auth.user.course_id) # todo: Test to see if vars.id is there -- if its not then load_user_metrics will crash # todo: This seems redundant with assignments/index -- should use this one... id should be text sid data_analyzer.load_user_metrics(request.vars.id) data_analyzer.load_assignment_metrics(request.vars.id) chapters = [] for chapter_label, chapter in six.iteritems( data_analyzer.chapter_progress.chapters): chapters.append({ "label": chapter.chapter_label, "status": chapter.status_text(), "subchapters": chapter.get_sub_chapter_progress(), }) activity = data_analyzer.formatted_activity.activities logger.debug("GRADES = %s", data_analyzer.grades) return dict( course=get_course_row(db.courses.ALL), user=data_analyzer.user, chapters=chapters, activity=activity, assignments=data_analyzer.grades, )
def index(): if not auth.user: session.flash = "Please Login" return redirect(URL('default', 'index')) if 'sid' not in request.vars: #return redirect(URL('assignments','index') + '?sid=%s' % (auth.user.username)) request.vars.sid = auth.user.username student = db(db.auth_user.username == request.vars.sid).select( db.auth_user.id, db.auth_user.username, db.auth_user.first_name, db.auth_user.last_name, db.auth_user.email, ).first() if not student: return redirect(URL('assignments', 'index')) if auth.user.course_name in ['thinkcspy', 'pythonds', 'JavaReview', 'webfundamentals', 'StudentCSP', 'apcsareview']: session.flash = "{} is not a graded course".format(auth.user.course_name) return redirect(URL('default', 'user')) data_analyzer = DashboardDataAnalyzer(auth.user.course_id) data_analyzer.load_user_metrics(request.vars.sid) data_analyzer.load_assignment_metrics(request.vars.sid, studentView=True) chapters = [] for chapter_label, chapter in six.iteritems(data_analyzer.chapter_progress.chapters): chapters.append({ "label": chapter.chapter_label, "status": chapter.status_text(), "subchapters": chapter.get_sub_chapter_progress() }) activity = data_analyzer.formatted_activity.activities (now, now_local, message1, message2, practice_graded, spacing, interleaving, practice_completion_count, remaining_days, max_days, max_questions, day_points, question_points, presentable_flashcards, available_flashcards_num, practiced_today_count, questions_to_complete_day, practice_today_left, points_received, total_possible_points, flashcard_creation_method) = _get_practice_data(auth.user, float(session.timezoneoffset) if 'timezoneoffset' in session else 0) return dict(student=student, course_id=auth.user.course_id, course_name=auth.user.course_name, user=data_analyzer.user, chapters=chapters, activity=activity, assignments=data_analyzer.grades, practice_message1=message1, practice_message2=message2, practice_graded=practice_graded, flashcard_count=available_flashcards_num, # The number of days the student has completed their practice. practice_completion_count=practice_completion_count, remaining_days=remaining_days, max_questions=max_questions, max_days=max_days, total_today_count=min(practice_today_left + practiced_today_count, questions_to_complete_day), # The number of times remaining to practice today to get the completion point. practice_today_left=practice_today_left, # The number of times this user has submitted their practice from the beginning of today (12:00 am) # till now. practiced_today_count=practiced_today_count, points_received=points_received, total_possible_points=total_possible_points, spacing=spacing, interleaving=interleaving )
def studentreport(): data_analyzer = DashboardDataAnalyzer(auth.user.course_id) for_dashboard = verifyInstructorStatus(auth.user.course_id, auth.user.id) if "id" in request.vars and for_dashboard: sid = request.vars.id else: sid = auth.user.username response.view = "assignments/index.html" data_analyzer.load_user_metrics(sid) data_analyzer.load_assignment_metrics(sid, not for_dashboard) chapters = [] for chapter_label, chapter in six.iteritems( data_analyzer.chapter_progress.chapters): chapters.append({ "label": chapter.chapter_label, "status": chapter.status_text(), "subchapters": chapter.get_sub_chapter_progress(), }) activity = data_analyzer.formatted_activity logger.debug("GRADES = %s", data_analyzer.grades) pd_dict = dict() if response.view == "assignments/index.html": ( pd_dict["now"], pd_dict["now_local"], pd_dict["practice_message1"], pd_dict["practice_message2"], pd_dict["practice_graded"], pd_dict["spacing"], pd_dict["interleaving"], pd_dict["practice_completion_count"], pd_dict["remaining_days"], pd_dict["max_days"], pd_dict["max_questions"], pd_dict["day_points"], pd_dict["question_points"], pd_dict["presentable_flashcards"], pd_dict["flashcard_count"], pd_dict["practiced_today_count"], pd_dict["questions_to_complete_day"], pd_dict["practice_today_left"], pd_dict["points_received"], pd_dict["total_possible_points"], pd_dict["flashcard_creation_method"], ) = _get_practice_data( auth.user, float(session.timezoneoffset) if "timezoneoffset" in session else 0, db, ) pd_dict["total_today_count"] = min( pd_dict["practice_today_left"] + pd_dict["practiced_today_count"], pd_dict["questions_to_complete_day"], ) if request.vars.action == "dlcsv": mtbl = pd.read_sql_query( """ select * from useinfo where sid = %(sid)s and course_id = %(course)s """, settings.database_uri, params={ "sid": sid, "course": auth.user.course_name }, ) response.headers["Content-Type"] = "application/vnd.ms-excel" response.headers[ "Content-Disposition"] = "attachment; filename=data_for_{}.csv".format( sid) session.flash = f"Downloading to data_for_{sid}.csv" return mtbl.to_csv(na_rep=" ") if request.vars.action == "dlcode": mtbl = pd.read_sql_query( """ select * from code where sid = %(sid)s and course_id = %(course)s """, settings.database_uri, params={ "sid": auth.user.username, "course": auth.user.course_id }, ) response.headers["Content-Type"] = "application/vnd.ms-excel" response.headers[ "Content-Disposition"] = "attachment; filename=code_for_{}.csv".format( sid) session.flash = f"Downloading to code_for_{sid}.csv" return mtbl.to_csv(na_rep=" ") return dict( course=get_course_row(db.courses.ALL), user=data_analyzer.user, chapters=chapters, activity=activity, assignments=data_analyzer.grades, **pd_dict, )
def studentreport(): data_analyzer = DashboardDataAnalyzer(auth.user.course_id) for_dashboard = verifyInstructorStatus(auth.user.course_id, auth.user.id) if "id" in request.vars and for_dashboard: sid = request.vars.id else: sid = auth.user.username response.view = "assignments/index.html" data_analyzer.load_user_metrics(sid) data_analyzer.load_assignment_metrics(sid) chapters = [] for chapter_label, chapter in six.iteritems( data_analyzer.chapter_progress.chapters): chapters.append({ "label": chapter.chapter_label, "status": chapter.status_text(), "subchapters": chapter.get_sub_chapter_progress(), }) activity = data_analyzer.formatted_activity logger.debug("GRADES = %s", data_analyzer.grades) pd = dict() if response.view == "assignments/index.html": ( pd["now"], pd["now_local"], pd["practice_message1"], pd["practice_message2"], pd["practice_graded"], pd["spacing"], pd["interleaving"], pd["practice_completion_count"], pd["remaining_days"], pd["max_days"], pd["max_questions"], pd["day_points"], pd["question_points"], pd["presentable_flashcards"], pd["flashcard_count"], pd["practiced_today_count"], pd["questions_to_complete_day"], pd["practice_today_left"], pd["points_received"], pd["total_possible_points"], pd["flashcard_creation_method"], ) = _get_practice_data( auth.user, float(session.timezoneoffset) if "timezoneoffset" in session else 0, db, ) pd["total_today_count"] = min( pd["practice_today_left"] + pd["practiced_today_count"], pd["questions_to_complete_day"], ) return dict(course=get_course_row(db.courses.ALL), user=data_analyzer.user, chapters=chapters, activity=activity, assignments=data_analyzer.grades, **pd)