WeBWorK Problems

File upload

Re: File upload

by Steven Fiedler -
Number of replies: 0

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();