Skip to content

MathQuill replaces AnSwEr input fields#922

Merged
mgage merged 32 commits into
openwebwork:WeBWorK-2.15from
drdrew42:develop_mathquill
Jul 31, 2019
Merged

MathQuill replaces AnSwEr input fields#922
mgage merged 32 commits into
openwebwork:WeBWorK-2.15from
drdrew42:develop_mathquill

Conversation

@drdrew42

@drdrew42 drdrew42 commented Feb 1, 2019

Copy link
Copy Markdown
Member

Updated and cleaned version of #920 & #921

MathQuill feature greedily replaces up to 9 answer blanks per problem, offering live TeX rendering of student answer entry. This feature pulls the most recent student entry for each answer blank, parses it into LaTeX through mathJS and then MathQuill renders the result into an editable answer blank.

updates include:

  • customized string handling: typing a double-quote now triggers text-mode (still waiting on response from MathQuill developers regarding the MathQuill edit handler not reacting as expected when in text-mode... strings still do not quite work correctly - but we're closer than before, even if it doesn't seem that way!) fixed
  • MathQuill no longer inserts extra '*' between symbols (let WW decide how to parse it instead...)
  • basic commands (sine cosine tangent etc) are now sent to WW properly
  • typing 'root' triggers an indexed radical which is sent to WW as a rational exponent
  • an empty index in a 'root' has default value 2, treated as '^(1/2)'; while 'sqrt' behaves as expected
  • empty fields in a fraction have default values 0 / 1 for numerator / denominator
  • absolute values are now started by '|' or by 'abs'
  • set-builder notation can be entered, using 'vert' or '\vert' (sorry @Alex-Jordan, but I could not figure out a way to intelligently separate the usage of '|' as both single and paired - if it stands alone, I can't see how to get it to close an in-progress absolute value, and dropping 'abs' isn't desirable either...)

If anyone is interested, the MathQuill edits are here

@dpvc

dpvc commented Feb 1, 2019

Copy link
Copy Markdown
Member

This branch looks much simpler, thanks! You should probably remove your old branches that are no longer needed (as they complicate the network diagram unnecessarily). An @mgage can remove his branch, as yours now includes all of his commits.

@mgage mgage mentioned this pull request Feb 1, 2019
@drdrew42

drdrew42 commented Feb 8, 2019

Copy link
Copy Markdown
Member Author

Further customization to the handling of \infty, now "inf" triggers the creation of the infinity symbol, and the .text() output targets the ~universal webwork inf string.

"union" now creates \cup which cycles back to "U" in .text(), while simply typing "U" works as well.

Modifications to .text() output: inserting whitespace into text output to ensure that we 'exit' out of fractions properly (issues with mismatching parenthesis when re-rendering a submitted student answer). Also corresponding modifications to .typedText() to read inputs with whitespace-as-tabs according to the MathQuill.options setting.

I believe this is functional enough for some of my more-experienced instructors to begin using with their classes. I'm proceeding with a beta-test of this feature in a handful of classrooms. I will continue to keep this thread updated with issues that we encounter (and hopefully fixes for them as well).

@drdrew42

Copy link
Copy Markdown
Member Author

still waiting on response from MathQuill developers regarding the MathQuill edit handler not reacting as expected when in text-mode...

I've now fixed the text-mode issue, and raw text strings are behaving normally.

As discovered by our guinea pigs students, mismatched brackets were being displayed properly; but when submitted to WeBWorK, the initial bracket superseded the answer as entered - e.g. [5,inf) was being submitted as [5,inf]. I have also resolved this issue.

glennricster and others added 12 commits February 14, 2019 09:32
method in ProblemUtil.pm, and call that from both the gateway quizzes
and single problems.
notably the fix to the text block handling.
answer boxes.  Each response group can set options individually.  For
example if a problem wants to change the way that roots are sent to
webwork from the (current) default of entering root(a,b) to b^(1/a), and
also change it so that '+-=<>' don't end superscripts and subscripts,
then the in the pg problem file do:
	$answer->cmp(mathQuillOpts => "rootsAreExponents: 1, charsThatBreakOutOfSupSub: ''")
