Commit e2dd118c by Bridger Maxwell

Added has_score attribute to xmodule, for problem-like xmodules.

parent 0cb100cf
......@@ -564,6 +564,7 @@ class CapaDescriptor(RawDescriptor):
module_class = CapaModule
stores_state = True
has_score = True
# Capa modules have some additional metadata:
# TODO (vshnayder): do problems have any other metadata? Do they
......
......@@ -99,10 +99,10 @@ class CourseDescriptor(SequenceDescriptor):
sections = []
for s in c.get_children():
if s.metadata.get('graded', False):
# TODO: Only include modules that have a score here
xmoduledescriptors = [child for child in yield_descriptor_descendents(s)]
xmoduledescriptors = list(yield_descriptor_descendents(s))
section_description = { 'section_descriptor' : s, 'xmoduledescriptors' : xmoduledescriptors}
# The xmoduledescriptors included here are only the ones that have scores.
section_description = { 'section_descriptor' : s, 'xmoduledescriptors' : filter(lambda child: child.has_score, xmoduledescriptors) }
section_format = s.metadata.get('format', "")
graded_sections[ section_format ] = graded_sections.get( section_format, [] ) + [section_description]
......
......@@ -308,6 +308,9 @@ class XModuleDescriptor(Plugin, HTMLSnippet):
# Attributes for inpsection of the descriptor
stores_state = False # Indicates wether the xmodule state should be
# stored in a database (independent of shared state)
has_score = False # This indicates whether the xmodule is a problem-type.
# It should respond to max_score() and grade(). It can be graded or ungraded
# (like a practice problem).
# A list of metadata that this module can inherit from its parent module
inheritable_metadata = (
......
......@@ -183,8 +183,8 @@ def get_score(user, problem, student_module_cache):
problem: an XModule
cache: A StudentModuleCache
"""
if not problem.descriptor.stores_state:
# These are not problems, and do not store state
if not problem.descriptor.stores_state or not problem.descriptor.has_score:
# These are not problems, and do not have a score
return (None, None)
correct = 0.0
......
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