WeBWorK Main Forum

error during LTI reporting of grade back to Canvas

error during LTI reporting of grade back to Canvas

by Larry Riddle -
Number of replies: 12

I have been helping a professor set up a summer course in WeBWorK (ver 2.14) with LTI authorization from Canvas. I have been enrolled as a student in his Canvas course. The LTI authorization works fine and I can access a problem set in Canvas. Everything was working fine until a few days ago. When grading a problem, I started getting this error message:

Can't use string ("{"errors":[{"message":"Duplicate"...) as a HASH ref while "strict refs" in use at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 193.

WeBWorK  correctly grades the problem because I can see the score in the WeBWorK gradebook, but is unable to report the grade back to Canvas.

Sometimes if I graded the problem again, the error would not appear and the grade would show up in Canvas. But now I am getting the error message every time I try to grade a problem.

The $LTIGradeMode is set to "homework". If I set $LTIGradeOnSubmit = 0  I do not get the error. But if I reset $LTIGradeOnSubmit back to 1, the error starts appearing again.

I looked at line 193 in the SubmitGrade.pm file, but did not see anything helpful that I understood. I tried setting $debug_lti_parameters to 1, but that did not give any additional information about this error.

Any suggestions on what might be happening and how I might fix that?

Here is the entire message after clicking on the grade button:

Error messages

Can't use string ("{"errors":[{"message":"Duplicate"...) as a HASH ref while "strict refs" in use at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 193.

Call stack

The information below can help locate the source of the problem.

  • in WeBWorK::Authen::LTIAdvanced::SubmitGrade::local_escape_html called at line 339 of /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm
  • in WeBWorK::Authen::LTIAdvanced::SubmitGrade::submit_grade called at line 182 of /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm
  • in WeBWorK::Authen::LTIAdvanced::SubmitGrade::submit_set_grade called at line 286 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/ProblemUtil/ProblemUtil.pm
  • in WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::process_and_log_answer called at line 775 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm
  • in WeBWorK::ContentGenerator::Problem::pre_header_initialize called at line 213 of /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm
  • in WeBWorK::ContentGenerator::go called at line 384 of /opt/webwork/webwork2/lib/WeBWorK.pm

Request information

MethodPOST
URI/webwork2/Math115_SU20/01/1/
HTTP Headers
CookieWeBWorKCourseAuthen.Math118_S20=admin%095nQhTPoJNiPAs7EyVQP44Z0SkVHHIfTW%091589307784; WeBWorKCourseAuthen.admin=admin%09rQYny24hSvoTZGuTL2gqUOt6C5MPD9Jj%091589579440; WeBWorKCourseAuthen.Math115_SU20=lriddle%09P08nC1BOWZw13GrummD5wNPjGCPipShU%091589731028; __utma=87823112.1332950099.1578770092.1589333072.1589386958.50; __utmz=87823112.1588983656.46.6.utmcsr=agnesscott.instructure.com|utmccn=(referral)|utmcmd=referral|utmcct=/courses/1596/modules/items/26432; _ga=GA1.2.1332950099.1578770092; sc_is_visitor_unique=rx1467224.1588523365.5C563BBAA4DC4F405B280941EA2DE239.13.12.12.12.11.11.10.9.7; _gcl_au=1.1.1350478361.1588524171; __utmc=87823112
Accept-Languageen-US,en;q=0.5
Originhttp://webwork.agnesscott.edu
Content-Length1443
Upgrade-Insecure-Requests1
Connectionkeep-alive
Content-Typemultipart/form-data; boundary=---------------------------294926704011688786814184246142
User-AgentMozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:76.0) Gecko/20100101 Firefox/76.0
DNT1
Refererhttp://webwork.agnesscott.edu/webwork2/Math115_SU20/01/1/?effectiveUser=lriddle&user=lriddle&key=P08nC1BOWZw13GrummD5wNPjGCPipShU
Hostwebwork.agnesscott.edu
Accept-Encodinggzip, deflate
Accepttext/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

