daranzolin / rcanvas

R Client for Canvas LMS API
Other
88 stars 43 forks source link

Uploading exams into Canvas #23

Open nelis73 opened 6 years ago

nelis73 commented 6 years ago

Hi David, I saw your rcanvas package, it looks great! Does it also allow for going the opposite way, uploading stuff into canvas? I am a contributor to the exams package, and am exploring how exams may be automatically generated for Canvas.

http://www.r-exams.org

Uploading an exam into Canvas from R would mean a great feature to people using the package.

daranzolin commented 6 years ago

Thanks Niels! Would this be a quiz object in Canvas? Or just a file to upload? We should be able to support both.

nelis73 commented 6 years ago

Hi David,

For now it would be a set of exercises in a standard test format (IMS qti based xml) created with the exams2blackboard() function. Now we get things working in Canvas by uploading the resulting zipfile manually in the menu for adding content and choosing "blackboard" as format for uploading quizzes. Once we learn more about Canvas, we may be able to create tests in Canvas' own format.

I cc Achim Zeileis to this reply; he is creator and maintainer of the package.

Best!

Niels Smits

Op 29 mrt. 2018 om 18:59 heeft David Ranzolin notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

Thanks Niels! Would this be a quiz object in Canvas?https://community.canvaslms.com/docs/DOC-10706-67952725251 Or just a file to upload? We should be able to support both.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/daranzolin/rcanvas/issues/23#issuecomment-377302313, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AgQpsT6JKflIL6stFshW86MUPm8cVtjKks5tjRL3gaJpZM4S__Ai.

statibk commented 6 years ago

Thanks, David!

Just to add to Niels' previous comments. Canvas can import quizzes from various flavors of QTI: https://community.canvaslms.com/docs/DOC-12683-4152724198

The R/exams package allows to create various of these formats: standard QTI 1.2, Blackboard-flavored QTI 1.2, standard QTI 2.1. We experimented a bit with these formats and had the best experiences so far with the Blackboard-flavored QTI 1.2. However, I would expect that the other two options may also be of interest - possibly after some fine-tuning.

So for the moment it would already be quite nice to have a two-step procedure: (1) creating a .zip file with one of the existing functions exams::exams2blackboard(), exams::exams2qti12(), or exams::exams2qti21() and (2) importing it into a Canvas quiz with some function in rcanvas.

This would make testing various options easier (e.g., the QTI flavor, the type of HTML converter, the way images or mathematical equations are embedded, etc.). And then when we have settled for a good set of defaults we could create a function exams2canvas() that calls one of the underlying exams2xyz() functions and optionally imports everything directly into Canvas.

Best wishes, Achim

nelis73 commented 5 years ago

Hi David,

I contacted you before about the R exams package.

