## WeBWorK Problems

by Paul Seeburger -
Number of replies: 26

When students enter set-builder notation, like {x | x < 4} in text mode in a MathQuill answer blank, WeBWorK does not display the student's answer in the answer blank after they submit it.

It shows correctly in the Entered and Answer Preview sections when I click the submit button, but the answer blank appears empty.

This behavior does not seem to happen when the student enters a phrase like, "all real numbers" in the text mode though.  In this case the student answer does appear in the answer blank after the student answer is submitted.

Is there any way to make the student entered answer appear in the answer blank after their submission?  It does not seem to matter whether their answer was correct or incorrect.  Their entered answer (in the text mode box) does not appear after they submit it.

This makes it harder for me to help them too, although I can still find their answer when we click submit or by looking at Past Answers.

Thanks!

by Glenn Rice -

I haven't seen anything like this, and can not reproduce it.

Is this a problem from the OPL or elsewhere?  If it is in the OPL, which problem?  If it is from elsewhere, can you attach the pg file?

by Paul Seeburger -
Here's the problem code. It's adapted from some PCC problems and another by Robin Cruz from about 2014.

Again, the issue is that when an answer is entered for the set-builder notation answer in text mode (Tt), the answer is processed correctly, and maintained in the Entered and Preview columns, but not displayed in the student's answer blank after each submission. And it is not there at all, even when I click into it.

##DESCRIPTION
## Compound Inequalities - OR
##
## Adapted from a problem by RA Cruz by Paul Seeburger
##
##ENDDESCRIPTION
## DBsubject(Algebra)
## DBchapter(Algebra of real numbers and simplifying expressions)
## DBsection(Inequalities and intervals)
## Institution('Monroe Community College')
## Author('Paul Seeburger, RA Cruz')
## MLT(Compound_inequality)
## KEYWORDS('inequalities','compound','and')
## Date('9/24/2014')

DOCUMENT(); # This should be the first executable line in the problem.

"PGstandard.pl",
"PGchoicemacros.pl",
"MathObjects.pl",
"contextInequalitySetBuilder.pl",
"PGML.pl",
"PGcourse.pl",
);

TEXT(beginproblem());

######################################
# Setup
#This is an (-infinity,a) or (b,infinity) problem:

$a = non_zero_random(-3,2,1);$c = random(2,3,1);
$ac =$a*$c; do {$b = random(-4,4,1);} while ($a==$b);
$d = random(-3,-2,1);$bd = $b*$d;

@inequal = ("$c x <$ac","$d x >$bd" );
@slice = NchooseK(2,2);

InequalitySetBuilder::UseVerticalSuchThat();
Context("InequalitySetBuilder-Only");
"empty set"=>{alias=>'null set'},
"{}"=>{alias=>'null set'},
"all real numbers"=>{},
);

#Context()->operators->undefine(">");
#Context()->{error}{msg}{"Can't use ' > ' in this context"} =
# "Simplest form for a chain inequality will never involve the > symbol. Rewrite it using <.";

$ans = Compute("x<$a");
if ($a<$b) {$ans = Compute("x<$b");}
$setans = Compute("{ x |$ans}");

Context("Interval");
if ($a<$b) {
$intans = Compute("(-inf,$b)");
}
else {
$intans = Compute("(-inf,$a)");
}
######################################
# Main text

BEGIN_TEXT
Solve the compound inequality.
$\Large {inequal[slice[0]] \quad\mbox{ or }\quad inequal[slice[1]] }$
END_TEXT

$rn = "\{x \mid x \in \mathbb{R}\}"; BEGIN_PGML Please type: *inf* for [\infty], *[$GTS]=* for [\geq], and *[$LTS]=* for [\leq] In set-builder notation, the solution set is [______________]. If the answer is [\varnothing], type *null set*. If the answer is [[$rn]], type *all real numbers*.

An example of set-builder notation is [\{x\mid x < 10\}].

In interval notation, the solution set is [______________].
An example of interval notation is [[1,\infty)]. If the answer is [\varnothing], type *none* or *null set*.

END_PGML

$showPartialCorrectAnswers = 1; ANS($setans->cmp(mathQuillOpts => "spaceBehavesLikeTab: false"));
ANS(\$intans->cmp(mathQuillOpts => "spaceBehavesLikeTab: false"));

######################################

COMMENT('MathObject version');
ENDDOCUMENT();

by Glenn Rice -
I have tried this problem with a couple different browsers, and tested as a student and professor.  I also tested this with WeBWorK and PG 2.15 and with the develop branch of both.  I can't reproduce this.

Do you have something in a custom PGcourse.pl macro that might be interfering?

Could you open the developer console in your browser and see if there is anything there that might reveal what is going on?

by Paul Seeburger -

I don't see anything in the Developer console when I submit these answers.

But I do use a macro very related to this answer blank.  It may well be the culprit, but I am not sure where in the code something may be amiss.  Perhaps I just need to update it from the latest version on Contrib.