In reply to Larry Riddle

Re: error during LTI reporting of grade back to Canvas

by Nathan Wallach -
I took a very quick look and am making a wild guess... 

I suspect that your Canvas installation is now checking that the "nonce" used for LTI grade-passback is not being reused and that WeBWorK's code at present is not good enough at preventing that from happening. From what I see, the nonce use by WW is set by 
                    nonce => int(rand( 2**32)),
and this is apparently not "good enough" to avoid reuse too quickly. 

From some quick reading, it seems that the OAuth 2 protocol requires nonces not be reused for far longer than was required in OAuth 1.

My guess is that a better method of generating the nonce would solve the problem. I have some ideas, and will try to post a proposed change sometime next week.

References: 
In reply to Larry Riddle

Re: error during LTI reporting of grade back to Canvas

by Nathan Wallach -

I am attaching a version of SubmitGrade.pm which has modified code to set the nonce used.

It uses UUID::Tiny to generate a unique ID string. One portion depends on the "sourcedid" which is unique for each student+score which can be passed back to the LMS. A second portion depends on the time.

This version does a 2 round process to try to avoid sending the LMS an updated grade when there is an old grade and the change is less than  0.001.

I did a very small test with Moodle and a development WW server, and with this modified version Moodle is still getting grade passback, so at least for Moodle it does not break anything.

Hopefully, the improved nonces will solve your problem with Canvas.

Please report back if you do try some version of these changes out.

You may want to try just using the modified nonce generation and not the 2 round process. If so - you should be able to find the changes made, here is a summary:

  1. Add "use UUID::Tiny  ':std';" at the top of the file.
  2. The lines below were added before definition of $gradeRequest to create the new nonce string.
  3. Set "nonce => "${uuid_p1}__${uuid_p2}"," in $gradeRequest instead of using "nonce => int(rand( 2**32)),"

  Lines added:

  •   # Generate a better nonce, first a portion unique for the sourcedid
  •   # which should be dependent on the student + the assignment if a
  •   # "homework" level sourcedid.
  •   my $uuid_p1 = create_uuid_as_string(UUID_SHA1, UUID_NS_URL, $sourcedid);
  •   # Next create a time dependent portion
  •   my $uuid_p2 = create_uuid_as_string(UUID_TIME);


In reply to Larry Riddle

Re: error during LTI reporting of grade back to Canvas

by Nathan Wallach -
I realized that there is also a second issue to look into here.
It looks like the manner in which local_escape_html() is being called (on line 339 of your version of SubmitGrade.pm) is problematic. Based on the other 2 calls to this function, it seems that instead of
debug(local_escape_html($response->content));
it may need to be
debug($self->local_escape_html($response->content));
as the function is expecting to get a reference to $self before the string "message".

