GithubHelp home page GithubHelp logo

Comments (3)

taniwallach avatar taniwallach commented on August 20, 2024

A sample problem which triggers the issue when answers are submitted is below.

Changing the line singleResult => 1, to singleResult => 0, bypasses the problem.

The error messages generated when singleResult => 1 is set are:

PG question processing error messages

PG warning messages

------
The evaluated answer is not an answer hash : ||.

WeBWorK Warnings

WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information.
Warning messages

    Use of uninitialized value $credit{"AnSwEr0002"} in numeric eq (==) at (eval 8750) line 288.
    Use of uninitialized value $credit{"AnSwEr0002"} in multiplication (*) at (eval 8750) line 304.

The sample problem:

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

loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  "parserRadioButtons.pl",
  "parserMultiAnswer.pl",
  "weightedGrader.pl",
);

TEXT(beginproblem());

install_weighted_grader();

Context("Numeric");

$a = random(1,4,1) * random(-1,1,2);

$ans1ev   = Compute("$a");
$ans1mult = Real("2");

$radio1 = RadioButtons(
  [ "Yes", "No" ],
  "Yes", # correct answer
  displayLabels => 0, # Do not display the label in the text
);

$multians1 = MultiAnswer( $ans1ev, $ans1mult )->with(
  singleResult => 0,
  checkTypes => 1,
  checker => sub {
      my ( $correct, $student, $self ) = @_;
      my ( $studAev, $studAm ) = @{$student};
      my ( $corrAev, $corrAm ) = @{$correct};

      my $myScore = 0;

      if ( $studAev == $corrAev ) {
        $myScore += 0.5;
        if ( $studAm == $corrAm ) {
          $myScore += 0.5;
        } 
      } 
      return( $myScore );
   }
);

Context()->texStrings;
BEGIN_TEXT
a. Enter \( \lambda = $a \) and enter \( 2 \) as the geometric multiplicity.
$BR

$BCENTER
\( \lambda = {} \)
\{ $multians1->ans_rule(3) \}
has ${BBOLD}geometric${EBOLD} multiplicity
\{ $multians1->ans_rule(3) \}
$ECENTER

$PAR

b. Is the matrix \( A \) diagonalizable? [Enter Yes.]
$BR$BR
\{$radio1->buttons\}

END_TEXT
Context()->normalStrings;

WEIGHTED_ANS( $multians1->cmp() , 80);
WEIGHTED_ANS( $radio1->cmp()   , 20 );

ENDDOCUMENT();        # This should be the last executable line in the problem.

from pg.

dpvc avatar dpvc commented on August 20, 2024

The problem is that, when singleResult is not true, $multians1->cmp() produces a list of answer checkers (one for each part of the multi-answer object, not a single answer checker. Because ANS() accepts an array of checkers, ANS($multians1->amp()) works fine, but WEIGHTED_ANS() only accepts a single answer checker, which is where the problem arrises.

One could do something like

map {WEIGHTED_ANS($_, 40)} ($mutlians1->cmp());

in this case.

Note that when singleResult is false, you are really supposed to return an array of scores, one for each part of the multi-answer object. If you only return a single result, it is used for all of them, but in your case, that is not really appropriate. For example, if you get the lambda value correct but the multiplicity incorrect, both parts are shows as 50% correct, which is sub-optimal. If you returned (1,0) or [1,0] rather that .5 in this case, then the lambda part would be shown as fully correct (which it is), and the multiplicity would be fully incorrect (not 50% correct). With the WEIGHTED_ANS() map above, the score would be 40% total for these two answers.

If you wanted the lambda to could as more than the multiplicity, you could do

($cmp1, $cmp2) = $multians1->cmp();
WEIGHTED_ANS($cmp1, 50);
WEIGHTED_ANS($cmp2, 30);

for example.

from pg.

taniwallach avatar taniwallach commented on August 20, 2024

@dpvc - Thanks for the detailed explanation and suggestions.

I think the conclusion is that the Wiki documentation on these two macro packages should both refer to a new Wiki page on how to use them together. I'll try to make time to write up something for the Wiki in the near future (and am leaving the issue open temporarily until I do so), and once there is something in the Wiki, your feedback/corrections to what is there will help make it more accurate.

The same technique given at the end of your post seems to also provide an approach which allows using post-filters with the individual specific "checkers" of a MultiAnswer group (apparently really with the individual answer hashes which are returned after the checker runs).

I was aware of the option of an array of results for when singleResult is false, and have used it. For the minimal example provided above, I just wanted to have a simple and relatively minimal example of what changes and fails when changing the value of singleResult to make sure the central issue could be examined.

from pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.