def get_rubric_max_scores(submission_uuid): """Gets the maximum possible value for each criterion option Iterates over the rubric used to grade the given submission, and creates a dictionary of maximum possible values. Args: submission_uuid: The submission to get the associated rubric max scores. Returns: A dictionary of max scores for this rubric's criteria options. Returns None if no assessments are found for this submission. Raises: PeerAssessmentInternalError: Raised when there is an error retrieving the submission, or its associated rubric. """ try: assessments = list( Assessment.objects.filter( submission_uuid=submission_uuid).order_by( "-scored_at", "-id").select_related("rubric")[:1]) if not assessments: return None assessment = assessments[0] rubric_dict = RubricSerializer.serialized_from_cache(assessment.rubric) return { criterion["name"]: criterion["points_possible"] for criterion in rubric_dict["criteria"] } except DatabaseError: error_message = ( u"Error getting rubric options max scores for submission uuid {uuid}" ).format(uuid=submission_uuid) logger.exception(error_message) raise PeerAssessmentInternalError(error_message)
def get_rubric_max_scores(submission_uuid): """Gets the maximum possible value for each criterion option Iterates over the rubric used to grade the given submission, and creates a dictionary of maximum possible values. Args: submission_uuid: The submission to get the associated rubric max scores. Returns: A dictionary of max scores for this rubric's criteria options. Returns None if no assessments are found for this submission. Raises: PeerAssessmentInternalError: Raised when there is an error retrieving the submission, or its associated rubric. """ try: assessments = list( Assessment.objects.filter(submission_uuid=submission_uuid) .order_by("-scored_at", "-id") .select_related("rubric")[:1] ) if not assessments: return None assessment = assessments[0] rubric_dict = RubricSerializer.serialized_from_cache(assessment.rubric) return {criterion["name"]: criterion["points_possible"] for criterion in rubric_dict["criteria"]} except DatabaseError: error_message = (u"Error getting rubric options max scores for submission uuid {uuid}").format( uuid=submission_uuid ) logger.exception(error_message) raise PeerAssessmentInternalError(error_message)
def criteria_summary(self, rubric_obj): """Short description of criteria for presenting in a list.""" rubric_data = RubricSerializer.serialized_from_cache(rubric_obj) return u", ".join( u"{} - {}: {}".format(criterion["name"], criterion['label'], criterion["points_possible"]) for criterion in rubric_data["criteria"])
def criteria_summary(self, rubric_obj): """Short description of criteria for presenting in a list.""" rubric_data = RubricSerializer.serialized_from_cache(rubric_obj) return u", ".join( u"{}: {}".format(criterion["name"], criterion["points_possible"]) for criterion in rubric_data["criteria"] )
def data(self, rubric_obj): """Full JSON string of rubric, indented and HTML formatted.""" rubric_data = RubricSerializer.serialized_from_cache(rubric_obj) return u"<pre>\n{}\n</pre>".format( html.escape(json.dumps(rubric_data, sort_keys=True, indent=4)))
def data(self, rubric_obj): """Full JSON string of rubric, indented and HTML formatted.""" rubric_data = RubricSerializer.serialized_from_cache(rubric_obj) return u"<pre>\n{}\n</pre>".format( html.escape(json.dumps(rubric_data, sort_keys=True, indent=4)) )