Now I am using the functions you wrote for the rcanvas package as a basis for making new functions. I am trying to write a function with which all content of a given quiz for a given student may be downloaded. I looked how you used the httr package to get stuff from Canvas. Whereas it is easy to obtain groups or setions from canvas, it is somehow impossible to do a similar thing for quiz content. In Mozilla Firefox I used "inspect element" to inspect a GET call for getting sections and one for getting quiz content of a specific student. The details of these GET calls is in the attachment (I don't see obvious differences between the calls).

When I tried to perform similar GET calls from R only obtaining sections was successful; obtaining quiz content resulted in an html-file consisting of a login screen. Below I pasted the R code and outputs.

Do you have an idea what went wrong or how to go about to find a solution?

Hoping to hear from you!

Best,

Niels

GET("https://canvas.uva.nl/api/v1/", path = "courses/3272/sections", add_headers = httr::add_headers(Authorization = paste("Bearer", rcanvas:::check_token()))) Response [https://canvas.uva.nl/courses/3272/sections]   Date: 2018-10-05 09:11   Status: 404   Content-Type: text/html; charset=utf-8   Size: 17.8 kB

<!DOCTYPE html> <html class="scripts-not-loaded" dir="ltr"   lang="en-GB">

    Page Not Found         ... >  GET("https://canvas.uva.nl/api/v1/", path = "courses/3272/quizzes/8212/history", query = list(headless = 1, user_id = 6606, version = 1), add_headers = httr::add_headers(Authorization = paste("Bearer", rcanvas:::check_token()))) Response [https://login.canvas.uva.nl/?referrer=canvas.uva.nl]   Date: 2018-07-17 12:17   Status: 200   Content-Type: text/html   Size: 13.9 kB New request: GET: https://canvas.uva.nl/courses/3272/quizzes/8212/history?headless=1&user_id=6606&version=1 Querystring: headless=1 user_id=6606 version=1 Request headers: Host: canvas.uva.nl User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: nl,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate, br Cookie: _ga=GA1.2.1580752581.1505898386; co_ac=h; _csrf_token=em1%2BklNGOPMZ05w9Zvf7ccUIZbhxx3b55zMP6U5LETouGD%2F1KxRzwni%2Fqk4KkYsaol4CzSC0F6DRXkCMIQ1BCA%3D%3D; log_session_id=3078a3c6eaf8f603dba2f3a5f7df417e; canvas_session=pZMhfZ2niQJkKgYxnxzhBg+Iaw_xiTJjAzkDCP5Wrx5XvlJo0lzUBMWpx1cFOcGxR4Ulx8Fhgr88tu7eJazgqaxNbf13NgqEpncKGQZ0Lf1P9dYuDtVqFQKUFq8hj3gc4jd6MlofJ3FBCLeWqVfyj_RUDpcGg2olGRc0Rm-J_l46SUQgPgJAUFsyjhtpWF3_NysfI9QR85iSzQlXr6mJ-EwxEiuO3HIeF0YndOvOVpk1U9dFrC_4B7duIbb7oyk8WhysrfCkFmo4bvpSkYZgW8rqFHprVktG0nRplEvSv7qNdMHpKmGcGNkqEA1poipmfDQaA2rAXi0PHLM7v_M_OjUBcYIHRl21tMg27M5hAaYwi_oiKvclKlgM3wRQbp6kfDRD5QL9welETHs7dA2n5weaqvZZhnUkR6AyGFjFIs4x8F-1-vj3meBdpiiQeAfakA.TTa64ca8vZ_Fw-EY7QtLUdp1TRM.W7ZHAg Connection: keep-alive Upgrade-Insecure-Requests: 1 New request: GET: https://canvas.uva.nl/api/v1/courses/3272/sections Request headers: Host: canvas.uva.nl User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: nl,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate, br Cookie: _ga=GA1.2.1580752581.1505898386; co_ac=h; _csrf_token=molBq4BkYviYPuXuCHJpyb7quO4ITPAD%2F%2FmzEgZRlQDO%2FADM%2BDYpyflS051kFBmi2bzfm1k%2FkVrJlPx3aRfFMg%3D%3D; log_session_id=3078a3c6eaf8f603dba2f3a5f7df417e; canvas_session=BSY32ESM7FKvIQ29A7O-8A+eloIN8C01lGgSsP_FIo1BQNozYFYVG1w7vCLeS2STFqM5iLRewQAcXPunlzAjT6lVqsuUNJdlgt1lDgnY1L4aKP1PLao5ua5-PWNwBx488PZqo-aQCHgc96einvWnnXV_QcsNDru6K8wKMqyyf3L8ob9c-r155jvc1ExRBhK_D8t_nLVBNo-5kcHGY1pN4oAcxRJvRUyTYvKtdYfKs4uHitnY0PjXCXQWGrFpIoxTArtw1_OaA8zEicY_-yQjFHN7kVXWNQvSNnyfWk8dEuLVAF1Il2oHi-KtJIVntClsQLviCzuqIKstTIpIW1-KYTC3wxfNqoz9Rxpbi89yH__48MBOFyv0XgjOiTr57XrJk9s30iiqDMfTb3ybJC5mteJUA07muluhLgqSnV7MaiuuOWpH9cDNRLwdoaYomt6aWE.mV1Qb7n6BHXr1IbfB8b4E7_D2Oc.W7crfw Connection: keep-alive Upgrade-Insecure-Requests: 1 If-None-Match: W/"f3855c14ee21e6ff9668139b3bb27a03-gzip" Cache-Control: max-age=0
nelis73 commented 5 years ago

Hi David,

In addition to what I wrote earlier/below I should have said that I started writing this function because I did not get the get_submission_single working:

get_submission_single(course_id = 3272, type = "quizzes", type_id = 8212, user_id=6606) Error in canvas_query(url, args, "GET") : Not Found (HTTP 404).

Cheers!

Niels

I contacted you before about the R exams package.

Now I am using the functions you wrote for the rcanvas package as a basis for making new functions. I am trying to write a function with which all content of a given quiz for a given student may be downloaded. I looked how you used the httr package to get stuff from Canvas. Whereas it is easy to obtain groups or setions from canvas, it is somehow impossible to do a similar thing for quiz content. In Mozilla Firefox I used "inspect element" to inspect a GET call for getting sections and one for getting quiz content of a specific student. The details of these GET calls is in the attachment (I don't see obvious differences between the calls).

When I tried to perform similar GET calls from R only obtaining sections was successful; obtaining quiz content resulted in an html-file consisting of a login screen. Below I pasted the R code and outputs.

Do you have an idea what went wrong or how to go about to find a solution?

Hoping to hear from you!

Best,

Niels

  GET("https://canvas.uva.nl/api/v1/", path = "courses/3272/sections", add_headers = httr::add_headers(Authorization = paste("Bearer", rcanvas:::check_token()))) Response [https://canvas.uva.nl/courses/3272/sections]   Date: 2018-10-05 09:11   Status: 404   Content-Type: text/html; charset=utf-8   Size: 17.8 kB

<!DOCTYPE html> <html class="scripts-not-loaded" dir="ltr"   lang="en-GB">

    Page Not Found         ... >  GET("https://canvas.uva.nl/api/v1/", path = "courses/3272/quizzes/8212/history", query = list(headless = 1, user_id = 6606, version = 1), add_headers = httr::add_headers(Authorization = paste("Bearer", rcanvas:::check_token()))) Response [https://login.canvas.uva.nl/?referrer=canvas.uva.nl]   Date: 2018-07-17 12:17   Status: 200   Content-Type: text/html   Size: 13.9 kB New request: GET: https://canvas.uva.nl/courses/3272/quizzes/8212/history?headless=1&user_id=6606&version=1 Querystring: headless=1 user_id=6606 version=1 Request headers: Host: canvas.uva.nl User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: nl,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate, br Cookie: _ga=GA1.2.1580752581.1505898386; co_ac=h; _csrf_token=em1%2BklNGOPMZ05w9Zvf7ccUIZbhxx3b55zMP6U5LETouGD%2F1KxRzwni%2Fqk4KkYsaol4CzSC0F6DRXkCMIQ1BCA%3D%3D; log_session_id=3078a3c6eaf8f603dba2f3a5f7df417e; canvas_session=pZMhfZ2niQJkKgYxnxzhBg+Iaw_xiTJjAzkDCP5Wrx5XvlJo0lzUBMWpx1cFOcGxR4Ulx8Fhgr88tu7eJazgqaxNbf13NgqEpncKGQZ0Lf1P9dYuDtVqFQKUFq8hj3gc4jd6MlofJ3FBCLeWqVfyj_RUDpcGg2olGRc0Rm-J_l46SUQgPgJAUFsyjhtpWF3_NysfI9QR85iSzQlXr6mJ-EwxEiuO3HIeF0YndOvOVpk1U9dFrC_4B7duIbb7oyk8WhysrfCkFmo4bvpSkYZgW8rqFHprVktG0nRplEvSv7qNdMHpKmGcGNkqEA1poipmfDQaA2rAXi0PHLM7v_M_OjUBcYIHRl21tMg27M5hAaYwi_oiKvclKlgM3wRQbp6kfDRD5QL9welETHs7dA2n5weaqvZZhnUkR6AyGFjFIs4x8F-1-vj3meBdpiiQeAfakA.TTa64ca8vZ_Fw-EY7QtLUdp1TRM.W7ZHAg Connection: keep-alive Upgrade-Insecure-Requests: 1 New request: GET: https://canvas.uva.nl/api/v1/courses/3272/sections Request headers: Host: canvas.uva.nl User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: nl,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate, br Cookie: _ga=GA1.2.1580752581.1505898386; co_ac=h; _csrf_token=molBq4BkYviYPuXuCHJpyb7quO4ITPAD%2F%2FmzEgZRlQDO%2FADM%2BDYpyflS051kFBmi2bzfm1k%2FkVrJlPx3aRfFMg%3D%3D; log_session_id=3078a3c6eaf8f603dba2f3a5f7df417e; canvas_session=BSY32ESM7FKvIQ29A7O-8A+eloIN8C01lGgSsP_FIo1BQNozYFYVG1w7vCLeS2STFqM5iLRewQAcXPunlzAjT6lVqsuUNJdlgt1lDgnY1L4aKP1PLao5ua5-PWNwBx488PZqo-aQCHgc96einvWnnXV_QcsNDru6K8wKMqyyf3L8ob9c-r155jvc1ExRBhK_D8t_nLVBNo-5kcHGY1pN4oAcxRJvRUyTYvKtdYfKs4uHitnY0PjXCXQWGrFpIoxTArtw1_OaA8zEicY_-yQjFHN7kVXWNQvSNnyfWk8dEuLVAF1Il2oHi-KtJIVntClsQLviCzuqIKstTIpIW1-KYTC3wxfNqoz9Rxpbi89yH__48MBOFyv0XgjOiTr57XrJk9s30iiqDMfTb3ybJC5mteJUA07muluhLgqSnV7MaiuuOWpH9cDNRLwdoaYomt6aWE.mV1Qb7n6BHXr1IbfB8b4E7_D2Oc.W7crfw Connection: keep-alive Upgrade-Insecure-Requests: 1 If-None-Match: W/"f3855c14ee21e6ff9668139b3bb27a03-gzip" Cache-Control: max-age=0
daranzolin commented 5 years ago

Hi @nelis73--I'll take a closer look at this sometime this week. Apologies!