version 1.107, 2003/01/28 00:13:37
|
version 1.117, 2003/03/25 23:07:07
|
Line 339 sub handle_save_or_undo {
|
Line 339 sub handle_save_or_undo {
|
|
|
sub analyze_header { |
sub analyze_header { |
my ($request) = @_; |
my ($request) = @_; |
my $result.='<html><body bgcolor="#FFFFFF"> |
my $result.='<html> |
|
<head><title>Analyzing a problem</title></head> |
|
<body bgcolor="#FFFFFF"> |
<form name="lonhomework" method="POST" action="'. |
<form name="lonhomework" method="POST" action="'. |
$ENV{'request.uri'}.'"> |
$ENV{'request.uri'}.'"> |
<input type="submit" name="problemmode" value="EditXML" /> |
<input type="submit" name="problemmode" value="EditXML" /> |
Line 353 sub analyze_header {
|
Line 355 sub analyze_header {
|
$request->rflush(); |
$request->rflush(); |
} |
} |
|
|
|
sub analyze_footer { |
|
my ($request) = @_; |
|
my $result='</body></html>'; |
|
$request->print($result); |
|
$request->rflush(); |
|
} |
|
|
sub analyze { |
sub analyze { |
my ($request,$file) = @_; |
my ($request,$file) = @_; |
&Apache::lonxml::debug("Analyze"); |
&Apache::lonxml::debug("Analyze"); |
Line 361 sub analyze {
|
Line 370 sub analyze {
|
my %allparts; |
my %allparts; |
my $rndseed=$ENV{'form.rndseed'}; |
my $rndseed=$ENV{'form.rndseed'}; |
&analyze_header($request); |
&analyze_header($request); |
|
my %prog_state= |
|
&Apache::lonhtmlcommon::Create_PrgWin($request,'Analyze Progress', |
|
'Getting Problem Variants', |
|
$ENV{'form.numtoanalyze'}); |
for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) { |
for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) { |
|
&Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state, |
|
'last problem'); |
my $subresult=&Apache::lonnet::ssi($request->uri, |
my $subresult=&Apache::lonnet::ssi($request->uri, |
('grade_target' => 'analyze'), |
('grade_target' => 'analyze'), |
('rndseed' => $i)); |
('rndseed' => $i)); |
&Apache::lonxml::debug(":$subresult:"); |
&Apache::lonxml::debug(":$subresult:"); |
(my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); |
(my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
my %analyze=&Apache::lonnet::str2hash($subresult); |
&Apache::lonhomework::showhash(%analyze); |
my @parts; |
my @parts = @{ $analyze{'parts'} }; |
if (defined(@{ $analyze{'parts'} })) { |
|
@parts=@{ $analyze{'parts'} }; |
|
} |
foreach my $part (@parts) { |
foreach my $part (@parts) { |
if (!exists($allparts{$part})) {$allparts{$part}=1;}; |
if (!exists($allparts{$part})) {$allparts{$part}=1;}; |
if ($analyze{$part.'.type'} eq 'numericalresponse') { |
if ($analyze{$part.'.type'} eq 'numericalresponse' || |
|
$analyze{$part.'.type'} eq 'stringresponse' || |
|
$analyze{$part.'.type'} eq 'formularesponse' ) { |
push( @{ $overall{$part.'.answer'} }, |
push( @{ $overall{$part.'.answer'} }, |
[@{ $analyze{$part.'.answer'} }]); |
[@{ $analyze{$part.'.answer'} }]); |
} |
} |
} |
} |
} |
} |
|
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, |
|
'Analyzing Results'); |
foreach my $part (keys(%allparts)) { |
foreach my $part (keys(%allparts)) { |
$request->print('<table><tr><td>Part '.$part.'</td></tr>'); |
if (defined(@{ $overall{$part.'.answer'} })) { |
foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) { |
$request->print('<table><tr><td>Part '.$part.'</td></tr>'); |
$request->print('<tr><td>'.join('</td><td>',@{ $answer }). |
foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) { |
'</td></tr>'); |
$request->print('<tr><td>'.join('</td><td>',@{ $answer }). |
|
'</td></tr>'); |
|
} |
|
$request->print('</table>'); |
|
} else { |
|
$request->print('<p>Part '.$part. |
|
' is not analyzabale at this time</p>'); |
} |
} |
} |
} |
|
&Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state); |
|
&analyze_footer($request); |
&Apache::lonhomework::showhash(%overall); |
&Apache::lonhomework::showhash(%overall); |
return $result; |
return $result; |
} |
} |
Line 393 sub editxmlmode {
|
Line 422 sub editxmlmode {
|
my ($request,$file) = @_; |
my ($request,$file) = @_; |
my $result; |
my $result; |
my $problem=&Apache::lonnet::getfile($file); |
my $problem=&Apache::lonnet::getfile($file); |
if ($problem == -1) { |
if ($problem eq -1) { |
&Apache::lonxml::error("<b> Unable to find <i>$file</i></b>"); |
&Apache::lonxml::error("<b> Unable to find <i>$file</i></b>"); |
$problem=''; |
$problem=''; |
} |
} |
Line 409 sub editxmlmode {
|
Line 438 sub editxmlmode {
|
&renderpage($request,$file); |
&renderpage($request,$file); |
} else { |
} else { |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem); |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem); |
my $xml_help = Apache::loncommon::help_open_topic("Problem_Editor_XML_Index"); |
my $xml_help = '<table><tr><td>'. |
|
&Apache::loncommon::help_open_topic("Problem_Editor_XML_Index",'Problem Editing Help') |
|
.'</td><td>'. |
|
&Apache::loncommon::help_open_topic("Greek_Symbols",'Greek Symbols', |
|
undef,undef,600) |
|
.'</td><td>'. |
|
&Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols', |
|
undef,undef,600) |
|
.'</td></tr></table>'; |
if ($cols > 80) { $cols = 80; } |
if ($cols > 80) { $cols = 80; } |
if ($cols < 70) { $cols = 70; } |
if ($cols < 70) { $cols = 70; } |
if ($rows < 20) { $rows = 20; } |
if ($rows < 20) { $rows = 20; } |
Line 424 sub editxmlmode {
|
Line 461 sub editxmlmode {
|
<input type="submit" name="submit" value="Submit Changes and View" /> |
<input type="submit" name="submit" value="Submit Changes and View" /> |
<input type="submit" name="Undo" value="undo" /> |
<input type="submit" name="Undo" value="undo" /> |
<hr /> |
<hr /> |
' . $xml_help . ' Problem Help<br> |
' . $xml_help . ' |
<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'. |
<textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'. |
&HTML::Entities::encode($problem).'</textarea> |
&HTML::Entities::encode($problem).'</textarea> |
</form></body></html>'; |
</form></body></html>'; |
Line 441 sub renderpage {
|
Line 478 sub renderpage {
|
foreach my $target (@targets) { |
foreach my $target (@targets) { |
#my $t0 = [&gettimeofday()]; |
#my $t0 = [&gettimeofday()]; |
my $problem=&Apache::lonnet::getfile($file); |
my $problem=&Apache::lonnet::getfile($file); |
if ($problem == -1) { |
if ($problem eq -1) { |
&Apache::lonxml::error("<b> Unable to find <i>$file</i></b>"); |
&Apache::lonxml::error("<b> Unable to find <i>$file</i></b>"); |
$problem=''; |
$problem=''; |
} |
} |
|
|
my %mystyle; |
my %mystyle; |
my $result = ''; |
my $result = ''; |
&Apache::inputtags::initialize_inputtags(); |
if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); } |
&Apache::outputtags::initialize_outputtags(); |
|
&Apache::edit::initialize_edit(); |
|
if ($target eq 'analyze') { %Apache::lonhomework::anaylze=(); } |
|
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); } |
if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); } |
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%ENV,'^form');} |
if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%ENV,'^form');} |
|
|
&Apache::lonxml::debug("Should be parsing now"); |
&Apache::lonxml::debug("Should be parsing now"); |
$result = &Apache::lonxml::xmlparse($request, $target, $problem, |
$result = &Apache::lonxml::xmlparse($request, $target, $problem, |
&setup_vars($target),%mystyle); |
&setup_vars($target),%mystyle); |
|
undef($Apache::lonhomework::parsing_a_problem); |
#$request->print("Result follows:"); |
#$request->print("Result follows:"); |
if ($target eq 'modified') { |
if ($target eq 'modified') { |
&handle_save_or_undo($request,\$problem,\$result); |
&handle_save_or_undo($request,\$problem,\$result); |
Line 473 sub renderpage {
|
Line 507 sub renderpage {
|
#$result.="<br />Spent $td seconds processing target $target\n</body>"; |
#$result.="<br />Spent $td seconds processing target $target\n</body>"; |
#} |
#} |
$request->print($result); |
$request->print($result); |
|
$request->rflush(); |
} |
} |
#$request->print(":Result ends"); |
#$request->print(":Result ends"); |
#my $td=&tv_interval($t0); |
#my $td=&tv_interval($t0); |
Line 496 sub get_template_list {
|
Line 531 sub get_template_list {
|
} |
} |
} |
} |
if (@allnames && !$result) { |
if (@allnames && !$result) { |
$result="<option>Select a $extension type</option>\n<option>". |
$result="<option>Select a $extension template</option>\n<option>". |
join('</option><option>',sort(@allnames)).'</option>'; |
join('</option><option>',sort(@allnames)).'</option>'; |
} |
} |
return $result; |
return $result; |