Added has_score attribute to xmodule, for problem-like xmodules.
This commit is contained in:
@@ -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)]
|
||||
|
||||
section_description = { 'section_descriptor' : s, 'xmoduledescriptors' : xmoduledescriptors}
|
||||
xmoduledescriptors = list(yield_descriptor_descendents(s))
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user