Any of the MathQuill document options can be set in this way as well as
our added option above (rootsAreExponents), with the exception of the
handlers option.
Also add in some niceties to the way that the mathquill answer boxes
work.
encountered in createAnswerQuill method of mqeditor.js, do not return
false.  That ends the processing of the jQuery .each function, and so
any valid inputs after that are skipped.
Also in the mathquill toolbar, remove the intersection and inequality
buttons, and add a text button.
The charsThatBreakOutOfSupSub option of mathquill is also removed.
Finally, just a little code clean up in the ProblemUtil.pm file.
are converted to exponents.  Probably the ideal thing to do here would
be to have the parserRoot.pl PG macro set the rootsAreExponents option
to false automatically.
@drdrew42

Copy link
Copy Markdown
Member Author

Another round of updates to this feature - which is proving quite robust by this point!

Big thanks to @drgrice1, who had the excellent idea of stashing the LaTeX'ed version of the student answer with the other "sticky" answers (in _problem_user). These extra, hidden answer blanks are also then removed before responses are stored in _past_answer.

The mathquill feature now replaces all answer blanks (both for named_ans and the usual AnSwEr blanks), and will accurately re-render the most recent student input when the page is reloaded.

A sidebar with commonly used structures has also been added - allowing for alternate entry of fractions, radicals, text mode, etc...

PG problems can also pass an option (rootsAreExponents: true/false) to the mathquill object, determining whether or not non-square roots should be interpreted as rational exponents (default) or as root(index, radicand). This option could be included as part of the parserRoot macro, as suggested in 6e2b163

@drgrice1 am I forgetting anything?

@drgrice1

Copy link
Copy Markdown
Member

I think you covered the changes. It might also be noted that there is information in ddeff29 as to how to set the rootsAreExponents and other MathQuill options from a PG problem.

@mgage mgage changed the base branch from develop to WeBWorK-2.15 July 31, 2019 20:31
@mgage

mgage commented Jul 31, 2019

Copy link
Copy Markdown
Member

Merging the MathQuill PR #922

@mgage mgage merged commit 75e7e76 into openwebwork:WeBWorK-2.15 Jul 31, 2019
@nmoller

nmoller commented Jul 31, 2019

Copy link
Copy Markdown
Member

@drdrew42 @taniwallach @mgage :
I had a look at your PR and I got:
PR-922.pdf
Does that make sense or am I doing something wrong?

@drdrew42

Copy link
Copy Markdown
Member Author

@nmoller Thanks for having a look - yes, that looks accurate. (Though I certainly need to do some housecleaning and prune some of those old WW branches.)

In short, yes, one must update the user tables in the db for the use of this new feature.

@mgage

mgage commented Jul 31, 2019 via email

Copy link
Copy Markdown
Member

@nmoller

nmoller commented Jul 31, 2019

Copy link
Copy Markdown
Member

Thanks for the hints. After doing that:

root@1a17a2520d69:/opt/webwork/webwork2/bin# ./upgrade_admin_db.pl
Added column 'useMathQuill' to table 'user'

The admin part does work... but login in as a student in a course and going to the set.... and I'm still having

Error messages
DBD::mysql::st execute failed: Unknown column 'useMathQuill' in 'field list' 

@drdrew42

Copy link
Copy Markdown
Member Author

upgrade_admin_db.pl only updates the tables for the admin course.

Now log into the admin course and "upgrade courses"

@nmoller

nmoller commented Jul 31, 2019

Copy link
Copy Markdown
Member

Thats what I have so far:
image

image

Once I click upgrade, I got
image

Still...It does not work.
I go with a new course:

addcourse test03 --db-layout=sql_single --users=$APP_ROOT/webwork2/courses.dist/adminClasslist.lst --professors=admin

I add an user.... I choose MathQuill in the course config. And everything works..
What should I test?

@taniwallach

Copy link
Copy Markdown
Member

Thats what I have so far:
...
Still...It does not work.
I go with a new course:
I add an user.... I choose MathQuill in the course config. And everything works..
...
What should I test?

Maybe change the user's config of the old course to use MathView, save the change, then change it to use MathQuill and save the change. Hopefully that will force the DB to get a valid setting in the field which had not existed in the past. I'm suggesting 2 steps just in case setting something expected as the current value would not trigger a save to the DB.

