--- loncom/homework/bridgetask.pm 2006/06/01 19:22:29 1.160
+++ loncom/homework/bridgetask.pm 2006/06/09 22:31:36 1.163
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.160 2006/06/01 19:22:29 albertel Exp $
+# $Id: bridgetask.pm,v 1.163 2006/06/09 22:31:36 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,7 +43,7 @@ use LONCAPA;
BEGIN {
- &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Instance','InstanceText','Criteria','ClosingParagraph'));
+ &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','ClosingParagraph'));
}
sub initialize_bridgetask {
@@ -365,26 +365,44 @@ sub file_list {
my $file=$file_url.$partial_file;
$file=~s|/+|/|g;
&Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
- $file_list.='
'.$file.
- ''."\n";
+ $file_list.=' '.$file.
+ ''."\n";
}
$file_list.="\n";
return $file_list;
}
+sub grade_mode {
+ if ($env{'form.regrade'} || $env{'form.regradeaspecificsubmission'}) {
+ return 'regrade';
+ }
+ return 'queue_grade';
+}
+
sub webgrade_standard_info {
my ($version)=&get_version();
my $file_list = &file_list($Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"});
- my %lt=&Apache::lonlocal::texthash('done' => 'Next Item',
- 'stop' => 'Quit Grading',
- 'fail' => 'Fail Rest',
- );
-
+ my %lt=('done' => 'Next Item',
+ 'stop' => 'Quit Grading',
+ 'fail' => 'Fail Rest',
+ 'cancel' => 'Cancel',
+ );
+ my %lt=&Apache::lonlocal::texthash(%lt);
+
my $result=<
+INFO
+
+ if (&grade_mode() eq 'regrade') {
+ $result.=<
+INFO
+ }
+
+ $result.=<
';
if ($status_code eq 'stop') {
$result.=''.&mt("Stopped grading.").''.$back;
+ } elsif ($status_code eq 'cancel') {
+ $result.=''.&mt("Cancelled grading.").''.$back;
} elsif ($status_code eq 'lock_failed') {
$result.=''.&mt("Failed to lock the requested record.")
.''.$back;
@@ -612,6 +634,8 @@ DONESCREEN
}
}
$webgrade='no';
+ }
+ if (!$todo || $env{'form.cancel'}) {
my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
}
if ($target eq 'webgrade' && defined($env{'form.queue'})) {
@@ -702,6 +726,8 @@ sub get_key_todo {
if (!$queue) {
$env{'form.queue'} = $queue = 'none';
#not queued so doing either a re or pre grade
+ #FIXME don't allow pregrade
+ &Apache::lonxml::debug("not in queue no lock");
return ($gradingkey);
}
@@ -709,11 +735,13 @@ sub get_key_todo {
if ($who eq $me) {
#already have the lock
$env{'form.gradingkey'}=&escape($gradingkey);
+ &Apache::lonxml::debug("already locked");
return ($gradingkey);
}
if (!defined($who)) {
if (&lock_key($queue,$gradingkey)) {
+ &Apache::lonxml::debug("newly locked");
return ($gradingkey);
} else {
return (undef,'lock_failed');
@@ -740,6 +768,8 @@ sub get_key_todo {
if ($target eq 'webgrade') {
if ($env{'form.stop'}) {
return (undef,'stop');
+ } elsif ($env{'form.cancel'}) {
+ return (undef,'cancel');
} elsif ($env{'form.next'}) {
return (undef,'select_user');
}
@@ -785,7 +815,8 @@ sub get_key_todo {
if ($env{'form.queuemode'} ne 'selected') {
# don't get something new from the queue if they hit the stop button
- if (!($env{'form.stop'} && $target eq 'webgrade')
+ if (!(($env{'form.cancel'} || $env{'form.stop'})
+ && $target eq 'webgrade')
&& !$env{'form.gradingaction'}) {
&Apache::lonxml::debug("Getting anew $queue");
return (&get_from_queue($queue));
@@ -937,7 +968,12 @@ DONEBUTTON
} elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
&Apache::structuretags::finalize_storage();
}
- if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
+ if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes'
+ && exists($env{'form.cancel'})) {
+ &check_queue_unlock($env{'form.queue'});
+ &Apache::lonxml::debug(" cancelled grading .".$env{'form.queue'});
+ } elsif ($target eq 'grade' && $env{'form.webgrade'} eq 'yes'
+ && !exists($env{'form.cancel'})) {
my $optional_required=
&Apache::lonxml::get_param('OptionalRequired',$parstack,
$safeeval);
@@ -1091,6 +1127,7 @@ sub check_queue_unlock {
my $me=$env{'user.name'}.':'.$env{'user.domain'};
my $who=&queue_key_locked($queue,$key,$cdom,$cnum);
if ($who eq $me) {
+ &Apache::lonxml::debug("unlocking my own $who");
return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
} elsif ($allow_not_me) {
&Apache::lonxml::debug("unlocking $who by $me");
@@ -1791,6 +1828,15 @@ sub get_id {
}
my %dimension;
+sub start_Setup {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ undef(%dimension);
+ my $dim_id=&get_id($parstack,$safeeval);
+ $Apache::bridgetask::dimension=$dim_id;
+ undef(@Apache::bridgetask::instance);
+ &Apache::lonxml::startredirection();
+ return &internal_location($dim_id);
+}
sub start_Question { return &start_Dimension(@_); }
sub start_Dimension {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
@@ -2057,6 +2103,41 @@ sub get_instance {
} else {
# any other targets no output
undef($result);
+ }
+ return $result;
+ }
+
+ sub end_Setup {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my $result=&Apache::lonxml::endredirection();
+ my $dim=&get_id($parstack,$safeeval);
+ my $instance=&get_instance($dim);
+ my $version=&get_version();
+ if ($target eq 'web') {
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
+ my @instances = $instance;
+ if (&Apache::response::showallfoils()) {
+ @instances = @{$dimension{'instances'}};
+ }
+ foreach my $instance (@instances) {
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{'questiontext'});
+ }
+ } elsif ($target eq 'webgrade'
+ || $target eq 'grade' && $env{'form.webgrade'}) {
+ # in case of any side effects that we need
+ @Apache::scripttag::parser_env = @_;
+ &Apache::scripttag::xmlparse($dimension{'intro'});
+ @Apache::scripttag::parser_env = @_;
+ &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+ @Apache::scripttag::parser_env = @_;
+ &Apache::scripttag::xmlparse($dimension{'questiontext'});
+ } else {
+ # any other targets no output
+ undef($result);
}
return $result;
}