--- loncom/homework/lonhomework.pm 2002/03/29 18:32:46 1.74
+++ loncom/homework/lonhomework.pm 2002/10/14 16:43:58 1.93
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.74 2002/03/29 18:32:46 albertel Exp $
+# $Id: lonhomework.pm,v 1.93 2002/10/14 16:43:58 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -28,6 +28,7 @@
# Guy Albertelli
# 11/30 Gerd Kortemeyer
# 6/1,8/17,8/18 Gerd Kortemeyer
+# 7/18 Jeremy Bowers
package Apache::lonhomework;
use strict;
@@ -41,8 +42,15 @@ use Apache::randomlabel();
use Apache::response();
use Apache::hint();
use Apache::outputtags();
+use Apache::caparesponse();
+use Apache::radiobuttonresponse();
+use Apache::optionresponse();
+use Apache::imageresponse();
+use Apache::essayresponse();
+use Apache::externalresponse();
use Apache::Constants qw(:common);
use HTML::Entities();
+use Apache::loncommon();
#use Time::HiRes qw( gettimeofday tv_interval );
BEGIN {
@@ -51,10 +59,14 @@ BEGIN {
sub get_target {
if ( $ENV{'request.state'} eq "published") {
- if ( defined($ENV{'form.grade_target'})
+ if ( defined($ENV{'form.grade_target'} )
+ && ($ENV{'form.grade_target'} eq 'tex')) {
+ return ($ENV{'form.grade_target'});
+ } elsif ( defined($ENV{'form.grade_target'} )
&& ($Apache::lonhomework::viewgrades == 'F' )) {
return ($ENV{'form.grade_target'});
}
+
if ( defined($ENV{'form.submitted'})) {
return ('grade', 'web');
} else {
@@ -71,7 +83,8 @@ sub get_target {
return ('web');
}
} else {
- if ( $ENV{'form.problemmode'} eq 'View' ) {
+ if ( $ENV{'form.problemmode'} eq 'View' ||
+ $ENV{'form.problemmode'} eq 'Discard Edits and View') {
if ( defined($ENV{'form.submitted'}) &&
(!defined($ENV{'form.resetdata'})) ) {
return ('grade', 'web','answer');
@@ -80,7 +93,11 @@ sub get_target {
}
} elsif ( $ENV{'form.problemmode'} eq 'Edit' ) {
if ( $ENV{'form.submitted'} eq 'edit' ) {
- return ('modified','edit');
+ if ( $ENV{'form.submit'} eq 'Submit Changes and View' ) {
+ return ('modified','web','answer');
+ } else {
+ return ('modified','edit');
+ }
} else {
return ('edit');
}
@@ -122,6 +139,8 @@ sub send_footer {
$Apache::lonxml::browse='';
+# JB, 9/24/2002: Any changes in this function may require a change
+# in lonnavmaps::resource::getDateStatus.
sub check_access {
my ($id) = @_;
my $date ='';
@@ -136,6 +155,15 @@ sub check_access {
foreach $temp ("opendate","duedate","answerdate") {
$lastdate = $date;
$date = &Apache::lonnet::EXT("resource.$id.$temp");
+ my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");
+ if ($thistype eq 'date_interval') {
+ if ($temp eq 'opendate') {
+ $date=&Apache::lonnet::EXT("resource.$id.duedate")-$date;
+ }
+ if ($temp eq 'answerdate') {
+ $date=&Apache::lonnet::EXT("resource.$id.duedate")+$date;
+ }
+ }
&Apache::lonxml::debug("found :$date: for :$temp:");
if ($date eq '') {
$date = "an unknown date"; $passed = 0;
@@ -192,21 +220,29 @@ sub check_access {
sub showhash {
my (%hash) = @_;
+ &showhashsubset(\%hash,'');
+ return '';
+}
+
+sub showhashsubset {
+ my ($hash,$keyre) = @_;
my $resultkey;
- foreach $resultkey (sort keys %hash) {
- if (ref($hash{$resultkey})) {
- if ($hash{$resultkey} =~ /ARRAY/ ) {
- my $string="$resultkey ---- (";
- foreach my $elm (@{ $hash{$resultkey} }) {
- $string.="$elm,";
+ foreach $resultkey (sort keys %$hash) {
+ if ($resultkey =~ /$keyre/) {
+ if (ref($$hash{$resultkey})) {
+ if ($$hash{$resultkey} =~ /ARRAY/ ) {
+ my $string="$resultkey ---- (";
+ foreach my $elm (@{ $$hash{$resultkey} }) {
+ $string.="$elm,";
+ }
+ chop($string);
+ &Apache::lonxml::debug("$string)");
+ } else {
+ &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
}
- chop($string);
- &Apache::lonxml::debug("$string)");
} else {
- &Apache::lonxml::debug("$resultkey ---- $hash{$resultkey}");
+ &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
}
- } else {
- &Apache::lonxml::debug("$resultkey ---- $hash{$resultkey}");
}
}
&Apache::lonxml::debug("\n
restored values^\n");
@@ -296,22 +332,34 @@ sub editxmlmode {
\$ENV{'form.editxmltext'});
if (!$error) { $problem=&Apache::lonnet::getfile($file); }
}
- my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
- if ($cols > 80) { $cols = 80; }
- $result.='