--- loncom/homework/bridgetask.pm 2005/08/09 07:34:51 1.38
+++ loncom/homework/bridgetask.pm 2005/09/29 19:18:37 1.55
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.38 2005/08/09 07:34:51 albertel Exp $
+# $Id: bridgetask.pm,v 1.55 2005/09/29 19:18:37 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -147,9 +147,7 @@ sub add_grading_button {
my $result=' ';
$result.='';
- if ( 1) {
- #need a permissions for limitng this to 'powerful users'
-
+ if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
my ($entries,$ready,$locks)=&get_queue_counts('gradingqueue');
$result.='
'.&mt("Grading Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
@@ -160,6 +158,8 @@ sub add_grading_button {
$result.='
'.&mt("Review Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
$result.='
'."\n";
+ $result.=' '."\n";
}
return $result;
}
@@ -204,6 +204,87 @@ sub preserve_grade_info {
return $result;
}
+sub style {
+ return (<
+STYLE
+
+}
+
+sub show_task {
+ my ($status,$previous)=@_;
+ if (!$previous && (
+ ( $status eq 'CLOSED' ) ||
+ ( $status eq 'BANNED') ||
+ ( $status eq 'UNAVAILABLE') ||
+ ( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NEEDS_CHECKIN') ||
+ ( $status eq 'WAITING_FOR_GRADE') ||
+ ( $status eq 'INVALID_ACCESS') )) {
+ return 0;
+ }
+ return 1;
+}
+
+sub internal_location {
+ my ($id)=@_;
+ return '';
+}
+
sub start_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
@@ -225,13 +306,14 @@ sub start_Task {
if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
$body_tag_start.=$uri.'">'.&add_grading_button()."";
my $symb=&Apache::lonnet::symbread();
- $body_tag_start.='';
-
+ if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
+ $body_tag_start.='';
+ }
}
}
if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
@@ -246,14 +328,7 @@ sub start_Task {
&Apache::run::run($expression,$safeeval);
&Apache::lonxml::debug("Got $status");
$body_tag_start.=&add_previous_version_button($status);
- if (!$previous && (
- ( $status eq 'CLOSED' ) ||
- ( $status eq 'BANNED') ||
- ( $status eq 'UNAVAILABLE') ||
- ( $status eq 'NOT_IN_A_SLOT') ||
- ( $status eq 'NEEDS_CHECKIN') ||
- ( $status eq 'WAITING_FOR_GRADE') ||
- ( $status eq 'INVALID_ACCESS') )) {
+ if (!&show_task($status,$previous)) {
my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
if ( $target eq "web" ) {
$result.= $head_tag_start.''.$body_tag_start;
@@ -284,43 +359,27 @@ sub start_Task {
}
} elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
if ($status eq 'NEEDS_CHECKIN') {
- if (&proctor_check_auth($slot_name,$slot)) {
- #FIXME immeadiatly add this to the grading queue
- # with slot->{'endtime'} for when grading can
- # begin on this resource
- # FIXME I think the above is done by default,
- # need to check that
- # failure doesn't do this.
- }
+ &proctor_check_auth($slot_name,$slot);
}
}
} elsif ($target eq 'web') {
my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
$result.="$head_tag_start$name
- $body_tag_start \n";
+ $body_tag_start \n".&style();
- my ($version,$previous)=&get_version();
- if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
- $result.='
'.&mt('Did not pass').'
';
- if (!$previous) {
- $result.=&add_request_another_attempt_button();
- }
- }
- if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
- $result.='
'.&mt('Passed').'
';
- }
$result.=$form_tag_start.
'';
$result.=&preserve_grade_info();
-
+ $result.=&internal_location();
+ &Apache::lonxml::startredirection();
}
} elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
$target eq 'webgrade') {
my $webgrade='yes';
if ($target eq 'webgrade') {
$result.=$head_tag_start.$body_tag_start;
- $result.=' Review'.&show_queue('reviewqueue');
- $result.=' Grade'.&show_queue('gradingqueue');
+ #$result.=' Review'.&show_queue('reviewqueue');
+ #$result.=' Grade'.&show_queue('gradingqueue');
}
# FIXME Blast! still need to reorg this, need to reshow the
# queue being reviewed once done with the grade pass...
@@ -329,7 +388,6 @@ sub start_Task {
# there isn't reshow the queue....
my ($todo,$status_code)=&get_key_todo($target);
- &Apache::lonnet::logthis("got todo -$todo- stat -$status_code-");
if ($todo) {
&setup_env_for_other_user($todo,$safeeval);
my ($symb,$uname,$udom)=&decode_queue_key($todo);
@@ -342,7 +400,7 @@ sub start_Task {
&Apache::structuretags::initialize_storage();
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
if ($target eq 'webgrade') {
- $result.=' After -'.&show_queue($env{'form.queue'});
+ #$result.=' After -'.&show_queue($env{'form.queue'});
$result.="\n".'
';
if ($status_code eq 'selected') {
$form_tag_start.=
@@ -361,6 +419,8 @@ sub start_Task {
$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.").'';
}
@@ -374,6 +434,10 @@ sub start_Task {
$webgrade.'" />';
$result.='';
+ if ($env{'form.regrade'}) {
+ $result.='';
+ }
}
} else {
# page_start returned a starting result, delete it if we don't need it
@@ -387,7 +451,7 @@ sub get_key_todo {
my $todo;
if (defined($env{'form.reviewasubmission'})) {
- &Apache::lonnet::logthis("review a submission....");
+ &Apache::lonxml::debug("review a submission....");
$env{'form.queue'}='reviewqueue';
return (undef,'show_list');
}
@@ -398,6 +462,12 @@ sub get_key_todo {
return (undef,'show_list');
}
+ if (defined($env{'form.regradeasubmission'})) {
+ &Apache::lonxml::debug("regrade a grading....");
+ $env{'form.queue'}='none';
+ return (undef,'select_user');
+ }
+
my $queue=$env{'form.queue'};
if (!defined($queue)) {
@@ -406,6 +476,20 @@ sub get_key_todo {
my $gradingkey=&Apache::lonnet::unescape($env{'form.gradingkey'});
+ if ($env{'form.queue'} eq 'none') {
+ if (defined($env{'form.gradingkey'})) {
+ if ($target eq 'webgrade') {
+ if ($env{'form.stop'}) {
+ return (undef,'stop');
+ } elsif ($env{'form.next'}) {
+ return (undef,'show_list');
+ }
+ }
+ return ($gradingkey,'selected');
+ } else {
+ return (undef,'show_list');
+ }
+ }
if (defined($env{'form.queue'}) && defined($env{'form.gradingkey'})
&& !defined($env{'form.gradingaction'})
&& $env{'form.queuemode'} eq 'selected') {
@@ -466,14 +550,63 @@ sub end_Task {
($target eq 'answer') || ($target eq 'tex')
) {
if ($target eq 'web') {
+ if (&show_task($status,$previous)) {
+ $result.=&Apache::lonxml::endredirection();
+ }
if ($status eq 'CAN_ANSWER' && !$previous) {
$result.="\n".'
'.&mt('Indicate the files from your portfolio to be evaluated in grading this task.').'
').
"
";
$result.=&Apache::inputtags::gradestatus('0');
}
+ if (&show_task($status,$previous)) {
+ my $bt_status=$Apache::lonhomework::history{"resource.$version.status"};
+ my $title=&Apache::lonnet::gettitle();
+ my %slot=&Apache::lonnet::get_slot($Apache::inputtags::slot_name);
+ my $start_time=
+ &Apache::lonlocal::locallocaltime($slot{'starttime'});
+
+ my $status;
+ $status.="\n
\n";
+
+ if ($bt_status eq 'pass') {
+ $status.='
You passed the '.$title.' given on '.
+ $start_time.'.
';
+ }
+ if ($bt_status eq 'fail') {
+ $status.='
You did not pass the '.$title.' given on '.
+ $start_time.'.
';
+ if (!$previous) {
+ $status.=&add_request_another_attempt_button();
+ }
+ }
+ my $man_count=0;
+ my $opt_count=0;
+ my $opt_passed=0;
+ foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
+ if ($Apache::bridgetask::dimensionmandatory{$dim_id}
+ eq 'N') {
+ $opt_count++;
+ if ($Apache::lonhomework::history{"resource.$version.$dim_id.status"} eq 'pass') {
+ $opt_passed++;
+ }
+ } else {
+ $man_count++;
+ }
+ }
+ my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
+ $parstack,$safeeval);
+ if ($opt_req !~ /\S/) { $opt_req='0'; }
+ $status.="\n
".&mt('You needed to pass all of the [_1] mandatory components and [_2] of the [_3] optional components on the bridge task.',$man_count,$opt_req,$opt_count)."
\n";
+
+ my $internal_location=&internal_location();
+ $result=~s/\Q$internal_location\E/$status/;
+ }
}
if ($target eq 'web' || $target eq 'webgrade') {
$result.=&Apache::lonxml::xmlend().'