From f9a04406c21a357cda8b127462efe457717e5a2b Mon Sep 17 00:00:00 2001 From: Lyla Fischer Date: Mon, 16 Apr 2012 12:24:18 -0400 Subject: [PATCH 1/3] fixed the default weight to not interfere with precedent --- djangoapps/courseware/grades.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangoapps/courseware/grades.py b/djangoapps/courseware/grades.py index 144f926c7f..5efa8372e5 100644 --- a/djangoapps/courseware/grades.py +++ b/djangoapps/courseware/grades.py @@ -100,7 +100,7 @@ def grade_sheet(student): correct = random.randrange( max(total-2, 1) , total + 1 ) else: correct = total - scores.append( Score(int(correct),total, float(p.get("weight", 1)), graded, p.get("name")) ) + scores.append( Score(int(correct),total, float(p.get("weight", total)), graded, p.get("name")) ) section_total, graded_total = aggregate_scores(scores) #Add the graded total to totaled_scores From da3424f67a85be8124c74792286dd95d5f900878 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Tue, 17 Apr 2012 11:45:24 -0400 Subject: [PATCH 2/3] Fixed zero-score-possible bug. --- djangoapps/courseware/grades.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/djangoapps/courseware/grades.py b/djangoapps/courseware/grades.py index 5efa8372e5..68e0f11dcd 100644 --- a/djangoapps/courseware/grades.py +++ b/djangoapps/courseware/grades.py @@ -131,6 +131,8 @@ def grade_sheet(student): } def aggregate_scores(scores): + scores = filter( lambda score: score.possible > 0, scores ) + total_correct_graded = sum((score.earned*1.0/score.possible)*score.weight for score in scores if score.graded) total_possible_graded = sum(score.weight for score in scores if score.graded) total_correct = sum((score.earned*1.0/score.possible)*score.weight for score in scores) @@ -225,10 +227,10 @@ def grade_summary_6002x(totaled_scores): final_percentage = final_score.earned * 1.0 / final_score.possible if 'Final' in totaled_scores else 0 if settings.GENERATE_PROFILE_SCORES: - midterm_score = Score(random.randrange(50, 150), 150, True, "?") + midterm_score = Score(random.randrange(50, 150), 150, 150, True, "?") midterm_percentage = midterm_score.earned / float(midterm_score.possible) - final_score = Score(random.randrange(100, 300), 300, True, "?") + final_score = Score(random.randrange(100, 300), 300, 300, True, "?") final_percentage = final_score.earned / float(final_score.possible) From a6fb97affa80dc6e8e51d970f9849ae823987753 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Tue, 17 Apr 2012 13:59:00 -0400 Subject: [PATCH 3/3] Catch Exception instead of ValueError for accessing our general content cache -- exception thrown changed in django 1.4 --- lib/util/cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/cache.py b/lib/util/cache.py index b0c370a035..c6f11f7d66 100644 --- a/lib/util/cache.py +++ b/lib/util/cache.py @@ -11,6 +11,6 @@ from django.core import cache # to returning the default cache. This will happen with dev machines. try: cache = cache.get_cache('general') -except ValueError: +except Exception: cache = cache.cache