WeBWorK Problems

assigning grade weights inside pgml compare methods

assigning grade weights inside pgml compare methods

by Larry Riddle -
Number of replies: 2

I was watching the video of TWP Tea Time #2 on the WeBWorK Project YouTube channel the other day. One of the presenters was talking about using a weighted grader and said that one issue with this is that the weighted_ans commands had to be placed after the end of the pgml block. Someone then interjected (around the 21:00 mark) that the weight option can be passed to the compare method inside the pgml block, but I couldn't quite catch the explanation of how to do that. I've tried doing a search but have so far been unsuccessful. Does anyone have an example of assigning weighted grades by passing the weight option inside pgml?

In reply to Larry Riddle

Re: assigning grade weights inside pgml compare methods

by Rick Lynch -

You can do it by placing WEIGHTED_ANS followed by an ans_rule call split by a semicolon within [@ @]*.  It's easier to see than describe. Here's an example (you may need to reformat a bit when copy/pasting):

BEGIN_PGML

a. What is [`5 + 1`]?

    Answer: [@ WEIGHTED_ANS(Compute("6")->cmp(), 50); ans_rule(5) @]*

b. What is [`10 - 2`]?

    Answer: [@ WEIGHTED_ANS(Compute("8")->cmp(), 50); ans_rule(5) @]*

END_PGML

I hope that helps.


In reply to Rick Lynch

Re: assigning grade weights inside pgml compare methods

by Glenn Rice -

With PG 2.18 you can also use:

[_]{Compute("6")}{5}{ cmp_options => { weight => 50 } }