def __init__(self, system, location, descriptor, model_data): XModule.__init__(self, system, location, descriptor, model_data) # We need to set the location here so the child modules can use it system.set('location', location) self.system = system if (self.system.open_ended_grading_interface): self.peer_gs = PeerGradingService( self.system.open_ended_grading_interface, self.system) else: self.peer_gs = MockPeerGradingService() if self.use_for_single_location: try: self.linked_problem = modulestore().get_instance( self.system.course_id, self.link_to_location) except: log.error( "Linked location {0} for peer grading module {1} does not exist" .format(self.link_to_location, self.location)) raise due_date = self.linked_problem._model_data.get( 'peer_grading_due', None) if due_date: self._model_data['due'] = due_date try: self.timeinfo = TimeInfo(self.due_date, self.grace_period_string) except: log.error( "Error parsing due date information in location {0}".format( location)) raise self.display_due_date = self.timeinfo.display_due_date try: self.student_data_for_location = json.loads( self.student_data_for_location) except: pass self.ajax_url = self.system.ajax_url if not self.ajax_url.endswith("/"): self.ajax_url = self.ajax_url + "/" # Integer could return None, so keep this check. if not isinstance(self.max_grade, int): raise TypeError("max_grade needs to be an integer.")
def __init__(self, *args, **kwargs): super(PeerGradingModule, self).__init__(*args, **kwargs) # Copy this to a new variable so that we can edit it if needed. # We need to edit it if the linked module cannot be found, so # we can revert to panel model. self.use_for_single_location_local = self.use_for_single_location # We need to set the location here so the child modules can use it. self.runtime.set('location', self.location) if (self.runtime.open_ended_grading_interface): self.peer_gs = PeerGradingService( self.system.open_ended_grading_interface, self.system) else: self.peer_gs = MockPeerGradingService() if self.use_for_single_location_local: linked_descriptors = self.descriptor.get_required_module_descriptors( ) if len(linked_descriptors) == 0: error_msg = "Peer grading module {0} is trying to use single problem mode without " "a location specified.".format(self.location) log.error(error_msg) # Change module over to panel mode from single problem mode. self.use_for_single_location_local = False else: self.linked_problem = self.system.get_module( linked_descriptors[0]) try: self.timeinfo = TimeInfo(self.due, self.graceperiod) except Exception: log.error( "Error parsing due date information in location {0}".format( self.location)) raise self.display_due_date = self.timeinfo.display_due_date try: self.student_data_for_location = json.loads( self.student_data_for_location) except Exception: pass self.ajax_url = self.system.ajax_url if not self.ajax_url.endswith("/"): self.ajax_url = self.ajax_url + "/"
def __init__(self, *args, **kwargs): super(PeerGradingModule, self).__init__(*args, **kwargs) #We need to set the location here so the child modules can use it self.runtime.set('location', self.location) if (self.system.open_ended_grading_interface): self.peer_gs = PeerGradingService(self.system.open_ended_grading_interface, self.system) else: self.peer_gs = MockPeerGradingService() if self.use_for_single_location: try: linked_descriptors = self.descriptor.get_required_module_descriptors() if len(linked_descriptors) == 0: error_msg = "Peer grading module {0} is trying to use single problem mode without " "a location specified.".format(self.location) log.error(error_msg) raise InvalidLinkLocation(error_msg) self.linked_problem = self.system.get_module(linked_descriptors[0]) except ItemNotFoundError: log.error("Linked location {0} for peer grading module {1} does not exist".format( self.link_to_location, self.location)) raise except NoPathToItem: log.error("Linked location {0} for peer grading module {1} cannot be linked to.".format( self.link_to_location, self.location)) raise try: self.timeinfo = TimeInfo(self.due, self.graceperiod) except Exception: log.error("Error parsing due date information in location {0}".format(self.location)) raise self.display_due_date = self.timeinfo.display_due_date try: self.student_data_for_location = json.loads(self.student_data_for_location) except Exception: pass self.ajax_url = self.system.ajax_url if not self.ajax_url.endswith("/"): self.ajax_url = self.ajax_url + "/"
def __init__(self, *args, **kwargs): super(PeerGradingModule, self).__init__(*args, **kwargs) #We need to set the location here so the child modules can use it self.runtime.set('location', self.location) if (self.system.open_ended_grading_interface): self.peer_gs = PeerGradingService( self.system.open_ended_grading_interface, self.system) else: self.peer_gs = MockPeerGradingService() if self.use_for_single_location: try: self.linked_problem = modulestore().get_instance( self.system.course_id, self.link_to_location) except ItemNotFoundError: log.error( "Linked location {0} for peer grading module {1} does not exist" .format(self.link_to_location, self.location)) raise due_date = self.linked_problem._model_data.get('due', None) if due_date: self._model_data['due'] = due_date try: self.timeinfo = TimeInfo(self.due, self.grace_period_string) except Exception: log.error( "Error parsing due date information in location {0}".format( self.location)) raise self.display_due_date = self.timeinfo.display_due_date try: self.student_data_for_location = json.loads( self.student_data_for_location) except Exception: pass self.ajax_url = self.system.ajax_url if not self.ajax_url.endswith("/"): self.ajax_url = self.ajax_url + "/"
def __init__(self, system, location, definition, descriptor, instance_state=None, shared_state=None, metadata=None, static_data=None, **kwargs): """ Definition file should have one or many task blocks, a rubric block, and a prompt block. See DEFAULT_DATA in combined_open_ended_module for a sample. """ self.instance_state = instance_state self.display_name = instance_state.get('display_name', "Open Ended") # We need to set the location here so the child modules can use it system.set('location', location) self.system = system # Tells the system which xml definition to load self.current_task_number = instance_state.get('current_task_number', 0) # This loads the states of the individual children self.task_states = instance_state.get('task_states', []) #This gets any old task states that have been persisted after the instructor changed the tasks. self.old_task_states = instance_state.get('old_task_states', []) # Overall state of the combined open ended module self.state = instance_state.get('state', self.INITIAL) self.student_attempts = instance_state.get('student_attempts', 0) self.weight = instance_state.get('weight', 1) # Allow reset is true if student has failed the criteria to move to the next child task self.ready_to_reset = instance_state.get('ready_to_reset', False) self.max_attempts = instance_state.get('max_attempts', MAX_ATTEMPTS) self.is_scored = instance_state.get('graded', IS_SCORED) in TRUE_DICT self.accept_file_upload = instance_state.get('accept_file_upload', ACCEPT_FILE_UPLOAD) in TRUE_DICT self.skip_basic_checks = instance_state.get('skip_spelling_checks', SKIP_BASIC_CHECKS) in TRUE_DICT if system.open_ended_grading_interface: self.peer_gs = PeerGradingService(system.open_ended_grading_interface, system) else: self.peer_gs = MockPeerGradingService() self.required_peer_grading = instance_state.get('required_peer_grading', 3) self.peer_grader_count = instance_state.get('peer_grader_count', 3) self.min_to_calibrate = instance_state.get('min_to_calibrate', 3) self.max_to_calibrate = instance_state.get('max_to_calibrate', 6) self.peer_grade_finished_submissions_when_none_pending = instance_state.get( 'peer_grade_finished_submissions_when_none_pending', False ) due_date = instance_state.get('due', None) grace_period_string = instance_state.get('graceperiod', None) try: self.timeinfo = TimeInfo(due_date, grace_period_string) except Exception: log.error("Error parsing due date information in location {0}".format(location)) raise self.display_due_date = self.timeinfo.display_due_date self.rubric_renderer = CombinedOpenEndedRubric(system, True) rubric_string = stringify_children(definition['rubric']) self._max_score = self.rubric_renderer.check_if_rubric_is_parseable(rubric_string, location, MAX_SCORE_ALLOWED) # Static data is passed to the child modules to render self.static_data = { 'max_score': self._max_score, 'max_attempts': self.max_attempts, 'prompt': definition['prompt'], 'rubric': definition['rubric'], 'display_name': self.display_name, 'accept_file_upload': self.accept_file_upload, 'close_date': self.timeinfo.close_date, 's3_interface': self.system.s3_interface, 'skip_basic_checks': self.skip_basic_checks, 'control': { 'required_peer_grading': self.required_peer_grading, 'peer_grader_count': self.peer_grader_count, 'min_to_calibrate': self.min_to_calibrate, 'max_to_calibrate': self.max_to_calibrate, 'peer_grade_finished_submissions_when_none_pending': ( self.peer_grade_finished_submissions_when_none_pending ), } } self.task_xml = definition['task_xml'] self.location = location self.fix_invalid_state() self.setup_next_task()