It's ContextInequalitySetBuilder.pl.  See my version attached.  It was from Sept. 2014.

Regarding Alex's earlier question, by using the PGInfo flag I was able to see the following after submitting my answer in blank 1.

HASH(0x55804d44c1c0)

Note that in this case with the correct answer, the answer blank is bordered in green to show that it is correct, although it is now completely empty.

Paul

by Glenn Rice -

I tested this with the macro you attached (which is almost identical the default macro in pg/macros other than two trivial differences in comments that won't affect anything), and the version of contextInequalitySetBuilder.pl in OpenProblemLibrary/macros/PCC/contextInequalitySetBuilder.pl (which is a little different), and still am not seeing this issue.

I don't think that there is a version of contextInequalitySetBuilder.pl in Contrib.

by Paul Seeburger -

When I looked up the OPL version of contextInequalitySetBuilder.pl in github, I did see that it was not changed since 2014 (other than comments).

Does this mean I no longer need to use this macro in my macros folder?  I don't think it was available on my server at that time.

I'm using a server with the following installation of WeBWorK.  I don't know if perhaps there could be something in any "develop" changes that could be a factor?

ww_version: 2.15+develop

Thanks for all your help, Glenn!

Paul

by Alex Jordan -
Hi Paul,

Would it be possible to create a fake student account, assign the problem set to them, and private message me login credentials? If I can witness it happening live with my web browser, I could watch the console for error messages and other things.

Alex

by Alex Jordan -
I am in the course and basically confirm what Paul experiences. But I can get more specific. The issue seems to happen for an answer that is in text mode and uses a brace pair. It's not important that it be a set-builder notation answer. If I submit an incorrect answer that is just {x} (in text mode), the answer does not persist in the field.

In the span that would normally have the previous answer, the class is class="mq-root-block mq-empty".

The same thing happens for me on a server that is running a clean 2.15, as well as a couple servers that are at different stages of develop.

by Paul Seeburger -
Thanks, Alex!

So you are seeing this behavior on other servers too, right?

I wonder why Glenn is not seeing it when he tries it.

Any ideas about how to address this issue? It may be a rare occurrence normally. It just came up for almost every problem in this isolated homework set.

Thanks!

Paul

by Glenn Rice -
Okay, so I didn't read your first post closely enough.  Sorry about that.  I didn't see that you are entering this in "text mode". When I enter the answer in text mode, I see it also.

Why are your students entering set builder in text mode? Set builder works best in math mode. They can get the vertical line by typing "vert" or by using the button on the toolbar. In math mode this works as expected.

In any case, I will look into what is going on with text mode here when I get a chance.

by Glenn Rice -
I am not sure what is happening exactly. I will have to look deeper into the MathQuill code to see what is going on, but it doesn't like the \{ and \} in text mode when it is input into the mathquill via the latex method.

In any case, tell your students not to use text mode for set builder. That is the way it should be anyway.

by Paul Seeburger -
That makes sense, Glenn.

And going forward I will recommend the MathQuill approach to entering set-builder notation.

But all the problems that ask for set-builder notation in my courses always mention the | bar above the enter key. And this was giving some of my basic algebra students issues. They were trying that and it was not working for them because of the automatic matching grouping symbols in MathQuill. Here, giving | |.

I would rather that MathQuill did NOT automatically match grouping symbols, as I think it's a good skill for students to learn.

And the automatic absolute values when they type the vertical bar | was frustrating some of them.

Since this is the first time I am teaching with MathQuill in my problems, I just showed them how to enter set-builder notation in both ways, either using the vertical bar on the template or using the text mode.

Perhaps because they have used the text mode before for several other special cases, many of them chose the text mode approach.

But now that I know how to allow spaces in MathQuill, the MathQuill set-builder notation looks better. It was mashing the x|x together with no spacing. I'd think it would automatically space these things out, but perhaps it's not designed to do that here.

Thanks so much for your help on this!

Paul

by Glenn Rice -
Even if the spaceBehavesLikeTab option is true, you can still type spaces. It is probably not intuitive unless you are accustomed to typing latex, but you can type "\ ", that is a backslash followed by a space.

The matching of delimiters is built in to MathQuill, and they do not provide an option to disable it. Matching of delimiters is common with programs that allow this type of math entry. Geogebra, Desmos, etc. It is not as important of a skill as you think to know that a parenthesis that is started must be ended, and I think you will find that your students do know this. The common mistake of not adding the matching parenthesis is probably more of a clerical error than that of not knowing. The same mistake that we really all make. What is more important is to know where a parenthesis that is started must be ended, and MathQuill does not tell your students that.

by Paul Seeburger -
Fair enough point on the need for students to close off their grouping symbols, Glenn. Figuring out where they end and using the correct symbols is probably more important, as you said.

It's just good they are allowed to use different symbols on each end for interval notation!

But getting spaces by typing "\ " won't translate to my algebra students. =)

Thanks for all the help!

by Glenn Rice -
Yeah, students won't get the "\ " thing, but you can use that and add a button to the toolbar to enter a space.

In fact you could  add the attached PGcourse1.pl (renamed to PGcourse.pl) to your course's macro directory and that will add a space button to the toolbar for all answers in all problems.

Although you might like the attached PGcourse2.pl better.  It disables the spaceBehavesLikeTab option (and re-enables typing spaces) in all answers in all problems.

If you already have a PGcourse.pl file, just add that the contents of the init method to that of your PGcourse.pl file.

by Paul Seeburger -

Wow!

That's really cool, Glenn!  I've already added the second option to my PGcourse.pl file and I can see that it works!

I'll play around some with the first one to see what I can do with it.

Might it be possible to set flags in a particular problem to tell the PGcourse.pl to add certain extra buttons just for a particular problem type?  That is, something needed in a small handful of problems but which I may not want on the template all the time?

Thanks!

by Glenn Rice -

Just create a macro that is essentially the same as the PGcourse.pl macro I gave you, but with your modified buttons, and load that macro in those problem types.

It is also possible to add buttons just for a particular answer in a problem, but that takes a bit more care.  I do that for some of my problems.  You have to know the answer name.

by Paul Seeburger -

That's powerful!  We'll see how I do at making that work.

Thanks, Glenn!

by Glenn Rice -

My pull request https://github.com/openwebwork/webwork2/pull/1200 includes a fix for set builder in text mode.

by Alex Jordan -

> Why are your students entering set builder in text mode?

My experience is that if I type up to the pipe character, MathQuill insists on providing a second pipe character as a grouping delimiter for absolute value. I cannot delete one without both disappearing. This is why they are using text mode. And this is what I experience logged in to Paul's course working a problem.

Perhaps you could do:

{ x "|" x > 0}

but that is even more awkward to communicate to students.

by Paul Seeburger -
Yes, but, the vertical bar on the MathQuill template does do the trick. It would just be nicer if it automatically inserted some space before and after it to make it look nicer.

And as mentioned before, I'd prefer to be able to turn off the automatic grouping symbol pairing feature.

by Glenn Rice -
This is why the vert button is on the toolbar. You should know this, you were the reason we added that button.

by Glenn Rice -

Both of the versions of the contextInequalitySetBuilder.pl macro (in the OPL and in pg/macros) haven't really changed since 2014.  If you are running WeBWorK 2.15 or later, then you do not need to put contextInequalitySetBuilder.pl in your macros folder.  In fact, I recommend that you use the one in pg/macros.  Your file still has the copyright symbol instead of &copy;, and you might see errors due to that.

2.15+develop is the version you will see if you are using the development branch of webwork.  I tested with the development branch and didn't have the problems, so that is not what is causing the issues you are seeing.

by Alex Jordan -

Out of curiosity, investigating something we do not understand (https://github.com/openwebwork/webwork2/issues/1208), can you access the transaction log for the course, and find the line corresponding to some time when the answer disappears from the answer blank? I'd be looking for a situation where Q0001_AnSwEr0001 is blank, but MaThQuIlL_Q0001_AnSwEr0001 (or something else) shows that {x | x < 4} (or whatever the answer was) was indeed typed by the student.

by Paul Seeburger -
Alex, since I don't oversee this server, I am not sure how to access this transaction log, but I was able to display the AnswerHashInfo for this problem and it gave a couple of errors on this answer blank. Perhaps that is related to the issue?

But the exact same error appears (only with AnswerHashInfo selected) if I enter the set-builder notation answer using MathQuill, in which case the answer remains after submission.

See below.

PG question processing error messages
PG debug messages

_filter_name => dereference_array_ans
ans_message =>
cmp_class => a Set in Set-Builder Notation
correct_ans => {x | x < 1}
correct_ans_latex_string => \left\{x \mid x < 1\right\}
correct_value => Unable to determine stringify for this item Can't locate object method "string" via package "InequalitySetBuilder::Interval::SUPER" at line 349 of (eval 2984)
done =>
error_flag =>
error_message =>
ignoreStrings => 1
isPreview =>
mathQuillOpts => spaceBehavesLikeTab: false
original_student_ans => {x | x<1}
preview_latex_string => \left\{x \mid x < 1\right\}
preview_text_string => {x | x < 1}
requireParenMatch => 1
score => 1
showEndTypeHints => 1
showEndpointHints => 1
showEqualErrors => 1
showTypeWarnings => 1
showUnionReduceWarnings => 1
student_ans => {x | x < 1}
student_formula => {x | x < 1}
student_value => Unable to determine stringify for this item Can't locate object method "string" via package "InequalitySetBuilder::Interval::SUPER" at line 349 of (eval 2984)
studentsMustReduceUnions => 1
type => Value (InequalitySetBuilder)