Commit cb4a7c66 by Vik Paruchuri

A somewhat working state for notifications. Combined open ended and peer…

A somewhat working state for notifications.  Combined open ended and peer grading xmodules still have significant errors.
parent b5786874
......@@ -69,6 +69,7 @@ class CombinedOpenEndedModule(XModule):
due = String(help="Date that this problem is due by", default= None, scope=Scope.settings)
graceperiod = String(help="Amount of time after the due date that submissions will be accepted", default=None, scope=Scope.settings)
max_score = Integer(help="Maximum score for the problem.", default=1, scope=Scope.settings)
version = Integer(help="Current version number", default=DEFAULT_VERSION, scope=Scope.settings)
data = String(help="XML data for the problem", scope=Scope.content)
js = {'coffee': [resource_string(__name__, 'js/src/combinedopenended/display.coffee'),
......@@ -120,22 +121,6 @@ class CombinedOpenEndedModule(XModule):
self.system = system
self.system.set('location', location)
# Load instance state
if instance_state is not None:
instance_state = json.loads(instance_state)
else:
instance_state = {}
self.version = self.metadata.get('version', DEFAULT_VERSION)
version_error_string = "Version of combined open ended module {0} is not correct. Going with version {1}"
if not isinstance(self.version, basestring):
try:
self.version = str(self.version)
except:
#This is a dev_facing_error
log.info(version_error_string.format(self.version, DEFAULT_VERSION))
self.version = DEFAULT_VERSION
versions = [i[0] for i in VERSION_TUPLES]
descriptors = [i[1] for i in VERSION_TUPLES]
modules = [i[2] for i in VERSION_TUPLES]
......@@ -154,11 +139,10 @@ class CombinedOpenEndedModule(XModule):
}
instance_state = { k: self.__dict__[k] for k in self.__dict__ if k in attributes[version_index]}
log.debug(instance_state)
self.child_descriptor = descriptors[version_index](self.system)
self.child_definition = descriptors[version_index].definition_from_xml(etree.fromstring(self.data), self.system)
self.child_module = modules[version_index](self.system, location, self.child_definition, self.child_descriptor,
instance_state = json.dumps(instance_state), metadata = self.metadata, static_data= static_data)
instance_state = instance_state, static_data= static_data)
def get_html(self):
return self.child_module.get_html()
......
......@@ -115,17 +115,10 @@ class CombinedOpenEndedV1Module():
"""
self.metadata = metadata
self.display_name = metadata.get('display_name', "Open Ended")
self.instance_state = instance_state
self.display_name = instance_state.get('display_name', "Open Ended")
self.rewrite_content_links = static_data.get('rewrite_content_links',"")
# Load instance state
if instance_state is not None:
instance_state = json.loads(instance_state)
else:
instance_state = {}
#We need to set the location here so the child modules can use it
system.set('location', location)
self.system = system
......@@ -141,14 +134,14 @@ class CombinedOpenEndedV1Module():
#Allow reset is true if student has failed the criteria to move to the next child task
self.allow_reset = instance_state.get('ready_to_reset', False)
self.max_attempts = int(self.metadata.get('attempts', MAX_ATTEMPTS))
self.is_scored = self.metadata.get('is_graded', IS_SCORED) in TRUE_DICT
self.accept_file_upload = self.metadata.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT
self.skip_basic_checks = self.metadata.get('skip_spelling_checks', SKIP_BASIC_CHECKS)
self.max_attempts = int(self.instance_state.get('attempts', MAX_ATTEMPTS))
self.is_scored = self.instance_state.get('is_graded', IS_SCORED) in TRUE_DICT
self.accept_file_upload = self.instance_state.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT
self.skip_basic_checks = self.instance_state.get('skip_spelling_checks', SKIP_BASIC_CHECKS)
display_due_date_string = self.metadata.get('due', None)
display_due_date_string = self.instance_state.get('due', None)
grace_period_string = self.metadata.get('graceperiod', None)
grace_period_string = self.instance_state.get('graceperiod', None)
try:
self.timeinfo = TimeInfo(display_due_date_string, grace_period_string)
except:
......@@ -158,7 +151,7 @@ class CombinedOpenEndedV1Module():
# Used for progress / grading. Currently get credit just for
# completion (doesn't matter if you self-assessed correct/incorrect).
self._max_score = int(self.metadata.get('max_score', MAX_SCORE))
self._max_score = int(self.instance_state.get('max_score', MAX_SCORE))
self.rubric_renderer = CombinedOpenEndedRubric(system, True)
rubric_string = stringify_children(definition['rubric'])
......@@ -760,7 +753,7 @@ class CombinedOpenEndedV1Module():
return progress_object
class CombinedOpenEndedV1Descriptor(XmlDescriptor, EditingDescriptor):
class CombinedOpenEndedV1Descriptor():
"""
Module for adding combined open ended questions
"""
......@@ -772,6 +765,9 @@ class CombinedOpenEndedV1Descriptor(XmlDescriptor, EditingDescriptor):
has_score = True
template_dir_name = "combinedopenended"
def __init__(self, system):
self.system =system
@classmethod
def definition_from_xml(cls, xml_object, system):
"""
......@@ -798,7 +794,7 @@ class CombinedOpenEndedV1Descriptor(XmlDescriptor, EditingDescriptor):
"""Assumes that xml_object has child k"""
return xml_object.xpath(k)[0]
return {'task_xml': parse_task('task'), 'prompt': parse('prompt'), 'rubric': parse('rubric')}, []
return {'task_xml': parse_task('task'), 'prompt': parse('prompt'), 'rubric': parse('rubric')}
def definition_to_xml(self, resource_fs):
......
......@@ -696,7 +696,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
return html
class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor):
class OpenEndedDescriptor():
"""
Module for adding open ended response questions to courses
"""
......@@ -708,6 +708,9 @@ class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor):
has_score = True
template_dir_name = "openended"
def __init__(self, system):
self.system =system
@classmethod
def definition_from_xml(cls, xml_object, system):
"""
......@@ -727,7 +730,7 @@ class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor):
"""Assumes that xml_object has child k"""
return xml_object.xpath(k)[0]
return {'oeparam': parse('openendedparam')}, []
return {'oeparam': parse('openendedparam')}
def definition_to_xml(self, resource_fs):
......
......@@ -299,7 +299,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
return [rubric_scores]
class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
class SelfAssessmentDescriptor():
"""
Module for adding self assessment questions to courses
"""
......@@ -311,6 +311,9 @@ class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
has_score = True
template_dir_name = "selfassessment"
def __init__(self, system):
self.system =system
@classmethod
def definition_from_xml(cls, xml_object, system):
"""
......
......@@ -58,9 +58,6 @@ class PeerGradingModule(XModule):
else:
self.peer_gs = MockPeerGradingService()
if isinstance(self.use_for_single_location, basestring):
self.use_for_single_location = (self.use_for_single_location in TRUE_DICT)
if self.use_for_single_location == True:
try:
self.linked_problem = modulestore().get_instance(self.system.course_id, self.link_to_location)
......@@ -72,9 +69,6 @@ class PeerGradingModule(XModule):
if due_date:
self.metadata['due'] = due_date
if isinstance(self.is_graded, basestring):
self.is_graded = (self.is_graded in TRUE_DICT)
try:
self.timeinfo = TimeInfo(self.display_due_date_string, self.grace_period_string)
except:
......
......@@ -59,7 +59,14 @@ def staff_grading_notifications(course, user):
def peer_grading_notifications(course, user):
system = ModuleSystem(None, None, None, render_to_string, None)
system = ModuleSystem(
ajax_url=None,
track_function=None,
get_module = None,
render_template=render_to_string,
replace_urls=None,
xblock_model_data= {}
)
peer_gs = peer_grading_service.PeerGradingService(settings.OPEN_ENDED_GRADING_INTERFACE, system)
pending_grading = False
img_path = ""
......@@ -93,7 +100,14 @@ def peer_grading_notifications(course, user):
def combined_notifications(course, user):
system = ModuleSystem(None, None, None, render_to_string, None)
system = ModuleSystem(
ajax_url=None,
track_function=None,
get_module = None,
render_template=render_to_string,
replace_urls=None,
xblock_model_data= {}
)
controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE, system)
student_id = unique_id_for_user(user)
user_is_staff = has_access(user, course, 'staff')
......
......@@ -60,7 +60,14 @@ class StaffGradingService(GradingService):
Interface to staff grading backend.
"""
def __init__(self, config):
config['system'] = ModuleSystem(None, None, None, render_to_string, None)
config['system'] = ModuleSystem(
ajax_url=None,
track_function=None,
get_module = None,
render_template=render_to_string,
replace_urls=None,
xblock_model_data= {}
)
super(StaffGradingService, self).__init__(config)
self.url = config['url'] + config['staff_grading']
self.login_url = self.url + '/login/'
......
......@@ -145,15 +145,21 @@ class TestPeerGradingService(ct.PageLoader):
self.course_id = "edX/toy/2012_Fall"
self.toy = modulestore().get_course(self.course_id)
location = "i4x://edX/toy/peergrading/init"
model_data = {}
model_data = {'data' : "<peergrading/>"}
self.mock_service = peer_grading_service.MockPeerGradingService()
self.system = ModuleSystem(location, None, None, render_to_string, None, model_data,
self.system = ModuleSystem(
ajax_url=location,
track_function=None,
get_module = None,
render_template=render_to_string,
replace_urls=None,
xblock_model_data= {},
s3_interface = test_util_open_ended.S3_INTERFACE,
open_ended_grading_interface=test_util_open_ended.OPEN_ENDED_GRADING_INTERFACE
)
self.descriptor = peer_grading_module.PeerGradingDescriptor(self.system, location, model_data)
model_data = {}
self.peer_module = peer_grading_module.PeerGradingModule(self.system, location, "<peergrading/>", self.descriptor, model_data)
self.peer_module = peer_grading_module.PeerGradingModule(self.system, location, self.descriptor, model_data)
self.peer_module.peer_gs = self.mock_service
self.logout()
......
......@@ -29,7 +29,14 @@ log = logging.getLogger(__name__)
template_imports = {'urllib': urllib}
system = ModuleSystem(None, None, None, render_to_string, None, None)
system = ModuleSystem(
ajax_url=None,
track_function=None,
get_module = None,
render_template=render_to_string,
replace_urls = None,
xblock_model_data= {}
)
controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE, system)
"""
......
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