useWirisEditor => $ce->{pg}->{options}->{useWirisEditor},
useMathView => $user->useMathView ne '' ? $user->useMathView : $ce->{pg}->{options}->{useMathView},
useWirisEditor => $user->useWirisEditor ne '' ? $user->useWirisEditor : $ce->{pg}->{options}->{useWirisEditor},
useMathQuill => $user->useMathQuill ne '' ? $user->useMathQuill : $ce->{pg}->{options}->{useMathQuill},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is it possible that $user->useMathQuill is a false-ish value that is also not explicitly equal to empty-string? In which case, the un-initialized course (that has been converted via "upgrade courses") has the sort of unintended consequences that @nmoller is seeing here?

Would it be better to use $user->useMathQuill ? if_yes : if no instead of ne ''?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@drdrew42 - It sound like something like that is probably causing the problem. Why guess - just test what shows up in the DB field if an old course is upgraded to add the MathQuill field and the user is not manually edited. We certainly want a patch to avoid this happening once WW 2.15 gets released.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've checked, db entries are NULL and I cannot replicate the issue described by @nmoller above. I did the following:

  1. git checkout develop_mathquill
  2. un-archived an old course that did not contain the new db column
  3. upgraded the course via the admin course
  4. logged into the course as admin and turned on MathQuill
  5. switched accounts to a professor in same course, loaded a problem page and MathQuill worked
  6. switched accounts to a student in same course, loaded a problem page and MathQuill worked
  7. SELECT user_id, useMathQuill from upgraded_course_name; shows that all users have NULL value for useMathQuill (and MathQuill behaved as expected with NULL value).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@nmoller - Could you examine what is in the database table directly.

docker container exec -it webwork2_db_1 bash
mysql -u webworkWrite -p webwork
  • the password should get you into the database.

@drdrew42

drdrew42 commented Aug 1, 2019

Copy link
Copy Markdown
Member Author

In order to test the functionality of the MathQuill feature:

  1. Create a new course, turn on the MathQuill feature, create a student in the course;
  2. Assign a non-empty problem set to a student-permission-ed user, make sure that the set is "open" now;
  3. Log in as the student user, visit any open, assigned problem page and confirm that putting your cursor in a text-entry field
    1. triggers the right-side entry bar to appear
    2. type in "1/x" and see it rendered vertically
    3. type in "sqrt(5)" and see if it displays a radical-5
    4. type "e^(1/x)" and see if the rendering is correct
  4. confirm that "submit answer" or "preview answer" accurately shows that WeBWorK receives what you intended in each of the above options;
  5. Use "submit answer" on at least one problem that is open;
  6. staying logged in as the "student", visit User Settings and disable MathQuill;
  7. (re)visit any problem page and confirm that MathQuill is indeed disabled (no right-side entry bar, no live-rendering of expressions, etc);
  8. revisit a problem(s) that has previously submitted answers (as required above), what do the answer boxes contain? Does it correspond to what you submitted previously?

@mgage

mgage commented Aug 1, 2019

Copy link
Copy Markdown
Member

@nmoller I've wondered whether the course upgrade took properly. You can check by going to
admin, choosing the Upgrade courses tab, and see if the course you updated reports that the database tables are ok. There are three html pages to the course upgrade process and it's easy to miss the last one. From your report it looks like the course was upgraded properly but it might be worth a second check.

@nmoller

nmoller commented Aug 2, 2019

Copy link
Copy Markdown
Member

