--- loncom/homework/lonhomework.pm 2002/02/27 20:23:26 1.71
+++ loncom/homework/lonhomework.pm 2002/08/16 21:30:08 1.86
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Homework handler
#
-# $Id: lonhomework.pm,v 1.71 2002/02/27 20:23:26 albertel Exp $
+# $Id: lonhomework.pm,v 1.86 2002/08/16 21:30:08 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -28,20 +28,29 @@
# Guy Albertelli
# 11/30 Gerd Kortemeyer
# 6/1,8/17,8/18 Gerd Kortemeyer
+# 7/18 Jeremy Bowers
package Apache::lonhomework;
use strict;
-use Apache::style;
-use Apache::lonxml;
-use Apache::lonnet;
-use Apache::lonplot;
-use Apache::inputtags;
-use Apache::structuretags;
-use Apache::randomlabel;
-use Apache::response;
-use Apache::hint;
-use Apache::outputtags;
+use Apache::style();
+use Apache::lonxml();
+use Apache::lonnet();
+use Apache::lonplot();
+use Apache::inputtags();
+use Apache::structuretags();
+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 {
@@ -60,6 +69,9 @@ sub get_target {
return ('web');
}
} elsif ($ENV{'request.state'} eq "construct") {
+ if ( defined($ENV{'form.grade_target'}) ) {
+ return ($ENV{'form.grade_target'});
+ }
if ( defined($ENV{'form.preview'})) {
if ( defined($ENV{'form.submitted'})) {
return ('grade', 'web');
@@ -76,7 +88,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');
}
@@ -128,6 +144,7 @@ sub check_access {
my $type;
my $passed;
&Apache::lonxml::debug("checking for part :$id:");
+ &Apache::lonxml::debug("time:".time);
foreach $temp ("opendate","duedate","answerdate") {
$lastdate = $date;
$date = &Apache::lonnet::EXT("resource.$id.$temp");
@@ -187,9 +204,30 @@ sub check_access {
sub showhash {
my (%hash) = @_;
+ &showhashsubset(\%hash,'');
+ return '';
+}
+
+sub showhashsubset {
+ my ($hash,$keyre) = @_;
my $resultkey;
- foreach $resultkey (sort keys %hash) {
- &Apache::lonxml::debug("$resultkey ---- $hash{$resultkey}");
+ 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}");
+ }
+ } else {
+ &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
+ }
+ }
}
&Apache::lonxml::debug("\n
restored values^\n");
return '';
@@ -255,6 +293,16 @@ sub handle_save_or_undo {
return $error;
}
+sub analyze {
+ my ($request,$file) = @_;
+ &Apache::lonxml::debug("Analyze");
+ my $result=&Apache::lonnet::ssi($request->uri,('grade_target' => 'analyze'));
+ &Apache::lonxml::debug(":$result:");
+ (my $garbage,$result)=split(/_HASH_REF__/,$result,2);
+ &showhash(&Apache::lonnet::str2hash($result));
+ return $result;
+}
+
sub editxmlmode {
my ($request,$file) = @_;
my $result;
@@ -268,22 +316,32 @@ 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.='