I suspect that fixing that may at least fix the report of "Can't use string ("{"errors":[{"message":"Duplicate"...) as a HASH ref while "strict refs" in use".

Please try that out, to see if we can also fix this bug, and not only the problem interfering with Canvas accepting the grades.
In reply to Nathan Wallach

Re: error during LTI reporting of grade back to Canvas

by Larry Riddle -
Nathan, thank you so much for taking a look at this issue for me. I greatly appreciate it.

I made the change you suggested to line 339 in SubmitGrade.pm. It did prevent the error message and allowed me to see the results of grading the problem. However, WeBWorK reported that "Your score was not successfully sent to the LMS".

I then tried replacing SubmitGrade.pm with your new version and grading a problem after accessing WW via Canvas. Grading the problem worked with no error message, but again WW reported that it was unsuccessful in sending the score to the LMS.

Finally, I made the change to the debug line in the new SubmitGrade.pm file. Again, however, WW was still unsuccessful in sending the score to the LMS.

What I find puzzling about this issue with Canvas and WeBWorK is that up until around May 15, I had been able to access problem sets in WW from a Canvas course, grade the problems, and have the score successfully sent back to Canvas. At some point around that date, I started getting this error message, first intermittently, and then with all problems, not only for this course, but with another Canvas course. Nothing had been changed in WeBWorK.

If it helps, I set $debug_lti_parameters = 1 in the course.conf file and got the following report when accessing the problem

===== parameters received =======
context_label => MAT 115 ON SU120
lti_version => LTI-1p0
custom_canvas_user_id => 103
custom_canvas_workflow_state => available
launch_presentation_document_target => iframe
oauth_nonce => 1WQ7R5XDBbQ9Q63x0NvhlGFOvgFIT9trUMB2fb3hZ4
custom_canvas_assignment_points_possible => 1
lis_person_name_family => Riddle
oauth_callback => about:blank
tool_consumer_info_product_family_code => canvas
oauth_version => 1.0
oauth_signature => mFdr76sFHjY+QcF6Z9UXv2u0KHE=
user_id => 4c743d75739ca11820b77932d2700b3a5e2c7273
roles => Learner
launch_presentation_return_url => https://agnesscott.instructure.com/courses/1783/external_content/success/external_tool_redirect
tool_consumer_instance_contact_email => notifications@instructure.com
launch_presentation_locale => en
lti_message_type => basic-lti-launch-request
lis_person_name_given => Larry
custom_canvas_course_id => 1783
custom_canvas_api_domain => agnesscott.instructure.com
custom_canvas_assignment_title => z-Score Problem
lis_person_contact_email_primary => lriddle@agnesscott.edu
context_title => Elementary Statistics
tool_consumer_info_version => cloud
ext_outcome_submission_submitted_at_accepted => true
oauth_consumer_key => WeBWorK
lis_outcome_service_url => https://agnesscott.instructure.com/api/lti/v1/tools/93/grade_passback
oauth_timestamp => 1590165065
resource_link_title => z-Score Problem
ext_outcome_data_values_accepted => url,text
lis_person_sourcedid => 0079094
ext_outcomes_tool_placement_url => https://agnesscott.instructure.com/api/lti/v1/turnitin/outcomes_placement/93
context_id => c6cdb516378c2510cfa634614340332051471149
ext_outcome_result_total_score_accepted => true
ext_ims_lis_basic_outcome_url => https://agnesscott.instructure.com/api/lti/v1/tools/93/ext_grade_passback
custom_canvas_assignment_id => 7502
tool_consumer_instance_guid => nnYk4VkevBXun67nxLg5Q6BD0cfCXicxOvisXcx6:canvas-lms
user_image => https://canvas.instructure.com/images/messages/avatar-50.png
custom_canvas_user_login_id => lriddle@agnesscott.edu
resource_link_id => 88e3c9f72f91c0c532de2339420ffc2b5927b43e
lis_result_sourcedid => 93-1783-7502-103-b154df8198b7055c4e222fa08b78b4032303dc3b
tool_consumer_instance_name => Agnes Scott College
lis_course_offering_sourcedid => MAT 115 ON SU120
ext_roles => urn:lti:instrole:ims/lis/Instructor,urn:lti:instrole:ims/lis/Student,urn:lti:role:ims/lis/Learner,urn:lti:sysrole:ims/lis/User
custom_canvas_enrollment_state => active
lis_person_name_full => Larry Riddle
ext_lti_assignment_id => 184e308c-2957-4f09-992d-eb8e55b7862e
oauth_signature_method => HMAC-SHA1
=========== summary ============ at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 213.
User id is |lriddle|
User mail address is |lriddle@agnesscott.edu|
Student id is |undefined|
preferred_source_of_username is |lis_person_contact_email_primary|
preferred_source_of_student_id is |undefined|
================================
The following path was reconstructed by WeBWorK. It should match the path in the LMS: at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 380.
http://webwork.agnesscott.edu/webwork2/Math115_SU20/28/ at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 381.

and the following after grading the problem

Retrieving prior grade using sourcedid: 93-1783-7502-103-b154df8198b7055c4e222fa08b78b4032303dc3b at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 253.

Thanks again for all your help.
In reply to Larry Riddle

Re: error during LTI reporting of grade back to Canvas

by Nathan Wallach -

Larry -

It is somewhat nice that the small proposed fix to the line 339 at least gets rid of the error message from WW due to the small bug. However, the real problem is understanding why Canvas is now rejected the grade pass-back request, and I'm not sure I can help more without more data on why something is going wrong. It still seems likely that for some reason Canvas is reporting "Duplicate nonce detected" but the change I suggested should make that quite unlikely (as explained below).

In addition to the WW control setting "$debug_lti_parameters" there is also a second setting "$debug_lti_grade_passback".  Based on the notes in conf/authen_LTI.conf.dist when both are on, the the full request and response between the LMS and WW will be logged into the apache error log (someplace like /var/log/apache2/error.log). Hopefully looking at a few such pairs will provide some additional hints as to what is going wrong with the grade passback.

I'm pretty sure these settings can be modified in course.conf to effect just the specific course.

---

The change is apparently on the Canvas side of things. According to what I have read, "Canvas" makes monthly updates on the 3rd Saturday of each month, so May 16 is a very logical day for a Canvas update to be released.  The debugging data seems to indicate you are using Canvas hosted by the software provider (infrastructure.com) and not a local system, as the URL starts with https://agnesscott.instructure.com (It is possible that your institution just recently moved from a local Canvas system to the service from infrastructure.com.) 

I first assumed that fixing it would apparently require modify WW to comply with some additional checks Canvas had added to the "nonce" not repeating before accepting a score update. It could be that my idea of having one part of the nonce now depend on the sourcedid in a fixed manner made things worse, but from what I see in the Canvas code - that does not seem likely, as it seems to just save the nonce string using 

      cache_key = "nonce:#{@tool.asset_string}:#{@signature.request.nonce}"

and check that this key is not already in the cache, but not to do any check for "similar" nonces. Thus, I am now less comfortable with the guess that a real detection of "nonce reuse" is the cause of your problems.

However if the "cache" is shared by many sites/courses. and the "tool.asset_string" does not differentiate between webwork used in different courses, maybe there really is an issue with duplicate nonces being detected due to that. Somehow, I doubt that is really the issue.

I suggest trying to contact the Canvas support staff (possibly via your IT staff) to also have them look into the issue. Maybe they will be able to determine what changes in Canvas might have caused the grade passback from WeBWorK to stop working in your courses. If they provide more information about what is going wrong, and if the problem is new demands on what WW should be sending - we can hopefully fix it.

Note: There is a post at  https://groups.google.com/forum/#!topic/canvas-lms-users/-Q4Y_sV7EKE  about a similar problem, and that thread had to do with an issue with then "Redis" database used by Canvas to store the nonces being overwhelmed... Maybe something like that is happening again, but that is probably something that the tech staff instructure.com would need to look into. 

Posting at  https://groups.google.com/forum/#!forum/canvas-lms-users  might also help, if the problem is on the canvas side and effects more places using Canvas.

Nathan


References about the release schedule:

https://community.canvaslms.com/docs/DOC-14787-what-is-the-canvas-release-schedule-for-beta-production-and-test-environments

https://community.canvaslms.com/docs/DOC-14783-about-canvas-release-notes-faq

Various collected links about the LTI/nonce handling from GitHub's repo for Canvas:

https://github.com/instructure/canvas-lms/

https://github.com/instructure/canvas-lms/blob/master/spec/controllers/lti_api_controllers_spec.rb

Has a line reporting the "Duplicate nonce detected" message:

https://github.com/instructure/canvas-lms/blob/1ffd248c4923b4337ad52289133149a026979d61/app/controllers/lti_api_controller.rb

Next file has the definition of Canvas's check_and_store_nonce function:

https://github.com/instructure/canvas-lms/blob/a664cdb0b26bf9d4473c0204dba38fc73a34ece7/lib/lti/security.rb

https://github.com/instructure/canvas-lms/blob/a664cdb0b26bf9d4473c0204dba38fc73a34ece7/lib/lti/message_authenticator.rb

https://github.com/instructure/canvas-lms/search?q=nonce&unscoped_q=nonce

In reply to Nathan Wallach

Re: error during LTI reporting of grade back to Canvas

by Larry Riddle -
Nathan,

I do intend to ask our IT liaison to Canvas to check with them next week. I determined that the last problem for which WW successfully sent the score back to the Canvas gradebook was graded at 10:43 on May 16, and that no problem I graded after 10:46 pm on May 16 has had a score registered in the Canvas gradebook.

I did turn on the $debug_lti_grade_passback setting and tried grading a problem three times: once with the original SubmitGrade.pm, once with your revision to line 339, and once with the version of SubmitGrade.pm where you modified the code to to set the nonce used. Here are the results of the three experiments:

original SubmitGrade.pm -- WW error message upon submitting grade
-------------
SubmitGrade.pm with line 339 modified
problem graded successfully
score not successfully set to LMS
Apache log:
[Sat May 23 20:45:05.168791 2020] [perl:warn] [pid 14336] [client 10.200.200.127:61812] [/webwork2/Math115_SU20/01/1/] submitting grade for user: lriddle set 01 , referer: http://webwork.agnesscott.edu/webwork2/Math115_SU20/01/1/?effectiveUser=lriddle&user=lriddle&key=hLpuF6YvWobgxmaPbLAzZ6VdOOCpWU3r
[Sat May 23 20:45:05.168926 2020] [perl:warn] [pid 14336] [client 10.200.200.127:61812] [/webwork2/Math115_SU20/01/1/] Submitting grade using sourcedid: 93-1783-7473-103-62011da1658963531c3c953bdd4295b311d422a3 and score: 1, referer: http://webwork.agnesscott.edu/webwork2/Math115_SU20/01/1/?effectiveUser=lriddle&user=lriddle&key=hLpuF6YvWobgxmaPbLAzZ6VdOOCpWU3r
performing mass_update via LTI at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 359.

Note: $LTIMassUpdateInterval = -1; set in course.conf, so I'm a bit confused about that last line.
---------------
SubmitGrade.pm with modified code to set the nonce used
problem graded successfully
score not successfully set to LMS
Apache log: (Note line numbers are different with new version of SubmitGrade.pm which was a longer file)
[Sat May 23 20:48:27.099270 2020] [perl:warn] [pid 14506] [client 10.200.200.127:61901] [/webwork2/Math115_SU20/01/1/] submitting grade for user: lriddle set 01 , referer: http://webwork.agnesscott.edu/webwork2/Math115_SU20/01/1/?effectiveUser=lriddle&key=s4JaX5HhqR4baViefac49F1WiK8MrX3u&user=lriddle
[Sat May 23 20:48:27.405999 2020] [perl:warn] [pid 14506] [client 10.200.200.127:61901] [/webwork2/Math115_SU20/01/1/] Unable to retrieve prior grade from LMS. Error: Unauthorized at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 332., referer: http://webwork.agnesscott.edu/webwork2/Math115_SU20/01/1/?effectiveUser=lriddle&key=s4JaX5HhqR4baViefac49F1WiK8MrX3u&user=lriddle
performing mass_update via LTI at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 480.
performing mass_update via LTI at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 480.
performing mass_update via LTI at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 480.
----------------

Thanks again for all your comments and suggestions. I will let you know what I learn from the Canvas technicians.
In reply to Larry Riddle

Re: error during LTI reporting of grade back to Canvas

by Nathan Wallach -

I'm sorry my help is only really finding the minor issues, and not yet helping address the main problem.

Sorry - it turns out that the debugging messages I had hoped to see in the apache error.log would only have been generated later on in the code, and the error was triggering a "return" before it got there. I apologize that I did not look into the code more carefully to make sure it would actually reach the place the data was set to be logged before asking you to do the test.

I'm attaching a new modified version of SubmitGrade.pm which should add the debugging message to the logs and also on the browser screen when $debug_lti_grade_passback and $debug_lti_parameters are both enabled. It collects and reports the debug messages earlier on in the 2-stage process in the "longer" version of SubmitGrade.pm. It also reports the nonce used, as that was not being reported in the older debugging data. This time I did test to make sure that I see the debugging output in a demo course using LTI grade pass-back, so I hope we will now see the full error message Canvas is sending you in the "response" data.

(The debug data will probably look nice in the browser window than in error.log.) 

About the "performing mass_update" message - the code to put that message into error.log was incorrectly located. The log record was being generated before the test whether it should be bypassed due to the setting of "$LTIMassUpdateInterval = -1" and I moved the line to where it should be in the attached version.

In reply to Nathan Wallach

Re: error during LTI reporting of grade back to Canvas

by Larry Riddle -
After installing the new revised version of SubmitGrade.pm, I graded a problem with both debug settings enabled and will send those reports to Canvas. If you are interested, here is what was displayed in the browser (you are correct --- much nicer looking and easier to read than in error.log)

Upon clicking the WW link in the Canvas course page:
===== parameters received =======
custom_canvas_assignment_title => Wilson's Problem
oauth_version => 1.0
oauth_nonce => emC0bmMfefJ1idP1b8GaIHTHKwcM9JB4y22cBQUBZQY
lis_course_offering_sourcedid => MAT 115 ON SU120
resource_link_title => Wilson's Problem
tool_consumer_instance_name => Agnes Scott College
oauth_signature => q+TG1BT7/L0FypOhzxASXydAM3I=
oauth_signature_method => HMAC-SHA1
ext_outcome_result_total_score_accepted => true
lis_person_sourcedid => 0079094
ext_lti_assignment_id => c980ae3c-02f4-4d12-a193-6ed1b8455549
lis_result_sourcedid => 93-1783-7501-103-988183e88e6b3a228d555a3599132eafb61c8e23
lti_version => LTI-1p0
oauth_consumer_key => WeBWorK
user_image => https://canvas.instructure.com/images/messages/avatar-50.png
custom_canvas_user_login_id => lriddle@agnesscott.edu
custom_canvas_enrollment_state => active
launch_presentation_locale => en
tool_consumer_instance_guid => nnYk4VkevBXun67nxLg5Q6BD0cfCXicxOvisXcx6:canvas-lms
custom_canvas_user_id => 103
lis_outcome_service_url => https://agnesscott.instructure.com/api/lti/v1/tools/93/grade_passback
ext_outcome_submission_submitted_at_accepted => true
context_label => MAT 115 ON SU120
oauth_callback => about:blank
ext_ims_lis_basic_outcome_url => https://agnesscott.instructure.com/api/lti/v1/tools/93/ext_grade_passback
resource_link_id => ae70fd5add342268b856c76aeb808d0667ab8b43
user_id => 4c743d75739ca11820b77932d2700b3a5e2c7273
tool_consumer_instance_contact_email => notifications@instructure.com
tool_consumer_info_version => cloud
lis_person_name_full => Larry Riddle
ext_roles => urn:lti:instrole:ims/lis/Instructor,urn:lti:instrole:ims/lis/Student,urn:lti:role:ims/lis/Learner,urn:lti:sysrole:ims/lis/User
ext_outcomes_tool_placement_url => https://agnesscott.instructure.com/api/lti/v1/turnitin/outcomes_placement/93
custom_canvas_assignment_points_possible => 1
lti_message_type => basic-lti-launch-request
tool_consumer_info_product_family_code => canvas
lis_person_name_given => Larry
lis_person_name_family => Riddle
ext_outcome_data_values_accepted => url,text
launch_presentation_return_url => https://agnesscott.instructure.com/courses/1783/external_content/success/external_tool_redirect
custom_canvas_workflow_state => available
oauth_timestamp => 1590332643
context_id => c6cdb516378c2510cfa634614340332051471149
custom_canvas_course_id => 1783
lis_person_contact_email_primary => lriddle@agnesscott.edu
context_title => Elementary Statistics
custom_canvas_api_domain => agnesscott.instructure.com
launch_presentation_document_target => iframe
custom_canvas_assignment_id => 7501
roles => Learner
=========== summary ============ at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 213.
User id is |lriddle|
User mail address is |lriddle@agnesscott.edu|
Student id is |undefined|
preferred_source_of_username is |lis_person_contact_email_primary|
preferred_source_of_student_id is |undefined|
================================
The following path was reconstructed by WeBWorK. It should match the path in the LMS: at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 380.
http://webwork.agnesscott.edu/webwork2/Math115_SU20/27/ at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced.pm line 381.

After grading the problem (and getting the report that the score not successfully sent to the LMS)
Warning messages

submitting grade for user: lriddle set 27
Submitting grade using sourcedid: 93-1783-7501-103-988183e88e6b3a228d555a3599132eafb61c8e23 and score: 1
The response is:
_request HTTP::Request=HASH(0x7fe58ed482c0) _rc 401 _protocol HTTP/1.1 _content {"errors":[{"message":"Duplicate nonce detected"}],"error_report_id":32030} _msg Unauthorized _headers HTTP::Headers=HASH(0x7fe58f182ad8) at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 320.
The request was:
_content <?xml version = "1.0" encoding = "UTF-8"?>V1.099999912393-1783-7501-103-988183e88e6b3a228d555a3599132eafb61c8e23en1 _uri https://agnesscott.instructure.com/api/lti/v1/tools/93/grade_passback _headers HTTP::Headers=HASH(0x7fe58ed48008) _uri_canonical https://agnesscott.instructure.com/api/lti/v1/tools/93/grade_passback _method POST at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 321.
In reply to Larry Riddle

Re: error during LTI reporting of grade back to Canvas

by Nathan Wallach -

At least we have a clear confirmation that the error message being sent back by Canvas is "Duplicate nonce detected":

{"errors":[{"message":"Duplicate nonce detected"}],"error_report_id":32030}

so is certainly coming from the "Duplicate nonce" detection code in Canvas, which is what I had guessed from the partial string from the first post:

Can't use string ("{"errors":[{"message":"Duplicate"...) as a HASH ref while "strict refs" in use at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 193.

Why Canvas is reporting this, especially with the more complicated nonce strings tried in the new code, is something the techs at infrastructure.com will need to look into.


In reply to Nathan Wallach

Re: error during LTI reporting of grade back to Canvas

by Larry Riddle -
This issue has finally been resolved. After much prodding on our end for Canvas technical support to actually investigate what might be causing Canvas to generate the "duplicate nonce detected" error, Canvas was able to identify that our WeBWorK server was posting times that were more than 1 minute ahead of the timestamp Canvas had. Apparently Canvas only allows for 1 minute ahead and 5 minutes behind. After syncing the time on the WeBWorK server (as of today it was about 90 seconds ahead of the "official" time), I was able to grade a problem in WeBWorK and have the score successfully sent to the LMS. I guess on May 16 between 10:43 pm and 10:46 pm when grade feedback stopped working, our WW server's time must have crossed over the 1 minute ahead threshold.
In reply to Nathan Wallach

Re: error during LTI reporting of grade back to Canvas

by Bianca Sosnovski -
Nathan,

This is not to ask a question to resolve an issue but to report something similar that happened with our new install of Webwork. 

Thank you for sharing the modified version of SubmitGrade.pm above. That was very helpful because we had the following message when submitting answers in the Webwork and the grade not being passed back to Blackboard:

"Can't use string ("Can't connect to bbhosted.cuny.e"...) as a HASH ref while "strict refs" in use at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 193."

With the modified file we started to see the following:

"Unable to retrieve prior grade from LMS. Error: Can't connect to bbhosted.cuny.edu:443 (SSL connect attempt failed error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small) at /opt/webwork/webwork2/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm line 344."

That was a more informative type of error. After researching the issue, our IT noticed that our school's Blackboard was using a weak key than was accepted by our SSL connection in ourWebwork. 

Thanks.