version 1.286, 2007/11/20 17:53:22
|
version 1.295, 2008/07/07 11:02:25
|
Line 137 sub get_target {
|
Line 137 sub get_target {
|
if ($env{'form.problemstate'} eq 'WEB_GRADE') { |
if ($env{'form.problemstate'} eq 'WEB_GRADE') { |
#$env{'form.webgrade'} = 'yes'; |
#$env{'form.webgrade'} = 'yes'; |
return ('grade','webgrade','answer'); |
return ('grade','webgrade','answer'); |
} elsif ( $env{'form.problemmode'} eq &mt('View') || |
} elsif (($env{'form.problemmode'} eq 'view') || |
$env{'form.problemmode'} eq &mt('Discard Edits and View')) { |
($env{'form.problemmode'} eq 'discard')) { |
if ( defined($env{'form.submitted'}) && |
if ( defined($env{'form.submitted'}) && |
(!defined($env{'form.resetdata'})) && |
(!defined($env{'form.resetdata'})) && |
(!defined($env{'form.newrandomization'}))) { |
(!defined($env{'form.newrandomization'}))) { |
Line 146 sub get_target {
|
Line 146 sub get_target {
|
} else { |
} else { |
return ('web','answer'); |
return ('web','answer'); |
} |
} |
} elsif ( $env{'form.problemmode'} eq &mt('Edit') || |
} elsif ($env{'form.problemmode'} eq 'edit') { |
$env{'form.problemmode'} eq 'Edit') { |
|
if ( $env{'form.submitted'} eq 'edit' ) { |
if ( $env{'form.submitted'} eq 'edit' ) { |
if ( $env{'form.submit'} eq &mt('Save and View') ) { |
if ( $env{'form.submitbutton'} eq &mt('Save and View') ) { |
return ('modified','web','answer'); |
return ('modified','web','answer'); |
} else { |
} else { |
return ('modified','no_output_web','edit'); |
return ('modified','no_output_web','edit'); |
Line 292 sub check_slot_access {
|
Line 291 sub check_slot_access {
|
} |
} |
} |
} |
|
|
my @slots= |
my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent"); |
(split(':',&Apache::lonnet::EXT("resource.0.availablestudent")), |
my $available = &Apache::lonnet::EXT("resource.0.available"); |
split(':',&Apache::lonnet::EXT("resource.0.available"))); |
my @slots= (split(':',$availablestudent),split(':',$available)); |
|
|
# if (!@slots) { |
# if (!@slots) { |
# return ($status,$datemsg); |
# return ($status,$datemsg); |
Line 421 sub check_access {
|
Line 420 sub check_access {
|
&Apache::lonxml::debug("symb:".$symb); |
&Apache::lonxml::debug("symb:".$symb); |
#if ($env{'request.state'} ne "construct" && $symb ne '') { |
#if ($env{'request.state'} ne "construct" && $symb ne '') { |
if ($env{'request.state'} ne "construct") { |
if ($env{'request.state'} ne "construct") { |
my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); |
my $idacc = &Apache::lonnet::EXT("resource.$id.acc"); |
|
my $allowed=&check_ip_acc($idacc); |
if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { |
if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { |
$status='INVALID_ACCESS'; |
$status='INVALID_ACCESS'; |
$date=&mt("can not be accessed from your location."); |
$date=&mt("can not be accessed from your location."); |
Line 712 sub handle_save_or_undo {
|
Line 712 sub handle_save_or_undo {
|
my $fs=Apache::File->new(">$filebak"); |
my $fs=Apache::File->new(">$filebak"); |
if (defined($fs)) { |
if (defined($fs)) { |
print $fs $$problem; |
print $fs $$problem; |
&Apache::lonxml::info("<b>".&mt("Making Backup to [_1]", |
|
'<span class="LC_filename">'. |
|
$filebak.'</span>'). |
|
"</b>"); |
|
} else { |
} else { |
&Apache::lonxml::info("<span class=\"LC_error\">". |
&Apache::lonxml::info("<span class=\"LC_error\">". |
&mt("Unable to make backup [_1]", |
&mt("Unable to make backup [_1]", |
Line 726 sub handle_save_or_undo {
|
Line 722 sub handle_save_or_undo {
|
my $fh=Apache::File->new(">$file"); |
my $fh=Apache::File->new(">$file"); |
if (defined($fh)) { |
if (defined($fh)) { |
print $fh $$result; |
print $fh $$result; |
&Apache::lonxml::info("<b>".&mt("Saving Modifications to [_1]", |
|
'<span class="LC_filename">'. |
|
$file.'</span>' )."</b>"); |
|
} else { |
} else { |
&Apache::lonxml::info('<span class="LC_error">'. |
&Apache::lonxml::info('<span class="LC_error">'. |
&mt("Unable to write to [_1]", |
&mt("Unable to write to [_1]", |
Line 743 sub handle_save_or_undo {
|
Line 736 sub handle_save_or_undo {
|
|
|
sub analyze_header { |
sub analyze_header { |
my ($request) = @_; |
my ($request) = @_; |
|
my $js = &Apache::structuretags::setmode_javascript(); |
my $result = |
my $result = |
&Apache::loncommon::start_page('Analyzing a problem',undef); |
&Apache::loncommon::start_page('Analyzing a problem',$js); |
|
|
$result .= |
$result .= |
&Apache::lonxml::message_location().' |
&Apache::lonxml::message_location().' |
<form name="lonhomework" method="POST" action="'. |
<form name="lonhomework" method="POST" action="'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
&HTML::Entities::encode($env{'request.uri'},'<>&"').'">'. |
|
'<input type="hidden" name="problemmode" value="'. |
|
$env{'form.problemmode'}.'" />'. |
&Apache::structuretags::remember_problem_state().' |
&Apache::structuretags::remember_problem_state().' |
<div class="LC_edit_problem_analyze_header"> |
<div class="LC_edit_problem_analyze_header"> |
<input type="submit" name="problemmode" value="'.&mt("EditXML").'" /> |
<input type="button" name="submitmode" value="'.&mt("EditXML").'" '. |
<input type="submit" name="problemmode" value="'.&mt('Edit').'" /> |
'onclick="javascript:setmode(this.form,'."'editxml'".')" /> |
|
<input type="button" name="submitmode" value="'.&mt('Edit').'" '. |
|
'onclick="javascript:setmode(this.form,'."'edit'".')" /> |
<hr class="LC_edit_problem_divide" /> |
<hr class="LC_edit_problem_divide" /> |
|
<input type="button" name="submitmode" value="'.&mt("View").'" '. |
<input type="submit" name="submit" value="'.&mt("View").'" /> |
'onclick="javascript:setmode(this.form,'."'view'".')" /> |
<hr class="LC_edit_problem_divide" /> |
<hr class="LC_edit_problem_divide" /> |
</div> |
</div> |
</form>'; |
</form>'; |
Line 919 sub editxmlmode {
|
Line 917 sub editxmlmode {
|
if (!$error) { $problem=&Apache::lonnet::getfile($file); } |
if (!$error) { $problem=&Apache::lonnet::getfile($file); } |
} |
} |
&Apache::lonhomework::showhashsubset(\%env,'^form'); |
&Apache::lonhomework::showhashsubset(\%env,'^form'); |
if ( $env{'form.submit'} eq &mt('Save and View') ) { |
if ( $env{'form.submitbutton'} eq &mt('Save and View') ) { |
&Apache::lonhomework::showhashsubset(\%env,'^form'); |
&Apache::lonhomework::showhashsubset(\%env,'^form'); |
$env{'form.problemmode'}='View'; |
$env{'form.problemmode'}='view'; |
&renderpage($request,$file); |
&renderpage($request,$file); |
} else { |
} else { |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem); |
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem); |
Line 936 sub editxmlmode {
|
Line 934 sub editxmlmode {
|
if ($rows < 20) { $rows = 20; } |
if ($rows < 20) { $rows = 20; } |
my $js = |
my $js = |
&Apache::edit::js_change_detection(). |
&Apache::edit::js_change_detection(). |
&Apache::loncommon::resize_textarea_js(); |
&Apache::loncommon::resize_textarea_js(). |
|
&Apache::structuretags::setmode_javascript(); |
my $only_body = ($env{'environment.remote'} eq 'off')? 0 : 1; |
my $only_body = ($env{'environment.remote'} eq 'off')? 0 : 1; |
|
my $dragmath = &Apache::lonhtmlcommon::dragmath("LC_editxmltext"); |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js, |
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js, |
{'no_auto_mt_title' => 1, |
{'no_auto_mt_title' => 1, |
Line 946 sub editxmlmode {
|
Line 946 sub editxmlmode {
|
'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], |
'onload' => 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). |
'<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'. |
'<form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'. |
Line 960 sub editxmlmode {
|
Line 959 sub editxmlmode {
|
</td></tr> |
</td></tr> |
</table> |
</table> |
<div class="LC_edit_problem_discards"> |
<div class="LC_edit_problem_discards"> |
<input type="hidden" name="problemmode" value="'.&mt('EditXML').'" /> |
<input type="hidden" name="problemmode" value="editxml" /> |
<input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" /> |
|
<input type="submit" '.&Apache::edit::submit_ask_anyway().'name="problemmode" accesskey="e" value="'.&mt('Edit').'" /> |
<input type="button" name="submitmode" accesskey="d" value="'.&mt('Discard Edits and View').'" '. |
|
'onclick="javascript:setmode(this.form,'."'discard'".')" /> |
|
<input type="button" '.&Apache::edit::submit_ask_anyway('setmode(this.form,'."'edit'".')').'name="submitmode" accesskey="e" value="'.&mt('Edit').'" /> |
<input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> |
<input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> |
</div> |
</div> |
<div class="LC_edit_problem_saves"> |
<div class="LC_edit_problem_saves"> |
<input type="submit" name="submit" accesskey="s" value="'.&mt('Save').'" /> |
<input type="submit" name="submitbutton" accesskey="s" value="'.&mt('Save').'" /> |
<input type="submit" name="submit" accesskey="v" value="'.&mt('Save and View').'" /> |
<input type="submit" name="submitbutton" accesskey="v" value="'.&mt('Save and View').'" />' |
|
.$dragmath.' |
</div> |
</div> |
<hr class="LC_edit_problem_divide" /> |
<hr class="LC_edit_problem_divide" /> |
'.&Apache::lonxml::message_location().' |
'.&Apache::lonxml::message_location().' |
Line 1080 sub get_template_list {
|
Line 1082 sub get_template_list {
|
} |
} |
my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}. |
my @files = glob($Apache::lonnet::perlvar{'lonIncludes'}. |
'/templates/*.'.$glob_extension); |
'/templates/*.'.$glob_extension); |
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title'))]} (@files); |
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title')), |
@files = sort {$a->[1] cmp $b->[1]} (@files); |
(&Apache::lonnet::metadata($_, 'category')?&mt(&Apache::lonnet::metadata($_, 'category')):&mt('Miscellaneous')), |
|
&mt(&Apache::lonnet::metadata($_, 'help'))]} (@files); |
|
@files = sort {$a->[2].$a->[1] cmp $b->[2].$b->[1]} (@files); |
|
my ($midpoint,$seconddiv,$numfiles); |
|
$numfiles = 0; |
|
foreach my $file (@files) { |
|
next if ($file->[1] !~ /\S/); |
|
$numfiles ++; |
|
} |
|
if ($numfiles > 0) { |
|
$result = '<div class="LC_left_float">'; |
|
$midpoint = int($numfiles/2); |
|
if ($numfiles%2) { |
|
$midpoint ++; |
|
} |
|
} |
|
my $count = 0; |
|
my $currentcategory=''; |
foreach my $file (@files) { |
foreach my $file (@files) { |
next if ($file->[1] !~ /\S/); |
next if ($file->[1] !~ /\S/); |
|
if ($file->[2] ne $currentcategory) { |
|
$currentcategory=$file->[2]; |
|
if ((!$seconddiv) && ($count >= $midpoint)) { |
|
$result .= '</div>'."\n".'<div class="LC_left_float">'."\n"; |
|
$seconddiv = 1; |
|
} |
|
$result.='<h3>'.$currentcategory.'</h3>'; |
|
$count++; |
|
} |
$result .= |
$result .= |
'<label><input type="radio" name="template" value="'.$file->[0].'" />'. |
'<label><input type="radio" name="template" value="'.$file->[0].'" />'. |
$file->[1].'</label><br />'; |
$file->[1].'</label>'; |
|
if ($file->[3]) { |
|
$result.=&Apache::loncommon::help_open_topic($file->[3]); |
|
} |
|
my $filename=$file->[0]; |
|
$filename=~s/^\/home\/httpd\/html//; |
|
$result.=' <font size="-2"><a href="'.$filename.'" target="sample">'.&mt('Example').'</font></a><br />'."\n"; |
|
$count ++; |
|
} |
|
if ($numfiles > 0) { |
|
$result .= '</div>'."\n".'<div class="LC_clear_float_footer"></div>'."\n"; |
} |
} |
return $result; |
return $result; |
} |
} |
Line 1146 $errormsg
|
Line 1184 $errormsg
|
|
|
sub update_construct_style { |
sub update_construct_style { |
if ($env{'request.state'} eq "construct" |
if ($env{'request.state'} eq "construct" |
&& $env{'form.problemmode'} eq &mt('View') |
&& $env{'form.problemmode'} eq 'view' |
&& defined($env{'form.submitted'}) |
&& defined($env{'form.submitted'}) |
&& !defined($env{'form.resetdata'}) |
&& !defined($env{'form.resetdata'}) |
&& !defined($env{'form.newrandomization'})) { |
&& !defined($env{'form.newrandomization'})) { |
Line 1155 sub update_construct_style {
|
Line 1193 sub update_construct_style {
|
&Apache::lonnet::delenv('construct\\.style'); |
&Apache::lonnet::delenv('construct\\.style'); |
} elsif ($env{'form.style_file'} |
} elsif ($env{'form.style_file'} |
&& $env{'construct.style'} ne $env{'form.style_file'}) { |
&& $env{'construct.style'} ne $env{'form.style_file'}) { |
&Apache::lonnet::appenv('construct.style' => |
&Apache::lonnet::appenv({'construct.style' => |
$env{'form.style_file'}); |
$env{'form.style_file'}}); |
} |
} |
} |
} |
} |
} |
Line 1169 sub handler {
|
Line 1207 sub handler {
|
$Apache::lonxml::debug=$env{'user.debug'}; |
$Apache::lonxml::debug=$env{'user.debug'}; |
$env{'request.uri'}=$request->uri; |
$env{'request.uri'}=$request->uri; |
&setuppermissions(); |
&setuppermissions(); |
# some times multiple problemmodes are submitted, need to select |
|
# the last one |
|
if ( defined($env{'form.problemmode'}) && ref($env{'form.problemmode'}) ) { |
|
my $mode=$env{'form.problemmode'}->[-1]; |
|
undef $env{'form.problemmode'}; |
|
$env{'form.problemmode'}=$mode; |
|
} |
|
|
|
my $file=&Apache::lonnet::filelocation("",$request->uri); |
my $file=&Apache::lonnet::filelocation("",$request->uri); |
|
|
Line 1204 sub handler {
|
Line 1235 sub handler {
|
['problemmode']); |
['problemmode']); |
if (!(defined $env{'form.problemmode'})) { |
if (!(defined $env{'form.problemmode'})) { |
#first visit to problem in construction space |
#first visit to problem in construction space |
$env{'form.problemmode'}='View'; |
$env{'form.problemmode'}= 'view'; |
&renderpage($request,$file); |
&renderpage($request,$file); |
} elsif ($env{'form.problemmode'} eq &mt('EditXML') || |
} elsif ($env{'form.problemmode'} eq 'editxml') { |
$env{'form.problemmode'} eq 'EditXML') { |
|
&editxmlmode($request,$file); |
&editxmlmode($request,$file); |
} elsif ($env{'form.problemmode'} eq &mt('Calculate answers')) { |
} elsif ($env{'form.problemmode'} eq 'calcanswers') { |
&analyze($request,$file); |
&analyze($request,$file); |
} else { |
} else { |
&update_construct_style(); |
&update_construct_style(); |