Skip to content
Snippets Groups Projects
Commit 35af8101 authored by Calen Pennington's avatar Calen Pennington
Browse files

Make grade graph on profile work correctly

parent 23195e9d
No related merge requests found
......@@ -57,8 +57,6 @@ class SemanticSectionDescriptor(XModuleDescriptor):
if len(xml_object) == 1:
for (key, val) in xml_object.items():
if key == 'format':
continue
xml_object[0].set(key, val)
return system.process_xml(etree.tostring(xml_object[0]))
......
......@@ -85,6 +85,8 @@ class XModule(object):
self.display_name = kwargs.get('display_name', '')
self.type = self.location.category
self._loaded_children = None
self.graded = kwargs.get('graded', False)
self.format = kwargs.get('format')
def get_name(self):
name = self.__xmltree.get('name')
......@@ -281,6 +283,9 @@ class XModuleDescriptor(Plugin):
Current arguments passed in kwargs:
location: A keystore.Location object indicating the name and ownership of this problem
goals: A list of strings of learning goals associated with this module
display_name: The name to use for displaying this module to the user
format: The format of this module ('Homework', 'Lab', etc)
graded (bool): Whether this module is should be graded or not
"""
self.system = system
self.definition = definition if definition is not None else {}
......@@ -288,6 +293,8 @@ class XModuleDescriptor(Plugin):
self.type = Location(kwargs.get('location')).category
self.url = Location(kwargs.get('location')).url()
self.display_name = kwargs.get('display_name')
self.format = kwargs.get('format')
self.graded = kwargs.get('graded', False)
# For now, we represent goals as a list of strings, but this
# is one of the things that we are going to be iterating on heavily
......@@ -315,7 +322,9 @@ class XModuleDescriptor(Plugin):
instance_state and shared_state, and returns a fully nstantiated XModule
"""
return partial(self.module_class, system, self.url, self.definition,
display_name=self.display_name)
display_name=self.display_name,
format=self.format,
graded=self.graded)
class DescriptorSystem(object):
def __init__(self, load_item, resources_fs):
......
......@@ -37,5 +37,7 @@ class XmlDescriptor(XModuleDescriptor):
course,
xml_object.tag,
xml_object.get('slug')],
display_name=xml_object.get('name')
display_name=xml_object.get('name'),
format=xml_object.get('format'),
graded=xml_object.get('graded') == 'true',
)
......@@ -92,6 +92,9 @@ def grade_sheet(student, course, student_module_cache):
for module in yield_descendents(s):
(correct, total) = get_score(student, module, student_module_cache)
if correct is None and total is None:
continue
if settings.GENERATE_PROFILE_SCORES:
if total > 1:
correct = random.randrange(max(total - 2, 1), total + 1)
......@@ -102,14 +105,13 @@ def grade_sheet(student, course, student_module_cache):
#We simply cannot grade a problem that is 12/0, because we might need it as a percentage
graded = False
if correct is not None and total is not None:
scores.append(Score(correct, total, graded, module.display_name))
scores.append(Score(correct, total, graded, module.display_name))
section_total, graded_total = graders.aggregate_scores(scores, s.display_name)
#Add the graded total to totaled_scores
format = getattr(s, 'format', "")
subtitle = getattr(s, 'subtitle', format)
if format and graded_total[1] > 0:
if format and graded_total.possible > 0:
format_scores = totaled_scores.get(format, [])
format_scores.append(graded_total)
totaled_scores[format] = format_scores
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment