Commit a99d7f7c by Bridger Maxwell

Fixed settings.GENERATE_PROFILE_SCORES for debugging progress graph.

parent 8ba85044
import abc import abc
import json import json
import logging import logging
import random
import sys import sys
from collections import namedtuple from collections import namedtuple
from django.conf import settings
log = logging.getLogger("mitx.courseware") log = logging.getLogger("mitx.courseware")
# This is a tuple for holding scores, either from problems or sections. # This is a tuple for holding scores, either from problems or sections.
...@@ -245,7 +248,16 @@ class SingleSectionGrader(CourseGrader): ...@@ -245,7 +248,16 @@ class SingleSectionGrader(CourseGrader):
foundScore = score foundScore = score
break break
if foundScore: if settings.GENERATE_PROFILE_SCORES: # for debugging!
earned = random.randint(2,15)
possible = random.randint(earned, 15)
percent = float(earned) / possible
detail = "{name} - {percent:.0%} ({earned:.3n}/{possible:.3n})".format(name=self.name,
percent=percent,
earned=float(earned),
possible=float(possible))
elif foundScore:
percent = foundScore.earned / float(foundScore.possible) percent = foundScore.earned / float(foundScore.possible)
detail = "{name} - {percent:.0%} ({earned:.3n}/{possible:.3n})".format(name=self.name, detail = "{name} - {percent:.0%} ({earned:.3n}/{possible:.3n})".format(name=self.name,
percent=percent, percent=percent,
...@@ -316,7 +328,19 @@ class AssignmentFormatGrader(CourseGrader): ...@@ -316,7 +328,19 @@ class AssignmentFormatGrader(CourseGrader):
scores = grade_sheet.get(self.type, []) scores = grade_sheet.get(self.type, [])
breakdown = [] breakdown = []
for i in range(max(self.min_count, len(scores))): for i in range(max(self.min_count, len(scores))):
if i < len(scores): print "scores" , scores
if settings.GENERATE_PROFILE_SCORES: # for debugging!
earned = random.randint(2,15)
possible = random.randint(earned, 15)
percentage = float(earned) / possible
summary = "{section_type} {index} - {name} - {percent:.0%} ({earned:.3n}/{possible:.3n})".format(index=i + 1,
section_type=self.section_type,
name="Generated",
percent=percentage,
earned=float(earned),
possible=float(possible))
elif i < len(scores):
percentage = scores[i].earned / float(scores[i].possible) percentage = scores[i].earned / float(scores[i].possible)
summary = "{section_type} {index} - {name} - {percent:.0%} ({earned:.3n}/{possible:.3n})".format(index=i + 1, summary = "{section_type} {index} - {name} - {percent:.0%} ({earned:.3n}/{possible:.3n})".format(index=i + 1,
section_type=self.section_type, section_type=self.section_type,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment