当前位置: 首页>>代码示例>>Python>>正文


Python MockPeerGradingService.get_data_for_location方法代码示例

本文整理汇总了Python中xmodule.open_ended_grading_classes.peer_grading_service.MockPeerGradingService.get_data_for_location方法的典型用法代码示例。如果您正苦于以下问题:Python MockPeerGradingService.get_data_for_location方法的具体用法?Python MockPeerGradingService.get_data_for_location怎么用?Python MockPeerGradingService.get_data_for_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmodule.open_ended_grading_classes.peer_grading_service.MockPeerGradingService的用法示例。


在下文中一共展示了MockPeerGradingService.get_data_for_location方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PeerGradingModule

# 需要导入模块: from xmodule.open_ended_grading_classes.peer_grading_service import MockPeerGradingService [as 别名]
# 或者: from xmodule.open_ended_grading_classes.peer_grading_service.MockPeerGradingService import get_data_for_location [as 别名]

#.........这里部分代码省略.........
            return self.peer_grading_problem({"location": self.link_to_location})["html"]

    def handle_ajax(self, dispatch, get):
        """
        Needs to be implemented by child modules.  Handles AJAX events.
        @return:
        """
        handlers = {
            "get_next_submission": self.get_next_submission,
            "show_calibration_essay": self.show_calibration_essay,
            "is_student_calibrated": self.is_student_calibrated,
            "save_grade": self.save_grade,
            "save_calibration_essay": self.save_calibration_essay,
            "problem": self.peer_grading_problem,
        }

        if dispatch not in handlers:
            # This is a dev_facing_error
            log.error("Cannot find {0} in handlers in handle_ajax function for open_ended_module.py".format(dispatch))
            # This is a dev_facing_error
            return json.dumps({"error": "Error handling action.  Please try again.", "success": False})

        d = handlers[dispatch](get)

        return json.dumps(d, cls=ComplexEncoder)

    def query_data_for_location(self):
        student_id = self.system.anonymous_student_id
        location = self.link_to_location
        success = False
        response = {}

        try:
            response = self.peer_gs.get_data_for_location(location, student_id)
            count_graded = response["count_graded"]
            count_required = response["count_required"]
            success = True
        except GradingServiceError:
            # This is a dev_facing_error
            log.exception(
                "Error getting location data from controller for location {0}, student {1}".format(location, student_id)
            )

        return success, response

    def get_progress(self):
        pass

    def get_score(self):
        max_score = None
        score = None
        score_dict = {"score": score, "total": max_score}
        if self.use_for_single_location not in TRUE_DICT or self.is_graded not in TRUE_DICT:
            return score_dict

        try:
            count_graded = self.student_data_for_location["count_graded"]
            count_required = self.student_data_for_location["count_required"]
        except:
            success, response = self.query_data_for_location()
            if not success:
                log.exception(
                    "No instance data found and could not get data from controller for loc {0} student {1}".format(
                        self.system.location.url(), self.system.anonymous_student_id
                    )
                )
开发者ID:hanwentao,项目名称:edx-platform,代码行数:70,代码来源:peer_grading_module.py

示例2: PeerGradingModule

# 需要导入模块: from xmodule.open_ended_grading_classes.peer_grading_service import MockPeerGradingService [as 别名]
# 或者: from xmodule.open_ended_grading_classes.peer_grading_service.MockPeerGradingService import get_data_for_location [as 别名]

