WeBWorK Problems

File upload

Re: File upload

by Steven Fiedler -
Number of replies: 1

I made some headway into effectively converting the sample essay problem to the behavior I originally expected, i.e., a summative assessment. The correct/incorrect indicator on the true/false toggle problem can be suppressed by triggering an action around the showAttemptResults flag.  Below is some code to that effect.

However, students can still indirectly determine if they were successful by viewing the problem score both under the status column on the set page and the Grade page. If anyone has an idea of how to hide these values until after the due date on a homework assignment, this would be helpful. For our use case, there are advantages to mixing formative and summative assessment and it would be inconvenient for the students to take a webwork test to complete just one additional question.


DOCUMENT();
loadMacros(
    'PGstandard.pl',  'PGML.pl',
    'parserPopUp.pl', 'PGessaymacros.pl',
    'PGcourse.pl'
);

$time=time();
$close=$rh_envir->{dueDate};
if($time < $close){  $rh_envir->{showAttemptResults}=0;}

$popup = PopUp(
    [ 'Choose', 'True', 'False' ],    # choices
    'False'                           # corect answer
);

$a = random(2, 5);

$f1 = Compute("ln(x (x-$a))");
$f2 = Compute("ln(x) + ln(x-$a)");

BEGIN_PGML
Answer the following true / false question and then explain your answer.  Your
answers will be read and graded manually at a later time.

[_]{$popup} For all real numbers [`x`], [`[$f1] = [$f2]`].

Please explain your reasoning in the answer box below.
[@ ANS( essay_cmp() ); essay_box(8, 60) @]*
END_PGML

ENDDOCUMENT();


In reply to Steven Fiedler

Re: File upload

by Steven Fiedler -

I largely answered my own question.  The below code gets me to where I wanted to go. I suspect that anything more sophisticated would need write access to the sets hash in the library *.pm files.

DOCUMENT();
loadMacros('PGstandard.pl','PGML.pl','PGcourse.pl','PGessaymacros.pl');

$num=1;
BEGIN_PGML
Enter the number [$num]: [___]
END_PGML

ANS(Real($num)->cmp(checker=>sub {
    my ($correct,$student,$ansHash) = @_;
    my $time=time();
    my $close=$rh_envir->{dueDate};
    if($time < $close){  
      $rh_envir->{showAttemptResults}=0;
      $ansHash->{ans_message}="This answer will be graded at a later time.";
      return 0;
    }
    elsif($student==$correct){ return 1; } #time > close && correct
    else{ return 0; }  #time > close && incorrect

    }#end sub
   ) #end cmp
); #end ANS()

BEGIN_PGML
Please explain your reasoning in the answer box below.
[@ ANS( essay_cmp() ); essay_box(8, 60) @]*
END_PGML

ENDDOCUMENT();