Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues with the sage.pl macro. #522

Merged
merged 1 commit into from
Mar 8, 2021

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Feb 2, 2021

First, there was an obvious typo that made the macro's ShowAnswerBlank option fail.

Next, sage uses python3 which requires that the print function have its arguments parenthesized. This causes the record_answer method in the ShowAnswerBlank eq 'none' case to fail.

Next, '<script src="$CellServer/static/jquery.min.js"></script>' was recently added to this macro before the loading of the sagecell
javascript. The sagecell javascript internally loads its own jQuery instance, and so there is no need for that. Furthermore, that version of jQuery conflicts with the version currently in use by WeBWorK.

Finally, the sagecell server does not correctly deal with jQuery. They recently added the usage of the noConflict method, but it was not done so correctly. This conflicts with our jQuery usage. So our version of jQuery is cached and restored after the sagecell javascript is loaded and executed. This is not the perfect solution, as it is theoretically possible for something else (another ready or window load function) to be executed during the time that the sagecell server code is loading. The only perfect solution is for the sagecell code to be fixed.

See https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5011 for some of my discussion on this.

First, there was an obvious typo that made the macro's ShowAnswerBlank
option fail.

Next, sage uses python3 which requires that the print function have its
arguments parenthesized.  This causes the record_answer method in the
ShowAnswerBlank eq 'none' case to fail.

Next, '<script src="$CellServer/static/jquery.min.js"></script>' was
recently added to this macro before the loading of the sagecell
javascript.  The sagecell javascript internally loads its own jQuery
instance, and so there is no need for that.  Furthermore, that version
of jQuery conflicts with the version currently in use by WeBWorK.

Finally, the sagecell server does not correctly deal with jQuery.  They
recently added the usage of the noConflict method, but then they still
use and modify the global $ variable.  This conflicts with our jQuery
usage.  So our version of jQuery is cached and restored after the
sagecell javascript is loaded and executed.

See https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5011 for some
of my discussion on this.
Copy link
Member

@taniwallach taniwallach left a comment

Choose a reason for hiding this comment

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

I used the test problem @drgrice1 posted in the forum thread https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5011#p15356

  • Before the patch - warnings were issued. (Listed below.)
  • After the patch - all OK - no warnings.

Warnings from before applying the patch:

PG question processing error messages

PG warning messages

------
No answer evaluator for the question labeled: sageAnswer

------
Answer evaluator sageAnswer was not executed due to errors.
========

@drgrice1 drgrice1 added this to the PG-2.16 milestone Feb 24, 2021
@taniwallach taniwallach requested review from drdrew42, Alex-Jordan and pstaabp and removed request for pstaabp and Alex-Jordan March 2, 2021 20:59
@taniwallach
Copy link
Member

Would appreciate someone else testing before we merge this.

Copy link
Contributor

@Alex-Jordan Alex-Jordan left a comment

Choose a reason for hiding this comment

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

I tested the same problem as @taniwallach with the same before and after results.

As an aside, is that problem correctly computing the answer? My random version created a 2x2 graph (four points in a square) and expect the answer for the graph radius to be 0. I would have guessed 2.

@drgrice1
Copy link
Member Author

drgrice1 commented Mar 5, 2021

I have no clue as to the validity of the problem. I didn't look closely. I just took the problem that was posted on the forum, and made the sage part work.

@taniwallach
Copy link
Member

We have 2 approvals after testing the patch. I'm merging it now.

@taniwallach taniwallach merged commit 365220d into openwebwork:develop Mar 8, 2021
@drgrice1 drgrice1 deleted the fix-sage-macro branch March 9, 2021 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants