version 1.128, 2005/11/10 22:19:27
|
version 1.139, 2006/06/19 16:15:53
|
Line 32 use Apache::lonlocal;
|
Line 32 use Apache::lonlocal;
|
use Apache::lonnet; |
use Apache::lonnet; |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','algorithmicresponse')); |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse')); |
} |
} |
|
|
sub start_response { |
sub start_response { |
my ($parstack,$safeeval)=@_; |
my ($parstack,$safeeval)=@_; |
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
my $id = &Apache::lonxml::get_id($parstack,$safeeval); |
if ($id eq '') { $id = $Apache::lonxml::curdepth; } |
|
if ($#Apache::inputtags::import > -1) { |
if ($#Apache::inputtags::import > -1) { |
&Apache::lonxml::debug("Turning :$id: into"); |
&Apache::lonxml::debug("Turning :$id: into"); |
$id = join('_',@Apache::inputtags::import).'_'.$id; |
$id = join('_',@Apache::inputtags::import).'_'.$id; |
Line 69 sub end_response {
|
Line 68 sub end_response {
|
|
|
sub start_hintresponse { |
sub start_hintresponse { |
my ($parstack,$safeeval)=@_; |
my ($parstack,$safeeval)=@_; |
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
my $id = &Apache::lonxml::get_id($parstack,$safeeval); |
if ($id eq '') { $id = $Apache::lonxml::curdepth; } |
|
push (@Apache::inputtags::hint,$id); |
push (@Apache::inputtags::hint,$id); |
push (@Apache::inputtags::hintlist,$id); |
push (@Apache::inputtags::hintlist,$id); |
push (@Apache::inputtags::paramstack,[%Apache::inputtags::params]); |
push (@Apache::inputtags::paramstack,[%Apache::inputtags::params]); |
Line 362 sub end_dataresponse {
|
Line 360 sub end_dataresponse {
|
return $result; |
return $result; |
} |
} |
|
|
sub start_algorithmicresponse { |
sub start_customresponse { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $id = &Apache::response::start_response($parstack,$safeeval); |
my $id = &Apache::response::start_response($parstack,$safeeval); |
push(@Apache::lonxml::namespace,'algorithmicresponse'); |
push(@Apache::lonxml::namespace,'customresponse'); |
my $result; |
my $result; |
undef($Apache::response::algorithmic_answer); |
undef($Apache::response::custom_answer); |
&Apache::lonxml::register('Apache::response',('answer')); |
&Apache::lonxml::register('Apache::response',('answer')); |
if ($target eq 'web') { |
if ($target eq 'web') { |
if ( &Apache::response::show_answer() ) { |
if ( &Apache::response::show_answer() ) { |
Line 391 sub start_algorithmicresponse {
|
Line 389 sub start_algorithmicresponse {
|
} elsif ($target eq 'answer' || $target eq 'grade') { |
} elsif ($target eq 'answer' || $target eq 'grade') { |
&Apache::response::reset_params(); |
&Apache::response::reset_params(); |
} elsif ($target eq 'meta') { |
} elsif ($target eq 'meta') { |
$result .= &Apache::response::meta_package_write('algorithmicresponse'); |
$result .= &Apache::response::meta_package_write('customresponse'); |
} |
} |
return $result; |
return $result; |
} |
} |
|
|
sub end_algorithmicresponse { |
sub end_customresponse { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $result; |
my $result; |
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
Line 404 sub end_algorithmicresponse {
|
Line 402 sub end_algorithmicresponse {
|
if ( $target eq 'grade' && &Apache::response::submitted() ) { |
if ( $target eq 'grade' && &Apache::response::submitted() ) { |
my $response = &Apache::response::getresponse(); |
my $response = &Apache::response::getresponse(); |
if ( $response =~ /[^\s]/ && |
if ( $response =~ /[^\s]/ && |
$Apache::response::algorithmic_answer_type eq 'loncapa/perl') { |
$Apache::response::custom_answer_type eq 'loncapa/perl') { |
if (!$Apache::lonxml::default_homework_loaded) { |
if (!$Apache::lonxml::default_homework_loaded) { |
&Apache::lonxml::default_homework_load($safeeval); |
&Apache::lonxml::default_homework_load($safeeval); |
} |
} |
Line 413 sub end_algorithmicresponse {
|
Line 411 sub end_algorithmicresponse {
|
$Apache::lonhomework::results{"resource.$part.$id.submission"}= |
$Apache::lonhomework::results{"resource.$part.$id.submission"}= |
$response; |
$response; |
my $error; |
my $error; |
${$safeeval->varglob('LONCAPA::algorithmicresponse_submission')}= |
${$safeeval->varglob('LONCAPA::customresponse_submission')}= |
$response; |
$response; |
|
|
my $award = &Apache::run::run('{ my $submission=$LONCAPA::algorithmicresponse_submission;'.$Apache::response::algorithmic_answer.'}',$safeeval); |
my $award = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer.'}',$safeeval); |
if (!&Apache::inputtags::valid_award($award)) { |
if (!&Apache::inputtags::valid_award($award)) { |
$error = $award; |
$error = $award; |
$award = 'ERROR'; |
$award = 'ERROR'; |
Line 436 sub end_algorithmicresponse {
|
Line 434 sub end_algorithmicresponse {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub start_mathresponse { |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
my $result; |
|
if ($target eq 'meta') { |
|
&Apache::response::start_response($parstack,$safeeval); |
|
$result=&Apache::response::meta_package_write('mathresponse'); |
|
&Apache::response::end_response(); |
|
} else { |
|
# $result.=&start_numericalresponse(@_); |
|
} |
|
return $result; |
|
} |
|
|
|
sub end_mathresponse { |
|
# return end_numericalresponse(@_); |
|
} |
|
|
sub start_answer { |
sub start_answer { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $result; |
my $result; |
$Apache::response::algorithmic_answer= |
$Apache::response::custom_answer= |
&Apache::lonxml::get_all_text_unbalanced("/answer",$parser); |
&Apache::lonxml::get_all_text_unbalanced("/answer",$parser); |
$Apache::response::algorithmic_answer_type= |
$Apache::response::custom_answer_type= |
lc(&Apache::lonxml::get_param('type',$parstack,$safeeval)); |
lc(&Apache::lonxml::get_param('type',$parstack,$safeeval)); |
$Apache::response::algorithmic_answer_type =~ s/\s+//g; |
$Apache::response::custom_answer_type =~ s/\s+//g; |
if ($target eq "edit" ) { |
if ($target eq "edit" ) { |
$result=&Apache::edit::tag_start($target,$token,'Answer algorithm'); |
$result=&Apache::edit::tag_start($target,$token,'Answer algorithm'); |
$result.=&Apache::edit::editfield($token->[1], |
$result.=&Apache::edit::editfield($token->[1], |
$Apache::response::algorithmic_answer, |
$Apache::response::custom_answer, |
'',80,4); |
'',80,4); |
} elsif ( $target eq "modified" ) { |
} elsif ( $target eq "modified" ) { |
$result=$token->[4].&Apache::edit::modifiedfield('/answer',$parser); |
$result=$token->[4].&Apache::edit::modifiedfield('/answer',$parser); |
Line 592 sub setup_params {
|
Line 607 sub setup_params {
|
} |
} |
} |
} |
|
|
|
{ |
|
my @answer_bits; |
|
|
sub answer_header { |
sub answer_header { |
my ($type) = @_; |
my ($type,$increment) = @_; |
my $result; |
my $result; |
if ($env{'form.answer_output_mode'} eq 'tex') { |
if ($env{'form.answer_output_mode'} eq 'tex') { |
$result = ' \vskip 0 mm \begin{tabular}{|c|}\hline Answer for Part: \verb|'. |
undef(@answer_bits); |
$Apache::inputtags::part.'| \\\\ \hline '; |
my $bit; |
|
if ($Apache::lonhomework::type eq 'exam') { |
|
$bit = ($Apache::lonxml::counter+$increment).') '; |
|
} else { |
|
$bit .= ' Answer for Part: \verb|'. |
|
$Apache::inputtags::part.'| '; |
|
} |
|
push(@answer_bits,$bit); |
} else { |
} else { |
$result = '<table border="1"><tr><td>Answer for Part:'. |
$result = '<table border="1"><tr>'; |
$Apache::inputtags::part. '</td>'."\n"; |
if ($Apache::lonhomework::type eq 'exam') { |
|
$result .= '<td>'.($Apache::lonxml::counter+$increment). ')</td>'; |
|
} else { |
|
$result .= '<td>Answer for Part:'.$Apache::inputtags::part.'</td>'; |
|
} |
|
$result .= "\n"; |
} |
} |
return $result; |
return $result; |
} |
} |
Line 617 sub answer_part {
|
Line 647 sub answer_part {
|
last; |
last; |
} |
} |
} |
} |
$result = '\verb'.$to_use.$answer.$to_use.'\\\\ \hline '; |
if ($answer ne '') { |
|
push(@answer_bits,'\verb'.$to_use.$answer.$to_use); |
|
} |
} else { |
} else { |
$result = '<td>'.$answer.'</td>'; |
$result = '<td>'.$answer.'</td>'; |
} |
} |
Line 628 sub answer_footer {
|
Line 660 sub answer_footer {
|
my ($type) = @_; |
my ($type) = @_; |
my $result; |
my $result; |
if ($env{'form.answer_output_mode'} eq 'tex') { |
if ($env{'form.answer_output_mode'} eq 'tex') { |
$result = ' \end{tabular} \vskip 0 mm '; |
my $columns = scalar(@answer_bits); |
|
$result = ' \vskip 0 mm \noindent \begin{tabular}{|'.'c|'x$columns.'}\hline '; |
|
$result .= join(' & ',@answer_bits); |
|
$result .= ' \\\\ \\hline \end{tabular} \vskip 0 mm '; |
} else { |
} else { |
$result = '</tr></table>'; |
$result = '</tr></table>'; |
} |
} |
return $result; |
return $result; |
} |
} |
|
|
|
} |
|
|
sub showallfoils { |
sub showallfoils { |
if (defined($env{'form.showallfoils'})) { |
if (defined($env{'form.showallfoils'})) { |
my ($symb)=&Apache::lonxml::whichuser(); |
my ($symb)=&Apache::lonxml::whichuser(); |
Line 858 sub submitted {
|
Line 895 sub submitted {
|
return 0; |
return 0; |
} |
} |
|
|
|
sub add_to_gradingqueue { |
|
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
|
if ( $courseid eq '' |
|
|| $symb eq '' |
|
|| $env{'request.state'} eq 'construct' |
|
|| $Apache::lonhomework::type ne 'problem') { |
|
return; |
|
} |
|
|
|
my %queue_info = ( 'type' => 'problem', |
|
'time' => time); |
|
|
|
if (exists($Apache::lonhomework::history{"resource.0.checkedin.slot"})) { |
|
$queue_info{'slot'}= |
|
$Apache::lonhomework::history{"resource.0.checkedin.slot"}; |
|
} |
|
|
|
my $result=&Apache::bridgetask::add_to_queue('gradingqueue',\%queue_info); |
|
if ($result ne 'ok') { |
|
&Apache::lonxml::error("add_to_queue said $result"); |
|
} |
|
} |
|
|
# basically undef and 0 (both false) mean that they still have work to do |
# basically undef and 0 (both false) mean that they still have work to do |
# and all true values mean that they can't do any more work |
# and all true values mean that they can't do any more work |
# |
# |