Commit 7ac8fecb by Calen Pennington

Rename XModule[Descriptor].type to .category to be parallel to Location

parent 7b78fa52
......@@ -22,7 +22,7 @@ def edit_item(request):
return render_to_response('unit.html', {
'contents': item.get_html(),
'js_module': item.js_module_name(),
'type': item.type,
'category': item.category,
'name': item.name,
})
......
......@@ -2,7 +2,7 @@
<header>
<section>
<h1 class="editable">${name}</h1>
<p>${type}</p>
<p>${category}</p>
</section>
<div class="actions">
......
......@@ -95,7 +95,7 @@ class XModule(object):
self.shared_state = shared_state
self.id = self.location.url()
self.name = self.location.name
self.type = self.location.category
self.category = self.location.category
self.metadata = kwargs.get('metadata', {})
self._loaded_children = None
......@@ -235,7 +235,7 @@ class XModuleDescriptor(Plugin):
self.system = system
self.definition = definition if definition is not None else {}
self.name = Location(kwargs.get('location')).name
self.type = Location(kwargs.get('location')).category
self.category = Location(kwargs.get('location')).category
self.url = Location(kwargs.get('location')).url()
self.metadata = kwargs.get('metadata', {})
self.shared_state_key = kwargs.get('shared_state_key')
......
......@@ -146,9 +146,9 @@ def get_score(user, problem, cache):
correct = 0.0
# If the ID is not in the cache, add the item
instance_module = cache.lookup(problem.type, problem.id)
instance_module = cache.lookup(problem.category, problem.id)
if instance_module is None:
instance_module = StudentModule(module_type=problem.type,
instance_module = StudentModule(module_type=problem.category,
module_state_key=problem.id,
student=user,
state=None,
......
......@@ -207,10 +207,10 @@ def get_module(user, request, location, student_module_cache, position=None):
'''
descriptor = keystore().get_item(location)
instance_module = student_module_cache.lookup(descriptor.type, descriptor.url)
instance_module = student_module_cache.lookup(descriptor.category, descriptor.url)
shared_state_key = getattr(descriptor, 'shared_state_key', None)
if shared_state_key is not None:
shared_module = student_module_cache.lookup(descriptor.type, shared_state_key)
shared_module = student_module_cache.lookup(descriptor.category, shared_state_key)
else:
shared_module = None
......@@ -246,7 +246,7 @@ def get_module(user, request, location, student_module_cache, position=None):
if not instance_module:
instance_module = StudentModule(
student=user,
module_type=descriptor.type,
module_type=descriptor.category,
module_state_key=module.id,
state=module.get_instance_state(),
max_grade=module.max_score())
......@@ -257,13 +257,13 @@ def get_module(user, request, location, student_module_cache, position=None):
if not shared_module and shared_state_key is not None:
shared_module = StudentModule(
student=user,
module_type=descriptor.type,
module_type=descriptor.category,
module_state_key=shared_state_key,
state=module.get_shared_state())
shared_module.save()
student_module_cache.append(shared_module)
return (module, instance_module, shared_module, descriptor.type)
return (module, instance_module, shared_module, descriptor.category)
def add_histogram(module):
......
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