--- loncom/homework/lonhomework.pm 2007/12/24 06:35:18 1.287
+++ loncom/homework/lonhomework.pm 2008/01/21 17:20:45 1.290
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.287 2007/12/24 06:35:18 raeburn Exp $
+# $Id: lonhomework.pm,v 1.290 2008/01/21 17:20:45 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -137,8 +137,8 @@ sub get_target {
if ($env{'form.problemstate'} eq 'WEB_GRADE') {
#$env{'form.webgrade'} = 'yes';
return ('grade','webgrade','answer');
- } elsif ( $env{'form.problemmode'} eq &mt('View') ||
- $env{'form.problemmode'} eq &mt('Discard Edits and View')) {
+ } elsif (($env{'form.problemmode'} eq 'view') ||
+ ($env{'form.problemmode'} eq 'discard')) {
if ( defined($env{'form.submitted'}) &&
(!defined($env{'form.resetdata'})) &&
(!defined($env{'form.newrandomization'}))) {
@@ -146,10 +146,9 @@ sub get_target {
} else {
return ('web','answer');
}
- } elsif ( $env{'form.problemmode'} eq &mt('Edit') ||
- $env{'form.problemmode'} eq 'Edit') {
+ } elsif ($env{'form.problemmode'} 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');
} else {
return ('modified','no_output_web','edit');
@@ -292,9 +291,9 @@ sub check_slot_access {
}
}
- my @slots=
- (split(':',&Apache::lonnet::EXT("resource.0.availablestudent")),
- split(':',&Apache::lonnet::EXT("resource.0.available")));
+ my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent");
+ my $available = &Apache::lonnet::EXT("resource.0.available");
+ my @slots= (split(':',$availablestudent),split(':',$available));
# if (!@slots) {
# return ($status,$datemsg);
@@ -421,7 +420,8 @@ sub check_access {
&Apache::lonxml::debug("symb:".$symb);
#if ($env{'request.state'} ne "construct" && $symb ne '') {
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')) {
$status='INVALID_ACCESS';
$date=&mt("can not be accessed from your location.");
@@ -712,10 +712,6 @@ sub handle_save_or_undo {
my $fs=Apache::File->new(">$filebak");
if (defined($fs)) {
print $fs $$problem;
- &Apache::lonxml::info("".&mt("Making Backup to [_1]",
- ''.
- $filebak.'').
- "");
} else {
&Apache::lonxml::info("".
&mt("Unable to make backup [_1]",
@@ -726,9 +722,6 @@ sub handle_save_or_undo {
my $fh=Apache::File->new(">$file");
if (defined($fh)) {
print $fh $$result;
- &Apache::lonxml::info("".&mt("Saving Modifications to [_1]",
- ''.
- $file.'' )."");
} else {
&Apache::lonxml::info(''.
&mt("Unable to write to [_1]",
@@ -743,20 +736,25 @@ sub handle_save_or_undo {
sub analyze_header {
my ($request) = @_;
+ my $js = &Apache::structuretags::setmode_javascript();
my $result =
- &Apache::loncommon::start_page('Analyzing a problem',undef);
+ &Apache::loncommon::start_page('Analyzing a problem',$js);
$result .=
&Apache::lonxml::message_location().'
';
@@ -919,9 +917,9 @@ sub editxmlmode {
if (!$error) { $problem=&Apache::lonnet::getfile($file); }
}
&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');
- $env{'form.problemmode'}='View';
+ $env{'form.problemmode'}='view';
&renderpage($request,$file);
} else {
my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
@@ -936,7 +934,8 @@ sub editxmlmode {
if ($rows < 20) { $rows = 20; }
my $js =
&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 $start_page =
&Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js,
@@ -946,7 +945,6 @@ sub editxmlmode {
'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],
'onload' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')],
}});
-
$result.=$start_page.
&renderpage($request,$file,['no_output_web'],1).
'