WeBWorK Main Forum

Why quoted text removed from answer displays by Webwork? (Still graded right.)

Re: Why quoted text removed from answer displays by Webwork? (Still graded right.)

by Davide Cervone -
Number of replies: 0
Is there any way to set a string to display as the answer when students select "Show correct answers" ?

Sure. Whatever you put in the quotations for Compute will be the correct answer. So

    $strings = Compute($string_answers[0])->cmp(checker => sub {...});
would do it.

On the other hand, I think this this type of answer checker is a bad idea, as they give no useful feedback when students are wrong (e.g., due to a spelling error). Unless their knowledge of the existence of the word "scalene" is what you are trying to test, I would rather see a pop-up menu with "Equilateral", "Isosceles", and "Scalene".

Alternatively, you could use the contextString.plfile and the String context to get better results. Here is an example:

 
    DOCUMENT();

    loadMacros(
      "PGstandard.pl",
      "MathObjects.pl",
      "contextString.pl",
      "PGML.pl",
    );

    TEXT(beginproblem());

    Context("String");
    Context()->strings->add(
      Equilateral => {},
      Isosceles => {},
      Scalene => {},
      "Equilateral triangle" => {alias => "Equaliateral"},
      "Isosceles triangle" => {alias => "Isosceles"},
      "Scalene triangle" => {alias => "Scalene"},
    );
    
    $ans = "Scalene";
    
    BEGIN_PGML
    [$ans] = [____________]{$ans}
    END_PGML

    ENDDOCUMENT();
This gives better error messages. See if that works better for you.

Davide