--- loncom/homework/bridgetask.pm 2005/11/15 19:50:22 1.77
+++ loncom/homework/bridgetask.pm 2005/11/21 23:00:19 1.84
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.77 2005/11/15 19:50:22 albertel Exp $
+# $Id: bridgetask.pm,v 1.84 2005/11/21 23:00:19 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@ sub initialize_bridgetask {
}
sub proctor_check_auth {
- my ($slot_name,$slot)=@_;
+ my ($slot_name,$slot,$type)=@_;
my $user=$env{'form.proctorname'};
my $domain=$env{'form.proctordomain'};
@@ -79,7 +79,7 @@ sub proctor_check_auth {
$authenticated=1;
}
}
- if ($authenticated) {
+ if ($authenticated && $type eq 'Task') {
my $version=
$Apache::lonhomework::results{'resource.version'}=
++$Apache::lonhomework::history{'resource.version'};
@@ -93,6 +93,12 @@ sub proctor_check_auth {
}
}
return 1;
+ } elsif ($authenticated && $type eq 'problem') {
+ &Apache::lonxml::debug("authed #slot_name");
+ $Apache::lonhomework::results{"resource.0.checkedin"}=
+ $user.'@'.$domain;
+ $Apache::lonhomework::results{"resource.0.checkedin.slot"}=
+ $slot_name;
}
}
}
@@ -416,7 +422,7 @@ sub start_Task {
$target eq 'tex') {
my ($version,$previous)=&get_version();
($status,$accessmsg,my $slot_name,$slot) =
- &Apache::lonhomework::check_task_access('0');
+ &Apache::lonhomework::check_slot_access('0','Task');
push(@Apache::inputtags::status,$status);
$Apache::inputtags::slot_name=$slot_name;
my $expression='$external::datestatus="'.$status.'";';
@@ -470,9 +476,10 @@ DONESCREEN
}
} elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
if ($status eq 'NEEDS_CHECKIN') {
- if(&proctor_check_auth($slot_name,$slot)) {
+ if(&proctor_check_auth($slot_name,$slot,'Task')
+ && defined($Apache::inputtags::slot_name)) {
my $result=&add_to_queue('gradingqueue',
- $Apache::inputtags::slot_name);
+ [$Apache::inputtags::slot_name]);
&Apache::lonxml::debug("add_to_queue said $result");
}
}
@@ -525,19 +532,23 @@ DONESCREEN
} else {
if ($target eq 'webgrade') {
$result.="\n";
+ my $back='
'.
+ &mt('Return to resource').'
';
if ($status_code eq 'stop') {
- $result.=''.&mt("Stopped grading.").'';
+ $result.=''.&mt("Stopped grading.").''.$back;
} elsif ($status_code eq 'lock_failed') {
- $result.=''.&mt("Failed to lock the request record.").'';
+ $result.=''.&mt("Failed to lock the request record.")
+ .''.$back;
} elsif ($status_code eq 'unlock') {
- $result.=''.&mt("Unlocked the requested record.").'';
+ $result.=''.&mt("Unlocked the requested record.")
+ .''.$back;
$result.=&show_queue($env{'form.queue'},1);
} elsif ($status_code eq 'show_list') {
$result.=&show_queue($env{'form.queue'},1);
} elsif ($status_code eq 'select_user') {
$result.=&select_user();
} else {
- $result.=''.&mt("No user to be graded.").'';
+ $result.=''.&mt("No user to be graded.").''.$back;
}
}
$webgrade='no';
@@ -671,7 +682,6 @@ sub get_key_todo {
}
return (undef,undef)
}
-
sub end_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result='';
@@ -695,7 +705,8 @@ sub end_Task {
'.&mt('Indicate the files from your portfolio to be evaluated in grading this task.').'
').
"";
}
- if (!$previous && !$env{'form.donescreen'}) {
+ if (!$previous && $status ne 'SHOW_ANSWER' &&
+ &show_task($status,$previous)) {
$result.=&Apache::inputtags::gradestatus('0');
$result.='';
$result.=<\n";
+ my $status = "\n\n";
if ($bt_status eq 'pass') {
$status.='
You passed the '.$title.' given on '.
- $start_time.'.
';
+ $start_time.'';
}
if ($bt_status eq 'fail') {
$status.='You did not pass the '.$title.' given on '.
- $start_time.'.
';
+ $start_time.'';
if (!$previous) {
$status.=&add_request_another_attempt_button();
}
@@ -775,9 +788,12 @@ DONEBUTTON
}
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
&Apache::structuretags::finalize_storage();
- if ($award eq 'SUBMITTED') {
- &add_to_queue('gradingqueue',$Apache::inputtags::slot_name);
+ if ($award eq 'SUBMITTED'
+ && defined($Apache::inputtags::slot_name)) {
+ &add_to_queue('gradingqueue',[$Apache::inputtags::slot_name]);
}
+ } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
+ &Apache::structuretags::finalize_storage();
}
if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
my $optional_required=
@@ -911,7 +927,7 @@ sub move_between_queues {
} else {
$cur_data = ['none'];
}
- my $result=&add_to_queue($dest_queue,$cur_data->[0]);
+ my $result=&add_to_queue($dest_queue,[$cur_data->[0]]);
if ($result ne 'ok') {
return $result;
}
@@ -974,10 +990,10 @@ sub get_queue_data {
return undef;
}
+
sub check_queue_for_key {
- my ($cid,$queue,$todo)=@_;
- my $cnum=$env{'course.'.$cid.'.num'};
- my $cdom=$env{'course.'.$cid.'.domain'};
+ my ($cdom,$cnum,$queue,$todo)=@_;
+
my %results=
&Apache::lonnet::get($queue,[$todo,"$todo\0locked"],$cdom,$cnum);
@@ -996,14 +1012,17 @@ sub check_queue_for_key {
}
sub add_to_queue {
- my ($queue,$slot_name)=@_;
+ my ($queue,$user_data)=@_;
if ($queue eq 'none') { return 'ok'; }
my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ if (!$cid || $env{'request.state'} eq 'construct') {
+ return 'no_queue';
+ }
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
my %data;
- $data{"$symb\0queue\0$uname\@$udom"}=[$slot_name];
- return &Apache::lonnet::newput($queue,\%data,$cdom,$cnum);
+ $data{"$symb\0queue\0$uname\@$udom"}=$user_data;
+ return &Apache::lonnet::cput($queue,\%data,$cdom,$cnum);
}
sub show_queue {
@@ -1228,8 +1247,8 @@ sub get_from_queue {
if ($todo) { return $todo; }
while (1) {
my $starttime=time;
- &Apache::lonnet::put($queue,{"$symb\0timestamp"=>$starttime},
- $cdom,$cnum);
+ &Apache::lonnet::cput($queue,{"$symb\0timestamp"=>$starttime},
+ $cdom,$cnum);
&Apache::lonxml::debug("$starttime");
my $regexp="^$symb\0queue\0";
my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
@@ -1300,7 +1319,9 @@ sub select_user {
foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
my ($uname,$udom) = split(/:/,$student);
- my %status = &get_student_status($symb,$cid,$udom,$uname);
+ my $cnum=$env{'course.'.$cid.'.num'};
+ my $cdom=$env{'course.'.$cid.'.domain'};
+ my %status = &get_student_status($symb,$cdom,$cnum,$udom,$uname);
my $queue = 'none';
my $cannot_grade;
if ($status{'reviewqueue'} =~ /^(in_progress|enqueue)$/) {
@@ -1379,16 +1400,16 @@ RESULT
}
sub get_student_status {
- my ($symb,$cid,$udom,$uname)=@_;
+ my ($symb,$cdom,$cnum,$udom,$uname)=@_;
my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
$udom,$uname);
my %status;
$status{'status'}=$record{'resource.status'};
$status{'version'}=$record{'resource.version'};
$status{'grader'}=$record{'resource.grader'};
- $status{'reviewqueue'}=&check_queue_for_key($cid,'reviewqueue',
+ $status{'reviewqueue'}=&check_queue_for_key($cdom,$cnum,'reviewqueue',
&encode_queue_key($symb,$udom,$uname));
- $status{'gradingqueue'}=&check_queue_for_key($cid,'gradingqueue',
+ $status{'gradingqueue'}=&check_queue_for_key($cdom,$cnum,'gradingqueue',
&encode_queue_key($symb,$udom,$uname));
return %status;
}
@@ -1465,6 +1486,7 @@ sub get_instance {
$instance = $instances[($version-1)%scalar(@instances)];
$Apache::lonhomework::results{"resource.$version.0.$dim.instance"} =
$instance;
+ $Apache::lonhomework::results{'INTERNAL_store'} = 1;
&Apache::response::poprandomnumber();
return $instance;
}