--- loncom/homework/response.pm 2008/12/23 18:09:36 1.210 +++ loncom/homework/response.pm 2010/02/28 23:44:36 1.217 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # various response type definitons response definition # -# $Id: response.pm,v 1.210 2008/12/23 18:09:36 raeburn Exp $ +# $Id: response.pm,v 1.217 2010/02/28 23:44:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,6 +54,7 @@ use strict; use Apache::lonlocal; use Apache::lonnet; use Apache::lonmaxima(); +use Apache::lonr(); BEGIN { &Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse')); @@ -283,7 +284,7 @@ sub check_for_previous { my %previous; $previous{'used'} = 0; foreach my $key (sort(keys(%Apache::lonhomework::history))) { - if ($key =~ /resource\.$partid\.$id\.submission$/) { + if ($key =~ /resource\.\Q$partid\E\.\Q$id\E\.submission$/) { if ( $last && $key =~ /^(\d+):/ ) { next if ($1 >= $last); } @@ -317,7 +318,10 @@ sub handle_previous { if ($$previous{'last'}) { push(@Apache::inputtags::previous,'PREVIOUSLY_LAST'); push(@Apache::inputtags::previous_version,$$previous{'version'}); - } elsif ($Apache::lonhomework::type ne 'survey') { + } elsif (($Apache::lonhomework::type ne 'survey') && + ($Apache::lonhomework::type ne 'surveycred') && + ($Apache::lonhomework::type ne 'anonsurvey') && + ($Apache::lonhomework::type ne 'anonsurveycred')) { push(@Apache::inputtags::previous,'PREVIOUSLY_USED'); push(@Apache::inputtags::previous_version,$$previous{'version'}); } @@ -438,7 +442,7 @@ sub end_customresponse { ${$safeeval->varglob('LONCAPA::customresponse_submission')}= $response; - my $award = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval); + my ($award,$score) = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval); if (!&Apache::inputtags::valid_award($award)) { $error = $award; $award = 'ERROR'; @@ -446,6 +450,9 @@ sub end_customresponse { &Apache::response::handle_previous(\%previous,$award); $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}= $award; + if ($award eq 'ASSIGNED_SCORE') { + $Apache::lonhomework::results{"resource.$part.$id.awarded"}=1.0*$score; + } if ($error) { $Apache::lonhomework::results{"resource.$part.$id.awardmsg"}= $error; @@ -508,7 +515,7 @@ sub start_mathresponse { 'answerdisplay',$token); $result.=&Apache::edit::select_arg('Algebra System:', 'cas', - ['maxima'], + ['maxima','R'], $token); $result.=&Apache::edit::text_arg('Argument Array:', 'args',$token). @@ -538,14 +545,14 @@ sub edit_mathresponse_button { # my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor'); my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'}; return(< + -$button +$button ENDFORMULABUTTON } @@ -572,6 +579,12 @@ sub end_mathresponse { $award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args, &Apache::lonxml::get_param('libraries',$parstack,$safeeval)); } + if ($cas eq 'R') { + my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)]; + $award=&Apache::lonr::r_run($Apache::response::custom_answer[-1],$response,$args, + &Apache::lonxml::get_param('libraries',$parstack,$safeeval)); + } + if (!&Apache::inputtags::valid_award($award)) { $error = $award; $award = 'ERROR'; @@ -897,6 +910,10 @@ sub showallfoils { } } if ($Apache::lonhomework::type eq 'survey') { return 1; } + if ($Apache::lonhomework::type eq 'surveycred') { return 1; } + if ($Apache::lonhomework::type eq 'anonsurvey') { return 1; } + if ($Apache::lonhomework::type eq 'anonsurveycred') { return 1; } + return 0; } @@ -948,13 +965,17 @@ sub getresponse { my $id = $Apache::inputtags::response[-1]; my $line; + my $startline = $env{'form.scantron_questnum_start.'.$part.'.'.$id}; + if (!$startline) { + $startline = $Apache::lonxml::counter; + } for ($line = 0; $line < $lines; $line++) { - my $theline = $Apache::lonxml::counter+$offset-1+$line; + my $theline = $startline+$offset-1+$line; $response = $env{"scantron.$theline.answer"}; if ((defined($response)) && ($response ne "") && ($response ne " ")) { last; } - + } # save bubbled letter for later