get_peer_review_completion_analytics
Analyze peer review completion rates for Canvas assignments with student-by-student breakdown and summary statistics to track participation and identify students needing follow-up.
Instructions
Get detailed analytics on peer review completion rates with student-by-student breakdown and summary statistics.
Args:
course_identifier: Canvas course code (e.g., badm_554_120251_246794) or ID
assignment_id: Canvas assignment ID
include_student_details: Include per-student breakdown
group_by_status: Group students by completion status
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignment_id | Yes | ||
| course_identifier | Yes | ||
| group_by_status | No | ||
| include_student_details | No |
Implementation Reference
- The MCP tool handler function 'get_peer_review_completion_analytics'. It resolves the course ID, creates a PeerReviewAnalyzer instance, calls its get_completion_analytics method, and returns the JSON-formatted result or an error message.@mcp.tool() @validate_params async def get_peer_review_completion_analytics( course_identifier: str | int, assignment_id: str | int, include_student_details: bool = True, group_by_status: bool = True ) -> str: """Get detailed analytics on peer review completion rates with student-by-student breakdown and summary statistics. Args: course_identifier: Canvas course code (e.g., badm_554_120251_246794) or ID assignment_id: Canvas assignment ID include_student_details: Include per-student breakdown group_by_status: Group students by completion status """ try: course_id = await get_course_id(course_identifier) analyzer = PeerReviewAnalyzer() result = await analyzer.get_completion_analytics( course_id=course_id, assignment_id=int(assignment_id), include_student_details=include_student_details, group_by_status=group_by_status ) if "error" in result: return f"Error getting peer review completion analytics: {result['error']}" return json.dumps(result, indent=2) except Exception as e: return f"Error in get_peer_review_completion_analytics: {str(e)}"
- The core helper method in PeerReviewAnalyzer that implements the peer review completion analytics logic. Fetches assignments and users from Canvas API, computes per-student statistics, completion rates, groups by status, and generates summary statistics.async def get_completion_analytics( self, course_id: int, assignment_id: int, include_student_details: bool = True, group_by_status: bool = True ) -> dict[str, Any]: """Get detailed analytics on peer review completion rates.""" try: # Get the assignments data assignments_data = await self.get_assignments( course_id, assignment_id, include_names=True ) if "error" in assignments_data: return assignments_data assignments = assignments_data["assignments"] # Get all students in the course users_response = await fetch_all_paginated_results( f"/courses/{course_id}/users", {"enrollment_type[]": "student", "per_page": 100} ) if "error" in users_response: return {"error": f"Failed to get users: {users_response}"} students = users_response if isinstance(users_response, list) else [] # Calculate completion statistics reviewer_stats = {} total_assigned = len(assignments) total_completed = sum(1 for a in assignments if a["status"] == "completed") # Group assignments by reviewer for assignment in assignments: reviewer_id = assignment["reviewer_id"] if reviewer_id not in reviewer_stats: reviewer_stats[reviewer_id] = { "student_id": reviewer_id, "student_name": assignment.get("reviewer_name", "Unknown"), "assigned_count": 0, "completed_count": 0, "pending_reviews": [] } reviewer_stats[reviewer_id]["assigned_count"] += 1 if assignment["status"] == "completed": reviewer_stats[reviewer_id]["completed_count"] += 1 else: # Calculate days since assigned days_since_assigned = 0 if assignment.get("assigned_date"): try: assigned_date = datetime.datetime.fromisoformat( assignment["assigned_date"].replace("Z", "+00:00") ) days_since_assigned = (datetime.datetime.now(datetime.timezone.utc) - assigned_date).days except ValueError: days_since_assigned = 0 reviewer_stats[reviewer_id]["pending_reviews"].append({ "reviewee_id": assignment["reviewee_id"], "reviewee_name": assignment.get("reviewee_name", "Unknown"), "days_since_assigned": days_since_assigned }) # Calculate completion rates for stats in reviewer_stats.values(): if stats["assigned_count"] > 0: stats["completion_rate"] = (stats["completed_count"] / stats["assigned_count"]) * 100 else: stats["completion_rate"] = 0.0 # Group by completion status completion_groups: dict[str, list[Any]] = { "all_complete": [], "partial_complete": [], "none_complete": [] } if group_by_status: for stats in reviewer_stats.values(): if stats["completion_rate"] == 100.0: completion_groups["all_complete"].append(stats) elif stats["completion_rate"] == 0.0: completion_groups["none_complete"].append(stats) else: completion_groups["partial_complete"].append(stats) # Calculate summary statistics students_with_submissions = len([s for s in students if any( a["reviewee_id"] == s["id"] for a in assignments )]) completion_rate = (total_completed / total_assigned * 100) if total_assigned > 0 else 0 reviews_per_student = assignments_data["assignment_info"]["peer_review_settings"]["reviews_per_student"] summary = { "total_students_enrolled": len(students), "students_with_submissions": students_with_submissions, "total_reviews_assigned": total_assigned, "reviews_completed": total_completed, "completion_rate_percent": round(completion_rate, 1), "students_all_complete": len(completion_groups["all_complete"]), "students_partial_complete": len(completion_groups["partial_complete"]), "students_none_complete": len(completion_groups["none_complete"]), "average_reviews_per_student": reviews_per_student } result = {"summary": summary} if include_student_details: result["completion_groups"] = completion_groups return result except Exception as e: return {"error": f"Exception in get_completion_analytics: {str(e)}"}
- src/canvas_mcp/server.py:52-52 (registration)The call to register_peer_review_tools(mcp) in the main server setup, which defines and registers the get_peer_review_completion_analytics tool among other peer review tools.register_peer_review_tools(mcp)