#.........这里部分代码省略.........
        else:
            return self.peer_grading_problem({'location': self.link_to_location})['html']

    def handle_ajax(self, dispatch, data):
        """
        Needs to be implemented by child modules.  Handles AJAX events.
        @return:
        """
        handlers = {
            'get_next_submission': self.get_next_submission,
            'show_calibration_essay': self.show_calibration_essay,
            'is_student_calibrated': self.is_student_calibrated,
            'save_grade': self.save_grade,
            'save_calibration_essay': self.save_calibration_essay,
            'problem': self.peer_grading_problem,
        }

        if dispatch not in handlers:
            # This is a dev_facing_error
            log.error("Cannot find {0} in handlers in handle_ajax function for open_ended_module.py".format(dispatch))
            # This is a dev_facing_error
            return json.dumps({'error': 'Error handling action.  Please try again.', 'success': False})

        d = handlers[dispatch](data)

        return json.dumps(d, cls=ComplexEncoder)

    def query_data_for_location(self, location):
        student_id = self.system.anonymous_student_id
        success = False
        response = {}

        try:
            response = self.peer_gs.get_data_for_location(location, student_id)
            count_graded = response['count_graded']
            count_required = response['count_required']
            success = True
        except GradingServiceError:
            # This is a dev_facing_error
            log.exception("Error getting location data from controller for location {0}, student {1}"
            .format(location, student_id))

        return success, response

    def get_progress(self):
        pass

    def get_score(self):
        max_score = None
        score = None
        weight = self.weight

        #The old default was None, so set to 1 if it is the old default weight
        if weight is None:
            weight = 1
        score_dict = {
            'score': score,
            'total': max_score,
        }
        if not self.use_for_single_location_local or not self.graded:
            return score_dict

        try:
            count_graded = self.student_data_for_location['count_graded']
            count_required = self.student_data_for_location['count_required']
        except:
开发者ID:Bachmann1234,项目名称:edx-platform,代码行数:70,代码来源:peer_grading_module.py

示例3: CombinedOpenEndedV1Module

# 需要导入模块: from xmodule.open_ended_grading_classes.peer_grading_service import MockPeerGradingService [as 别名]
# 或者: from xmodule.open_ended_grading_classes.peer_grading_service.MockPeerGradingService import get_data_for_location [as 别名]

#.........这里部分代码省略.........
                    self.state = self.DONE
                    self.current_task_number = len(self.task_xml) - 1
                else:
                    self.state = self.INITIAL
                changed = True
                self.setup_next_task()
        return changed

    def update_task_states_ajax(self, return_html):
        """
        Runs the update task states function for ajax calls.  Currently the same as update_task_states
        Input: The html returned by the handle_ajax function of the child
        Output: New html that should be rendered
        """
        changed = self.update_task_states()
        if changed:
            pass
        return return_html

    def check_if_student_has_done_needed_grading(self):
        """
        Checks with the ORA server to see if the student has completed the needed peer grading to be shown their grade.
        For example, if a student submits one response, and three peers grade their response, the student
        cannot see their grades and feedback unless they reciprocate.
        Output:
        success - boolean indicator of success
        allowed_to_submit - boolean indicator of whether student has done their needed grading or not
        error_message - If not success, explains why
        """
        student_id = self.system.anonymous_student_id
        success = False
        allowed_to_submit = True
        try:
            response = self.peer_gs.get_data_for_location(self.location.url(), student_id)
            count_graded = response['count_graded']
            count_required = response['count_required']
            student_sub_count = response['student_sub_count']
            count_available = response['count_available']
            success = True
        except GradingServiceError:
            # This is a dev_facing_error
            log.error("Could not contact external open ended graders for location {0} and student {1}".format(
                self.location, student_id))
            # This is a student_facing_error
            error_message = "Could not contact the graders.  Please notify course staff."
            return success, allowed_to_submit, error_message
        except KeyError:
            log.error("Invalid response from grading server for location {0} and student {1}".format(self.location, student_id))
            error_message = "Received invalid response from the graders.  Please notify course staff."
            return success, allowed_to_submit, error_message
        if count_graded >= count_required or count_available==0:
            error_message = ""
            return success, allowed_to_submit, error_message
        else:
            allowed_to_submit = False
            # This is a student_facing_error
            error_string = ("<h4>Feedback not available yet</h4>"
                            "<p>You need to peer grade {0} more submissions in order to see your feedback.</p>"
                            "<p>You have graded responses from {1} students, and {2} students have graded your submissions. </p>"
                            "<p>You have made {3} submissions.</p>")
            error_message = error_string.format(count_required - count_graded, count_graded, count_required,
                                                student_sub_count)
            return success, allowed_to_submit, error_message

    def get_rubric(self, _data):
        """
开发者ID:6thfdwp,项目名称:edx-platform,代码行数:70,代码来源:combined_open_ended_modulev1.py


注:本文中的xmodule.open_ended_grading_classes.peer_grading_service.MockPeerGradingService.get_data_for_location方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。