--- loncom/homework/bridgetask.pm 2006/07/17 20:35:11 1.181
+++ loncom/homework/bridgetask.pm 2006/10/31 21:29:38 1.188
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.181 2006/07/17 20:35:11 albertel Exp $
+# $Id: bridgetask.pm,v 1.188 2006/10/31 21:29:38 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','Setup','Instance','InstanceText','Criteria','ClosingParagraph'));
+ &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','GraderNote','ClosingParagraph'));
}
my %dimension;
@@ -105,7 +105,7 @@ sub check_in {
sub check_in_sequence {
my ($user,$domain,$slot_name) = @_;
my $navmap = Apache::lonnavmaps::navmap->new();
- my ($symb) = &Apache::lonxml::whichuser();
+ my ($symb) = &Apache::lonnet::whichuser();
my ($map) = &Apache::lonnet::decode_symb($symb);
my @resources =
$navmap->retrieveResources($map, sub { $_[0]->is_problem() },0,0);
@@ -225,7 +225,7 @@ sub add_previous_version_button {
}
sub add_grading_button {
- my (undef,$cid)=&Apache::lonxml::whichuser();
+ my (undef,$cid)=&Apache::lonnet::whichuser();
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
@@ -388,12 +388,14 @@ sub internal_location {
}
sub submission_time_stamp {
- my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
my $submissiontime;
my $version=$Apache::lonhomework::history{'resource.0.version'};
for (my $v=$Apache::lonhomework::history{'version'};$v>0;$v--) {
- if (defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.bridgetask.portfiles'})) {
+ if (defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.bridgetask.portfiles'})
+ && defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.tries'})) {
$submissiontime=$Apache::lonhomework::history{$v.':timestamp'};
+ last;
}
}
my $result;
@@ -404,16 +406,18 @@ sub submission_time_stamp {
my ($color,$when)=('#FF6666','after');
if ($diff > 0) { ($color,$when)=('#336600','before'); }
my $info;
+ $diff = abs($diff);
if ($diff%60) { $info=($diff%60).' seconds'; }
$diff=int($diff/60);
if ($diff%60) { $info=($diff%60).' minutes '.$info; }
$diff=int($diff/60);
if ($diff) { $info=$diff.' hours '.$info; }
$result='
'.
- &mt('Student submitted [_1] [_2] the deadline.
- (Submission was at [_3], end of period was [_4].)',
- $info,$when,scalar(localtime($submissiontime)),
- scalar(localtime($slot{'endtime'}))).
+ &mt('Student submitted [_1] [_2] the deadline. '.
+ '(Submission was at [_3], end of period was [_4].)',
+ $info,$when,
+ &Apache::lonlocal::locallocaltime($submissiontime),
+ &Apache::lonlocal::locallocaltime($slot{'endtime'})).
'
';
}
return $result;
@@ -422,7 +426,7 @@ sub submission_time_stamp {
sub file_list {
my ($files,$uname,$udom) = @_;
if (!defined($uname) || !defined($udom)) {
- (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
+ (undef,undef,$udom,$uname) = &Apache::lonnet::whichuser();
}
my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
@@ -483,7 +487,7 @@ sub done_screen {
my ($version) = @_;
my $title=&Apache::lonnet::gettitle();
my @files=split(',',$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'});
- my (undef,undef,$domain,$user)= &Apache::lonxml::whichuser();
+ my (undef,undef,$domain,$user)= &Apache::lonnet::whichuser();
my $files = '';
my $msg;
foreach my $file (@files) {
@@ -827,7 +831,7 @@ sub get_key_todo {
if (defined($env{'form.regradeaspecificsubmission'}) &&
defined($env{'form.gradinguser'}) &&
defined($env{'form.gradingdomain'}) ) {
- my ($symb,$cid)=&Apache::lonxml::whichuser();
+ my ($symb,$cid)=&Apache::lonnet::whichuser();
my $cnum = $env{'course.'.$cid.'.num'};
my $cdom = $env{'course.'.$cid.'.domain'};
my $uname = $env{'form.gradinguser'};
@@ -1098,8 +1102,6 @@ DONEBUTTON
if ($award eq 'SUBMITTED') {
&add_to_queue('gradingqueue',\%queue_data);
}
- } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
- &Apache::structuretags::finalize_storage();
}
if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes'
&& exists($env{'form.cancel'})) {
@@ -1140,35 +1142,14 @@ DONEBUTTON
$env{'user.name'}.':'.$env{'user.domain'};
if ($review) {
$Apache::lonhomework::results{"resource.$version.0.status"}='review';
- if ($env{'form.queue'} eq 'reviewqueue') {
- &check_queue_unlock($env{'form.queue'});
- &Apache::lonxml::debug(" still needs review not changing status.");
- } else {
- if ($env{'form.queue'} ne 'none') {
- &move_between_queues($env{'form.queue'},'reviewqueue');
- } else {
- &add_to_queue('reviewqueue',\%queue_data);
- }
- }
} elsif ($ungraded) {
$Apache::lonhomework::results{"resource.$version.0.status"}='ungraded';
- if ($env{'form.queue'} eq 'reviewqueue') {
- &Apache::lonxml::debug("moving back.");
- &move_between_queues($env{'form.queue'},
- 'gradingqueue');
- } elsif ($env{'form.queue'} eq 'none' ) {
- &add_to_queue('gradingqueue',\%queue_data);
- } else {
- &check_queue_unlock($env{'form.queue'});
- }
} elsif ($mandatory_failed) {
$Apache::lonhomework::results{"resource.$version.0.status"}='fail';
$Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
$Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
$Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
- &remove_from_queue($env{'form.queue'});
-
- my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
if ($env{'form.regrade'} ne 'yes') {
$Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
@@ -1184,9 +1165,7 @@ DONEBUTTON
$Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
$Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
$Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
- &remove_from_queue($env{'form.queue'});
-
- my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
if ($env{'form.regrade'} ne 'yes') {
$Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
@@ -1209,6 +1188,38 @@ DONEBUTTON
}
&minimize_storage();
&Apache::structuretags::finalize_storage();
+
+ # data stored, now handle queue
+ if ($review) {
+ if ($env{'form.queue'} eq 'reviewqueue') {
+ &check_queue_unlock($env{'form.queue'});
+ &Apache::lonxml::debug(" still needs review not changing status.");
+ } else {
+ if ($env{'form.queue'} ne 'none') {
+ &move_between_queues($env{'form.queue'},'reviewqueue');
+ } else {
+ &add_to_queue('reviewqueue',\%queue_data);
+ }
+ }
+ } elsif ($ungraded) {
+ if ($env{'form.queue'} eq 'reviewqueue') {
+ &Apache::lonxml::debug("moving back.");
+ &move_between_queues($env{'form.queue'},
+ 'gradingqueue');
+ } elsif ($env{'form.queue'} eq 'none' ) {
+ &add_to_queue('gradingqueue',\%queue_data);
+ } else {
+ &check_queue_unlock($env{'form.queue'});
+ }
+ } elsif ($mandatory_failed) {
+ &remove_from_queue($env{'form.queue'});
+ } else {
+ &remove_from_queue($env{'form.queue'});
+ }
+ }
+ if (exists($Apache::lonhomework::results{'INTERNAL_store'})) {
+ # instance generation occured and hasn't yet been stored
+ &Apache::structuretags::finalize_storage();
}
} elsif ($target eq 'webgrade') {
$result.="";
@@ -1232,6 +1243,10 @@ DONEBUTTON
'Partial Credit Factor');
$result.=&Apache::response::meta_stores_write('status','string',
'Bridge Task Status');
+ } elsif ($target eq 'edit') {
+ &Apache::structuretags::reset_problem_globals('Task');
+ undef($Apache::lonhomework::parsing_a_task);
+ return ('','no');
}
&Apache::structuretags::reset_problem_globals('Task');
undef($Apache::lonhomework::parsing_a_task);
@@ -1258,7 +1273,7 @@ sub move_between_queues {
sub check_queue_unlock {
my ($queue,$key,$allow_not_me)=@_;
if ($queue eq 'none') { return 'ok'; }
- my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
if (!defined($key)) {
$key="$symb\0queue\0$uname:$udom";
}
@@ -1281,7 +1296,7 @@ sub in_queue {
if ($queue eq 'none') { return 0; }
if (!defined($symb) || !defined($cdom) || !defined($cnum)
|| !defined($udom) || !defined($uname)) {
- ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ ($symb,my $cid,$udom,$uname)=&Apache::lonnet::whichuser();
$cnum=$env{'course.'.$cid.'.num'};
$cdom=$env{'course.'.$cid.'.domain'};
}
@@ -1300,7 +1315,7 @@ sub remove_from_queue {
if ($queue eq 'none') { return 'ok'; }
if (!defined($symb) || !defined($cdom) || !defined($cnum)
|| !defined($udom) || !defined($uname)) {
- ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ ($symb,my $cid,$udom,$uname)=&Apache::lonnet::whichuser();
$cnum=$env{'course.'.$cid.'.num'};
$cdom=$env{'course.'.$cid.'.domain'};
}
@@ -1325,7 +1340,7 @@ sub setup_env_for_other_user {
sub get_queue_data {
my ($queue,$udom,$uname)=@_;
- my ($symb,$cid,$other_udom,$other_uname)=&Apache::lonxml::whichuser();
+ my ($symb,$cid,$other_udom,$other_uname)=&Apache::lonnet::whichuser();
if (!$uname || !$udom) {
$uname=$other_uname;
$udom =$other_udom;
@@ -1371,7 +1386,7 @@ sub check_queue_for_key {
sub add_to_queue {
my ($queue,$user_data)=@_;
if ($queue eq 'none') { return 'ok'; }
- my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
if (!$cid || $env{'request.state'} eq 'construct') {
return 'no_queue';
}
@@ -1409,7 +1424,7 @@ sub get_limited_classlist {
sub show_queue {
my ($queue,$with_selects)=@_;
my $result;
- my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
@@ -1536,7 +1551,7 @@ FORM
sub get_queue_counts {
my ($queue)=@_;
my $result;
- my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
@@ -1553,7 +1568,6 @@ sub get_queue_counts {
foreach my $key (sort(keys(%queue))) {
my ($symb,$uname,$udom) = &decode_queue_key($key);
if (!defined($classlist->{$uname.':'.$udom})) { next; }
-
if ($key=~/locked$/) {
$locks++;
} elsif ($key=~/timestamp$/) {
@@ -1594,7 +1608,7 @@ sub decode_queue_key {
sub queue_key_locked {
my ($queue,$key,$cdom,$cnum)=@_;
if (!defined($cdom) || !defined($cnum)) {
- my (undef,$cid)=&Apache::lonxml::whichuser();
+ my (undef,$cid)=&Apache::lonnet::whichuser();
$cnum=$env{'course.'.$cid.'.num'};
$cdom=$env{'course.'.$cid.'.domain'};
}
@@ -1706,7 +1720,7 @@ sub find_mid_grade {
sub lock_key {
my ($queue,$todo)=@_;
my $me=$env{'user.name'}.':'.$env{'user.domain'};
- my (undef,$cid)=&Apache::lonxml::whichuser();
+ my (undef,$cid)=&Apache::lonnet::whichuser();
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
my $success=&Apache::lonnet::newput($queue,{"$todo\0locked"=> $me},
@@ -1721,7 +1735,7 @@ sub lock_key {
sub get_queue_symb_status {
my ($queue,$symb,$cdom,$cnum) = @_;
if (!defined($cdom) || !defined($cnum)) {
- my (undef,$cid)=&Apache::lonxml::whichuser();
+ my (undef,$cid)=&Apache::lonnet::whichuser();
$cnum=$env{'course.'.$cid.'.num'};
$cdom=$env{'course.'.$cid.'.domain'};
}
@@ -1745,7 +1759,7 @@ sub get_queue_symb_status {
sub get_from_queue {
my ($queue)=@_;
my $result;
- my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
my $todo=&find_mid_grade($queue,$symb,$cdom,$cnum);
@@ -1821,7 +1835,7 @@ sub get_from_queue {
}
sub select_user {
- my ($symb,$cid)=&Apache::lonxml::whichuser();
+ my ($symb,$cid)=&Apache::lonnet::whichuser();
my @chosen_sections=
&Apache::loncommon::get_env_multiple('form.chosensections');
@@ -2506,9 +2520,31 @@ sub start_Criteria {
sub end_Criteria {
}
+sub start_GraderNote {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+
+ if ($target eq 'webgrade') {
+ return ''.
+ &mt('Note to graders:').'';
+ }
+ my $note=&Apache::lonxml::get_all_text('/gradernote',$parser,$style);
+ return;
+}
+
+sub end_GraderNote {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+
+ if ($target eq 'webgrade') {
+ return '
';
+ }
+ return;
+}
+
+
+
sub proctor_validation_screen {
my ($slot) = @_;
- my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
+ my (undef,undef,$domain,$user) = &Apache::lonnet::whichuser();
my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg');
my $name=&Apache::loncommon::plainname($user,$domain);