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

Two solutions using Context("Inequalities") #280

Closed
d-torrance opened this issue Aug 29, 2016 · 3 comments
Closed

Two solutions using Context("Inequalities") #280

d-torrance opened this issue Aug 29, 2016 · 3 comments

Comments

@d-torrance
Copy link
Contributor

Hello!

Consider the following problem:

DOCUMENT();

loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  "contextInequalities.pl"
);

Context("Inequalities");

$ans = Compute("x=1 or x=2");

TEXT(beginproblem());
BEGIN_TEXT
\{ ans_rule(20) \}
END_TEXT

ANS($ans->cmp());

ENDDOCUMENT();

The solution "{1,2}" is marked correct, but "x=1 or x=2" (which we used to define the answer in the first place) is marked incorrect.

This is an issue for many of the problems in [1].

[1] https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/CollegeOfIdaho/setAlgebra_04_03_AbsoluteValue

@dpvc
Copy link
Member

dpvc commented Aug 29, 2016

The x=1 or x=2 expression is supposed to produce a Set object equivalent to {1,2}, but it turns out that it is producing a Union object (with one element, the set {1,2}). Due to some technical issues in how Union's are checked, this causes the correct answer to be marked incorrect. It is easily fixed in the lib/Value/Set.pm file, but until that is is an official release, one way to handle it in the problem itself is to add

$ans = $ans->{data}[0] if $ans->type eq "Union";  # hack to fix problem with inequality above

directly after the line that computes $ans. That will fix it for now, and when the library is fixed, the if statement will be false, and it will stop doing anything. So the problem should continue to work without modification (though it would be good to remove the hack eventually).

dpvc added a commit to dpvc/pg that referenced this issue Aug 29, 2016
@dpvc
Copy link
Member

dpvc commented Aug 29, 2016

The issue280 branch of my fork of PG includes the fix.

goehle added a commit that referenced this issue Aug 30, 2016
Don't force the result of adding two sets to be a Union.  #280
@goehle goehle closed this as completed Aug 30, 2016
@dpvc
Copy link
Member

dpvc commented Aug 30, 2016

The branch has been merged into develop.

Alex-Jordan pushed a commit to Alex-Jordan/pg that referenced this issue Dec 25, 2017
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

No branches or pull requests

3 participants