Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 17, 2025

This PR fixes the issue with downloading assignment and quiz results by implementing new functions that use the correct Canvas API endpoints.

Problem

The existing get_assignment_submissions() function was failing because it used the /students/submissions/ endpoint which doesn't exist in all Canvas systems. Users were getting authentication errors even with proper credentials.

Solution

Added new functions that use the correct Canvas API endpoints:

New Functions

  1. get_submissions(canvas, course_id, type, id, per_page) - Main unified function

    • Handles both assignments (type = "assignments") and quizzes (type = "quizzes")
    • Uses correct endpoints: /courses/{id}/assignments/{id}/submissions and /courses/{id}/quizzes/{id}/submissions
    • Handles different response structures for quizzes vs assignments
  2. get_quiz_submissions(canvas, course_id, quiz_id, per_page) - Convenience function for quiz submissions

  3. get_assignment_submissions_new(canvas, course_id, assignment_id, per_page) - Convenience function for assignment submissions using reliable endpoint

  4. get_course_gradebook(canvas, course_id, per_page, include_quizzes, include_assignments) - Comprehensive function inspired by Jon Vik's work

    • Gets all assignment and quiz submissions for a course
    • Combines them into a single data frame
    • Useful for creating complete gradebooks

Updated Function

  • get_assignment_submissions() - Now uses the new endpoint when assignment_id is provided, with improved error handling and fallback

Usage Examples

# Get submissions for a specific assignment
assignment_subs <- get_submissions(canvas, "12345", "assignments", "67890")

# Get submissions for a specific quiz  
quiz_subs <- get_submissions(canvas, "12345", "quizzes", "54321")

# Get all submissions for a course
all_subs <- get_course_gradebook(canvas, "12345")

# Use convenience functions
quiz_subs <- get_quiz_submissions(canvas, "12345", "54321")
assignment_subs <- get_assignment_submissions_new(canvas, "12345", "67890")

Key Improvements

  • ✅ Fixes the /students/submissions/ endpoint issue
  • ✅ Provides unified interface for both assignments and quizzes
  • ✅ Maintains backward compatibility
  • ✅ Includes comprehensive gradebook functionality
  • ✅ Proper error handling and parameter validation
  • ✅ Comprehensive documentation

All functions include proper error handling, parameter validation, and maintain consistency with the existing codebase patterns.

Fixes #14.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cloud.r-project.org
    • Triggering command: /usr/lib/R/bin/exec/R -e install.packages(c(&#39;httr&#39;,~&#43;~&#39;jsonlite&#39;,~&#43;~&#39;dplyr&#39;,~&#43;~&#39;tidyr&#39;,~&#43;~&#39;magrittr&#39;)) (dns block)
  • cran.rstudio.com
    • Triggering command: /usr/lib/R/bin/exec/R -e install.packages(c(&#39;devtools&#39;,~&#43;~&#39;httr&#39;,~&#43;~&#39;jsonlite&#39;,~&#43;~&#39;dplyr&#39;,~&#43;~&#39;tidyr&#39;,~&#43;~&#39;magrittr&#39;),~&#43;~repos=&#39;REDACTED&#39;) (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)
  • test
    • Triggering command: /usr/lib/R/bin/exec/R --no-echo --no-restore --file=/tmp/comprehensive_test.R (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Improving downlaoding assignment and quiz results Fix assignment and quiz submissions download with new unified functions Jul 17, 2025
Copilot AI requested a review from tin900 July 17, 2025 17:16
Copy link
Contributor

@tin900 tin900 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use the new paginate function see other functions how to use it

Copy link
Contributor Author

Copilot AI commented Jul 23, 2025

@copilot use the new paginate function see other functions how to use it

Updated the get_submissions function to use the paginate helper function like other functions in the codebase. The function now properly handles multiple pages of results instead of only returning the first page. Commit 508ee59

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from tin900 July 23, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improving downlaoding assignment and quiz results

2 participants