version 1.267, 2007/04/07 00:12:42
|
version 1.280, 2007/10/31 01:37:52
|
Line 63 BEGIN {
|
Line 63 BEGIN {
|
} |
} |
|
|
|
|
|
=pod |
|
|
|
=item set_bubble_lines() |
|
|
|
Called at analysis time to set the bubble lines |
|
hash for the problem.. This should be called in the |
|
end_problemtype tag in analysis mode. |
|
|
|
We fetch the hash of part id counters from lonxml |
|
and push them into analyze:{part_id.bubble_lines}. |
|
|
|
=cut |
|
|
|
sub set_bubble_lines { |
|
my %bubble_counters = &Apache::lonxml::get_bubble_line_hash(); |
|
|
|
foreach my $key (keys(%bubble_counters)) { |
|
$Apache::lonhomework::analyze{"$key.bubble_lines"} = |
|
$bubble_counters{"$key"}; |
|
} |
|
} |
|
|
# |
# |
# Decides what targets to render for. |
# Decides what targets to render for. |
# Implicit inputs: |
# Implicit inputs: |
Line 188 sub proctor_checked_in {
|
Line 210 sub proctor_checked_in {
|
return 0; |
return 0; |
} |
} |
|
|
$Apache::lonxml::browse=''; |
|
sub check_ip_acc { |
sub check_ip_acc { |
my ($acc)=@_; |
my ($acc)=@_; |
&Apache::lonxml::debug("acc is $acc"); |
&Apache::lonxml::debug("acc is $acc"); |
Line 196 sub check_ip_acc {
|
Line 217 sub check_ip_acc {
|
return 1; |
return 1; |
} |
} |
my $allowed=0; |
my $allowed=0; |
my $ip=$ENV{'REMOTE_ADDR'}; |
my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'}; |
|
|
my $name; |
my $name; |
foreach my $pattern (split(',',$acc)) { |
foreach my $pattern (split(',',$acc)) { |
$pattern =~ s/^\s*//; |
$pattern =~ s/^\s*//; |
Line 376 sub check_access {
|
Line 398 sub check_access {
|
if ($env{'request.state'} eq "construct") { |
if ($env{'request.state'} eq "construct") { |
if ($env{'form.problemstate'}) { |
if ($env{'form.problemstate'}) { |
if ($env{'form.problemstate'} =~ /^CANNOT_ANSWER/) { |
if ($env{'form.problemstate'} =~ /^CANNOT_ANSWER/) { |
if ( ! ($env{'form.problemstate'} eq 'CANNOT_ANSWER_correct' && |
if ( ! ($env{'form.problemstate'} eq 'CANNOT_ANSWER_correct' |
lc($Apache::lonhomework::problemstatus) eq 'no')) { |
&& &hide_problem_status())) { |
return ('CANNOT_ANSWER', |
return ('CANNOT_ANSWER', |
&mt('is in this state due to author settings.')); |
&mt('is in this state due to author settings.')); |
} |
} |
Line 436 sub check_access {
|
Line 458 sub check_access {
|
$date = &mt("an indeterminate date"); $passed = 0; |
$date = &mt("an indeterminate date"); $passed = 0; |
} else { |
} else { |
if (time < $date) { $passed = 0; } else { $passed = 1; } |
if (time < $date) { $passed = 0; } else { $passed = 1; } |
$date = localtime $date; |
$date = &Apache::lonlocal::locallocaltime($date); |
} |
} |
if (!$passed) { $type=$temp; last; } |
if (!$passed) { $type=$temp; last; } |
} |
} |
Line 467 sub check_access {
|
Line 489 sub check_access {
|
# if (correct and show prob status) or excused then CANNOT_ANSWER |
# if (correct and show prob status) or excused then CANNOT_ANSWER |
if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/ |
if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/ |
&& |
&& |
lc($Apache::lonhomework::problemstatus) ne 'no') |
&show_problem_status()) |
|| |
|| |
$Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { |
$Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { |
$status = 'CANNOT_ANSWER'; |
$status = 'CANNOT_ANSWER'; |
Line 724 sub analyze_header {
|
Line 746 sub analyze_header {
|
<form name="lonhomework" method="POST" action="'. |
<form name="lonhomework" method="POST" action="'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&Apache::structuretags::remember_problem_state().' |
&Apache::structuretags::remember_problem_state().' |
|
<div class="LC_edit_problem_analyze_header"> |
<input type="submit" name="problemmode" value="'.&mt("EditXML").'" /> |
<input type="submit" name="problemmode" value="'.&mt("EditXML").'" /> |
<input type="submit" name="problemmode" value="'.&mt('Edit').'" /> |
<input type="submit" name="problemmode" value="'.&mt('Edit').'" /> |
<hr /> |
<hr class="LC_edit_problem_divide" /> |
|
|
<input type="submit" name="submit" value="'.&mt("View").'" /> |
<input type="submit" name="submit" value="'.&mt("View").'" /> |
<hr /> |
<hr class="LC_edit_problem_divide" /> |
|
</div> |
</form>'; |
</form>'; |
&Apache::lonxml::add_messages(\$result); |
&Apache::lonxml::add_messages(\$result); |
$request->print($result); |
$request->print($result); |
Line 788 sub analyze {
|
Line 813 sub analyze {
|
$i++; |
$i++; |
} |
} |
} |
} |
|
if (!keys(%{ $analyze{$part.'.answer'} })) { |
|
my $answer_part = |
|
['<span class="LC_error">'.&mt('Error').'</span>']; |
|
$seedexample{join("\0",$part,0,@{$answer_part})}= |
|
$thisseed; |
|
push( @{ $overall{$part.'.answer'}[0] }, |
|
$answer_part); |
|
} |
} |
} |
} |
} |
} |
} |
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, |
&Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state, |
&mt('Analyzing Results')); |
&mt('Analyzing Results')); |
$request->print('<hr />'.&mt('List of possible answers').': '); |
$request->print('<hr class="LC_edit_problem_divide" />'.&mt('List of possible answers').': '); |
foreach my $part (sort(keys(%allparts))) { |
foreach my $part (sort(keys(%allparts))) { |
if (defined(@{ $overall{$part.'.answer'} })) { |
if (defined(@{ $overall{$part.'.answer'} })) { |
for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) { |
for (my $i=0;$i<scalar(@{ $overall{$part.'.answer'} });$i++) { |
Line 831 sub analyze {
|
Line 864 sub analyze {
|
return $result; |
return $result; |
} |
} |
|
|
|
{ |
|
my $show_problem_status; |
|
sub reset_show_problem_status { |
|
undef($show_problem_status); |
|
} |
|
|
|
sub set_show_problem_status { |
|
my ($new_status) = @_; |
|
$show_problem_status = lc($new_status); |
|
} |
|
|
|
sub hide_problem_status { |
|
return ($show_problem_status eq 'no' |
|
|| $show_problem_status eq 'no_feedback_ever'); |
|
} |
|
|
|
sub show_problem_status { |
|
return ($show_problem_status eq 'yes' |
|
|| $show_problem_status eq ''); |
|
} |
|
|
|
sub show_some_problem_status { |
|
return ($show_problem_status eq 'no'); |
|
} |
|
|
|
sub show_no_problem_status { |
|
return ($show_problem_status eq 'no_feedback_ever'); |
|
} |
|
} |
|
|
sub editxmlmode { |
sub editxmlmode { |
my ($request,$file) = @_; |
my ($request,$file) = @_; |
my $result; |
my $result; |
Line 861 sub editxmlmode {
|
Line 924 sub editxmlmode {
|
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; } |
|
my $js = |
|
&Apache::edit::js_change_detection(). |
|
&Apache::loncommon::resize_textarea_js(); |
|
my $only_body = ($env{'environment.remote'} eq 'off')? 0 : 1; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file), |
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js, |
&Apache::edit::js_change_detection(), |
{'no_auto_mt_title' => 1, |
{'no_auto_mt_title' => 1,}); |
'only_body' => $only_body, |
|
'add_entries' => { |
|
'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
|
'onload' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
|
}}); |
|
|
$result.=$start_page. |
$result.=$start_page. |
&renderpage($request,$file,['no_output_web'],1). |
&renderpage($request,$file,['no_output_web'],1). |
Line 872 sub editxmlmode {
|
Line 943 sub editxmlmode {
|
<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'. |
<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&Apache::structuretags::remember_problem_state().' |
&Apache::structuretags::remember_problem_state().' |
<input type="hidden" name="problemmode" value="'.&mt('EditXML').'" /> |
<div class="LC_edit_problem_editxml_header"> |
<input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" /> |
<table class="LC_edit_problem_header_title"><tr><td> |
<input type="submit" '.&Apache::edit::submit_ask_anyway().'name="problemmode" accesskey="e" value="'.&mt('Edit').'" /> |
'.&mt('Problem Editing').&Apache::loncommon::help_open_topic('Problem_Editor_XML_Index').' |
<input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> |
</td><td align="right"> |
<hr /> |
'.&Apache::loncommon::helpLatexCheatsheet().' |
<input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes').'" /> |
</td></tr> |
<input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" /> |
</table> |
<hr /> |
<div class="LC_edit_problem_discards"> |
' . $xml_help . ' |
<input type="hidden" name="problemmode" value="'.&mt('EditXML').'" /> |
<textarea '.&Apache::edit::element_change_detection().' style="width:100%" rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'. |
<input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" /> |
&HTML::Entities::encode($problem,'<>&"').'</textarea><br /> |
<input type="submit" '.&Apache::edit::submit_ask_anyway().'name="problemmode" accesskey="e" value="'.&mt('Edit').'" /> |
<input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes').'" /> |
<input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> |
<input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" /> |
</div> |
|
<div class="LC_edit_problem_saves"> |
|
<input type="submit" name="submit" accesskey="s" value="'.&mt('Save').'" /> |
|
<input type="submit" name="submit" accesskey="v" value="'.&mt('Save and View').'" /> |
|
</div> |
|
<hr class="LC_edit_problem_divide" /> |
|
</div> |
|
' . ' |
|
<textarea '.&Apache::edit::element_change_detection(). |
|
' rows="'.$rows.'" cols="'.$cols.'" style="width:100%" '. |
|
' name="editxmltext" id="LC_editxmltext">'. |
|
&HTML::Entities::encode($problem,'<>&"').'</textarea> |
|
<div id="LC_aftertextarea"> |
|
</div> |
</form>'.&Apache::loncommon::end_page(); |
</form>'.&Apache::loncommon::end_page(); |
&Apache::lonxml::add_messages(\$result); |
&Apache::lonxml::add_messages(\$result); |
$request->print($result); |
$request->print($result); |
Line 901 sub renderpage {
|
Line 985 sub renderpage {
|
my @targets = @{$targets || [&get_target()]}; |
my @targets = @{$targets || [&get_target()]}; |
&Apache::lonhomework::showhashsubset(\%env,'form.'); |
&Apache::lonhomework::showhashsubset(\%env,'form.'); |
&Apache::lonxml::debug("Running targets ".join(':',@targets)); |
&Apache::lonxml::debug("Running targets ".join(':',@targets)); |
|
|
my $overall_result; |
my $overall_result; |
foreach my $target (@targets) { |
foreach my $target (@targets) { |
# FIXME need to do something intelligent when a problem goes |
# FIXME need to do something intelligent when a problem goes |
Line 938 sub renderpage {
|
Line 1023 sub renderpage {
|
&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); |
&finished_parsing(); |
if (!$output) { $result = ''; } |
if (!$output) { $result = ''; } |
#$request->print("Result follows:"); |
#$request->print("Result follows:"); |
if ($target eq 'modified') { |
if ($target eq 'modified') { |
Line 969 sub renderpage {
|
Line 1054 sub renderpage {
|
} |
} |
} |
} |
|
|
|
sub finished_parsing { |
|
undef($Apache::lonhomework::parsing_a_problem); |
|
undef($Apache::lonhomework::parsing_a_task); |
|
} |
|
|
# with no arg it returns a HTML <option> list of the template titles |
# with no arg it returns a HTML <option> list of the template titles |
# with one arg it returns the filename associated with the arg passed |
# with one arg it returns the filename associated with the arg passed |
sub get_template_list { |
sub get_template_list { |
Line 977 sub get_template_list {
|
Line 1067 sub get_template_list {
|
my @allnames; |
my @allnames; |
&Apache::lonxml::debug("Looking for :$extension:"); |
&Apache::lonxml::debug("Looking for :$extension:"); |
foreach my $file (</home/httpd/html/res/adm/includes/templates/*.$extension>) { |
foreach my $file (</home/httpd/html/res/adm/includes/templates/*.$extension>) { |
|
&Apache::lonxml::debug("Looking at $file"); |
my $name=&Apache::lonnet::metadata($file,'title'); |
my $name=&Apache::lonnet::metadata($file,'title'); |
|
&Apache::lonxml::debug("Got a name $name"); |
if ($namewanted && ($name eq $namewanted)) { |
if ($namewanted && ($name eq $namewanted)) { |
$result=$file; |
$result=$file; |
last; |
last; |
Line 1047 $errormsg
|
Line 1139 $errormsg
|
return ''; |
return ''; |
} |
} |
|
|
|
sub update_construct_style { |
|
if ($env{'request.state'} eq "construct" |
|
&& $env{'form.problemmode'} eq &mt('View') |
|
&& defined($env{'form.submitted'}) |
|
&& !defined($env{'form.resetdata'}) |
|
&& !defined($env{'form.newrandomization'})) { |
|
if ((!$env{'form.style_file'} && $env{'construct.style'}) |
|
||$env{'form.clear_style_file'}) { |
|
&Apache::lonnet::delenv('construct\\.style'); |
|
} elsif ($env{'form.style_file'} |
|
&& $env{'construct.style'} ne $env{'form.style_file'}) { |
|
&Apache::lonnet::appenv('construct.style' => |
|
$env{'form.style_file'}); |
|
} |
|
} |
|
} |
|
|
|
|
sub handler { |
sub handler { |
#my $t0 = [&gettimeofday()]; |
#my $t0 = [&gettimeofday()]; |
my $request=$_[0]; |
my $request=$_[0]; |
Line 1097 sub handler {
|
Line 1207 sub handler {
|
} elsif ($env{'form.problemmode'} eq &mt('Calculate answers')) { |
} elsif ($env{'form.problemmode'} eq &mt('Calculate answers')) { |
&analyze($request,$file); |
&analyze($request,$file); |
} else { |
} else { |
|
&update_construct_style(); |
&renderpage($request,$file); |
&renderpage($request,$file); |
} |
} |
} else { |
} else { |