@drdrew42 : You are right something weird with that updated cours (its user table looks like
image

In the other... it looks fine:
image

@taniwallach I'm used to have a phpmyadmin to go into the db:

docker run --name myadmin01 --network webwork2tani_default -d --link webwork2tani_dbMB4_1:db -p 8081:80 phpmyadmin/phpmyadmin

@mgage You was right ... something weird happens I revisited the upgrade page...and it worked for my test01 course

But the other courses reappeared than the upgrade page:
image

Tomorrow I'll follow the script suggested in comment

Thanks for your patience.

@nmoller

nmoller commented Aug 2, 2019

Copy link
Copy Markdown
Member

I'm trying to follow the script kindly given by @drdrew42 ... and when I go to the new course Classlist Editor I get :
image

And what is weirder is that i happens 2 out ~3 times???
I'm sorry... I feel that I'm not helping that much.

@nmoller

nmoller commented Aug 2, 2019

Copy link
Copy Markdown
Member

Each time I create a new course... I should go through the upgrade process:
image

image
Well... the last time..only one:
image

But the error in the Classlit link keep comming
image

@nmoller

nmoller commented Aug 2, 2019

Copy link
Copy Markdown
Member

And the most annoying of all that is that line 1811 is a commented line??? I'm still not arriving at testing mathquill 😞

Be sure that I've already double-checked that I've checked out drdrew42 develop_mathquill branch.

And going back to the admin page.... update courses surprised me with:
image
😭

After re-re-upgrading.... Classeditor is back.

@drdrew42

drdrew42 commented Aug 2, 2019

Copy link
Copy Markdown
Member Author

I do not understand what we're seeing here - there is no reason why the db tables should need to be repeatedly upgraded... @nmoller when you're re-upgrading these courses, what does WeBWorK say is in need of updating?

@mgage

mgage commented Aug 2, 2019 via email

Copy link
Copy Markdown
Member

@mgage

mgage commented Aug 2, 2019 via email

Copy link
Copy Markdown
Member

@nmoller

nmoller commented Aug 2, 2019

Copy link
Copy Markdown
Member

@drdrew42 : I can give you access to my testing env if you want. I've send you the link and user by email..

@nmoller

nmoller commented Aug 2, 2019

Copy link
Copy Markdown
Member

@drdrew42 @mgage : I can rebuild the whole env from scratch if you think that could be something to try. I've started from the env build to test tani's utf8 PR and switched ww2 to develop_mathquill branch.

@mgage

mgage commented Aug 2, 2019 via email

Copy link
Copy Markdown
Member

@nmoller

nmoller commented Aug 2, 2019

Copy link
Copy Markdown
Member

@drdrew42 @mgage : Rebuilding the env... and everything worked:
ww2-test003.pdf

I've gone through activate/desactivate as indicated in the script and it works as expected.

@taniwallach

Copy link
Copy Markdown
Member

I think that the problem is that the Docker builds were using the old master branch, and not everything needed was being mounted from a local directory into Docker.

We probably should write up some more detailed instructions on how to test using externally mounted pg and webwork2 against a "standard" Docker image, as it is far easier to get special branches in an external directory than to change the Docker image.

@nmoller

nmoller commented Aug 3, 2019

Copy link
Copy Markdown
Member

The difference was the pg branch but the build process works fine. Resuming that means... if we are testing a branch of ww2, it would be fine to state which pg branch to use or vice-versa.

For a tester does have no idea (as it is my case) the best would be to have the dockerfile set with the right components without having to mount a local version of ww2 or pg.

A developer is surely aware of what combination to use.
Thanks for anybodys help in the process. 🎊

@taniwallach

Copy link
Copy Markdown
Member

The difference was the pg branch but the build process works fine. Resuming that means... if we are testing a branch of ww2, it would be fine to state which pg branch to use or vice-versa.

For a tester does have no idea (as it is my case) the best would be to have the dockerfile set with the right components without having to mount a local version of ww2 or pg.

The problem is that at the PR stage, there is not always a "standard" branch to test against in the main repository, only in the developer's personal fork, and most such PRs should not be changing the main Dockerfile or docker-compose.yml.

Instead, maybe we can standardize test procedures based on either:

  • proving a custom Dockerfile (require an image rebuild)
  • providing instructions for what pg and webwork2 branches to mount from outside a given Docker image in order to test.

@xcompass , @mgage, @heiderich - Thoughts on this?

@nmoller

nmoller commented Aug 3, 2019

Copy link
Copy Markdown
Member

I agree with you Nathan, and here I rejoin Pan opinion that the best way would be to have an "official image" meaning a dockerhub version where to push. And having the dev branches accordingly built and pushed to some tagging system (to be established too).

That maybe could be added after Pan comments in PR-972 but as this is turning more into a general discussion ... in my images, I try to follow the advice to log everything to stdout so the command "docker logs -f... " or the centralising process of the orchestrator (mostly pushing it to some kind of ELK stack) works as expected.

@taniwallach

Copy link
Copy Markdown
Member

Let's move the discussion of improving the Docker configuration to #979 and #980

@drdrew42 drdrew42 deleted the develop_mathquill branch December 29, 2019 20:20
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.

8 participants