From 1b6f05885119715664af62074ccb8cfd5b07172a Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Fri, 10 Feb 2012 12:18:08 -0500 Subject: [PATCH 1/2] Added bar on progress graph to show overall grade. --HG-- branch : bridger-dev --- courseware/views.py | 23 +++++++++++++++++++++++ settings_new_askbot.py | 3 +++ 2 files changed, 26 insertions(+) diff --git a/courseware/views.py b/courseware/views.py index 24ee4982f7..49243d3fb1 100644 --- a/courseware/views.py +++ b/courseware/views.py @@ -1,6 +1,7 @@ import json import logging import os +import random import sys import StringIO import urllib @@ -125,6 +126,13 @@ def profile(request): else: percentage = 0 summary = "0% (?/?)" + + if settings.GENERATE_PROFILE_SCORES: + points_possible = random.randrange(10, 50) + points_earned = random.randrange(5, points_possible) + percentage = points_earned / float(points_possible) + summary = "{0:.0%} ({1}/{2})".format( percentage, points_earned, points_possible ) + summary = "Homework {0} - {1}".format(i + 1, summary) homework_percentages.append( {'percentage': percentage, 'summary': summary} ) @@ -140,6 +148,13 @@ def profile(request): else: percentage = 0 summary = "0% (?/?)" + + if settings.GENERATE_PROFILE_SCORES: + points_possible = random.randrange(10, 50) + points_earned = random.randrange(5, points_possible) + percentage = points_earned / float(points_possible) + summary = "{0:.0%} ({1}/{2})".format( percentage, points_earned, points_possible ) + summary = "Lab {0} - {1}".format(i + 1, summary) lab_percentages.append( {'percentage': percentage, 'summary': summary} ) lab_total, lab_dropped_indices = totalWithDrops(lab_percentages, 2) @@ -152,6 +167,14 @@ def profile(request): final_score = ('?', '?') final_percentage = 0 + if settings.GENERATE_PROFILE_SCORES: + midterm_score = (random.randrange(50, 150), 150) + midterm_percentage = midterm_score[0] / float(midterm_score[1]) + + final_score = (random.randrange(100, 250), 300) + final_percentage = final_score[0] / float(final_score[1]) + + grade_summary = [ { 'category': 'Homework', diff --git a/settings_new_askbot.py b/settings_new_askbot.py index 4e56a07cd6..50a4929488 100644 --- a/settings_new_askbot.py +++ b/settings_new_askbot.py @@ -14,6 +14,9 @@ LIB_URL = 'https://mitxstatic.s3.amazonaws.com/js/' BOOK_URL = '/static/book/' BOOK_URL = 'https://mitxstatic.s3.amazonaws.com/book_images/' +# Feature Flags. These should be set to false until they are ready to deploy, and then eventually flag mechanisms removed +GENERATE_PROFILE_SCORES = False # If this is true, random scores will be generated for the purpose of debugging the profile graphs + # Our parent dir (mitx_all) is the BASE_DIR BASE_DIR = os.path.abspath(os.path.join(__file__, "..", "..")) From a8c32923dca4ef6d9c370df4d2e805349c3c8653 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Fri, 10 Feb 2012 15:57:57 -0500 Subject: [PATCH 2/2] Rotated the profile graph labels, so the all fit --HG-- branch : bridger-dev --- courseware/views.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/courseware/views.py b/courseware/views.py index 49243d3fb1..5a63fb3039 100644 --- a/courseware/views.py +++ b/courseware/views.py @@ -134,8 +134,9 @@ def profile(request): summary = "{0:.0%} ({1}/{2})".format( percentage, points_earned, points_possible ) summary = "Homework {0} - {1}".format(i + 1, summary) + label = "HW {0:02d}".format(i + 1) - homework_percentages.append( {'percentage': percentage, 'summary': summary} ) + homework_percentages.append( {'percentage': percentage, 'summary': summary, 'label' : label} ) homework_total, homework_dropped_indices = totalWithDrops(homework_percentages, 2) #Figure the lab scores @@ -156,7 +157,9 @@ def profile(request): summary = "{0:.0%} ({1}/{2})".format( percentage, points_earned, points_possible ) summary = "Lab {0} - {1}".format(i + 1, summary) - lab_percentages.append( {'percentage': percentage, 'summary': summary} ) + label = "Lab {0:02d}".format(i + 1) + + lab_percentages.append( {'percentage': percentage, 'summary': summary, 'label' : label} ) lab_total, lab_dropped_indices = totalWithDrops(lab_percentages, 2) @@ -171,7 +174,7 @@ def profile(request): midterm_score = (random.randrange(50, 150), 150) midterm_percentage = midterm_score[0] / float(midterm_score[1]) - final_score = (random.randrange(100, 250), 300) + final_score = (random.randrange(100, 300), 300) final_percentage = final_score[0] / float(final_score[1]) @@ -181,6 +184,7 @@ def profile(request): 'subscores' : homework_percentages, 'dropped_indices' : homework_dropped_indices, 'totalscore' : {'score' : homework_total, 'summary' : "Homework Average - {0:.0%}".format(homework_total)}, + 'totallabel' : 'HW Avg', 'weight' : 0.15, }, { @@ -188,16 +192,19 @@ def profile(request): 'subscores' : lab_percentages, 'dropped_indices' : lab_dropped_indices, 'totalscore' : {'score' : lab_total, 'summary' : "Lab Average - {0:.0%}".format(lab_total)}, + 'totallabel' : 'Lab Avg', 'weight' : 0.15, }, { 'category': 'Midterm', 'totalscore' : {'score' : midterm_percentage, 'summary' : "Midterm - {0:.0%} ({1}/{2})".format(midterm_percentage, midterm_score[0], midterm_score[1])}, + 'totallabel' : 'Midterm', 'weight' : 0.30, }, { 'category': 'Final', 'totalscore' : {'score' : final_percentage, 'summary' : "Final - {0:.0%} ({1}/{2})".format(final_percentage, final_score[0], final_score[1])}, + 'totallabel' : 'Final', 'weight' : 0.40, } ]