--- loncom/homework/bridgetask.pm 2005/04/07 06:56:21 1.11
+++ loncom/homework/bridgetask.pm 2005/05/24 19:33:28 1.30
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.11 2005/04/07 06:56:21 albertel Exp $
+# $Id: bridgetask.pm,v 1.30 2005/05/24 19:33:28 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -48,14 +48,18 @@ sub initialize_bridgetask {
$Apache::bridgetask::dimension='';
# list of all Dimension ids seen
@Apache::bridgetask::dimensionlist=();
+ # mandatory attribute of all Dimensions seen
+ %Apache::bridgetask::dimensionmandatory=();
# list of all current Instance ids
@Apache::bridgetask::instance=();
# list of all Instance ids seen in this problem
@Apache::bridgetask::instancelist=();
+ # key of queud user data that we are currently grading
+ $Apache::bridgetask::queue_key='';
}
sub proctor_check_auth {
- my ($slot)=@_;
+ my ($slot_name,$slot)=@_;
my $user=$env{'form.proctorname'};
my $domain=$env{'form.proctordomain'};
@@ -65,8 +69,18 @@ sub proctor_check_auth {
if ($puser eq $user && $pdom eq $domain) {
my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
if ($authhost ne 'no_host') {
- $Apache::lonhomework::results{'resource.checkedin'}=
+ my $version=
+ $Apache::lonhomework::results{'resource.version'}=
+ ++$Apache::lonhomework::history{'resource.version'};
+ $Apache::lonhomework::results{"resource.$version.checkedin"}=
$user.'@'.$domain;
+ $Apache::lonhomework::results{"resource.$version.checkedin.slot"}=
+ $slot_name;
+ foreach my $key (keys(%Apache::lonhomework::history)) {
+ if ($key=~/^resource\.0\./) {
+ $Apache::lonhomework::results{$key}='';
+ }
+ }
return 1;
}
}
@@ -74,44 +88,126 @@ sub proctor_check_auth {
return 0;
}
+sub get_version {
+ my ($version,$previous);
+ if ($env{'form.previousversion'} &&
+ defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) {
+ $version=$env{'form.previousversion'};
+ $previous=1;
+ } else {
+ $version=$Apache::lonhomework::history{'resource.version'};
+ $previous=0;
+ }
+ if (wantarray) {
+ return ($version,$previous);
+ }
+ return $version;
+}
+
sub add_previous_version_button {
+ my ($status)=@_;
+ my $result;
+ if ($Apache::lonhomework::history{'resource.version'} eq '') {
+ return '';
+ }
+ if ($Apache::lonhomework::history{'resource.version'} < 2 &&
+ $status ne 'NEEDS_CHECKIN') {
+ return '';
+ }
+ my $version=&get_version();
+ if ($env{'form.previousversion'} ne '' &&
+ $env{'form.previousversion'} eq $version) {
+ $result.="
".&mt("Showing previous version [_1]",$version).
+ "
\n";
+ }
+ my @to_show;
+ foreach my $test_version (1..$Apache::lonhomework::history{'resource.version'}) {
+ if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.status'})) {
+ push(@to_show,$test_version);
+ }
+ }
+ my $list='\n\n";
+ $result.='";
+ return $result;
+}
+
+sub add_grading_button {
+ my $result=' ';
+ $result.='';
+ return $result;
+}
+
+sub add_request_another_attempt_button {
my $result;
- $result.=&mt(' Show a previously done version: [_1]','');
+ $result.=' ';
+ return $result;
+}
+
+sub preserve_grade_info {
+ my $result;
+ # if we are viewing someone else preserve that info
+ if (defined $env{'form.grade_symb'}) {
+ foreach my $field ('symb','courseid','domain','username') {
+ $result .= ''."\n";
+ }
+ }
return $result;
}
sub start_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- &Apache::structuretags::initialize_storage();
- &Apache::lonhomework::showhash(%Apache::lonhomework::history);
-
my ($status,$accessmsg,$slot);
+ if ($target ne 'webgrade') {
+ &Apache::structuretags::initialize_storage();
+ &Apache::lonhomework::showhash(%Apache::lonhomework::history);
+ }
+
$Apache::lonhomework::parsing_a_task=1;
#should get back a or the neccesary stuff to start XML/MathML
my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
&Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
-
+
if ($target eq 'web') {
- $body_tag_start.=&add_previous_version_button();
+ if ($Apache::lonhomework::modifygrades) {
+ $body_tag_start.='";
+ }
}
- if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
$target eq 'tex') {
- ($status,$accessmsg,$slot) =
+ my ($version,$previous)=&get_version();
+ ($status,$accessmsg,my $slot_name,$slot) =
&Apache::lonhomework::check_task_access('0');
push(@Apache::inputtags::status,$status);
+ $Apache::inputtags::slot_name=$slot_name;
my $expression='$external::datestatus="'.$status.'";';
- $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
+ $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.solved"}.'";';
&Apache::run::run($expression,$safeeval);
&Apache::lonxml::debug("Got $status");
- if (( $status eq 'CLOSED' ) ||
- ( $status eq 'BANNED') ||
- ( $status eq 'UNAVAILABLE') ||
- ( $status eq 'NOT_IN_A_SLOT') ||
- ( $status eq 'NEEDS_CHECKIN') ||
- ( $status eq 'INVALID_ACCESS')) {
+ $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') )) {
my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
if ( $target eq "web" ) {
$result.= $head_tag_start.''.$body_tag_start;
@@ -123,6 +219,8 @@ sub start_Task {
} elsif ($status eq 'NEEDS_CHECKIN') {
$msg.='
'.&mt('Your submission is in the grading queue.').'
';
} elsif ($status ne 'NOT_YET_VIEWED') {
$msg.='
'.&mt('Not open to be viewed').'
';
}
@@ -137,12 +235,15 @@ sub start_Task {
} else {
$result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
}
- } elsif ($target eq 'grade') {
+ } elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
if ($status eq 'NEEDS_CHECKIN') {
- if (&proctor_check_auth($slot)) {
+ 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.
}
}
}
@@ -151,13 +252,55 @@ sub start_Task {
$result.="$head_tag_start$name
$body_tag_start \n $form_tag_start".
'';
- # if we are viewing someone else preserve that info
- if (defined $env{'form.grade_symb'}) {
- foreach my $field ('symb','courseid','domain','username') {
- $result .= ''."\n";
+ $result.=&preserve_grade_info();
+ 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').'
';
+ }
+ }
+ } elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
+ $target eq 'webgrade') {
+ if ($target eq 'webgrade') {
+ $result.=$head_tag_start.$body_tag_start.$form_tag_start;
+ $result.='';
+ $result.=' Before'.&show_queue('gradingqueue');
+ }
+ my $todo;
+ # don't get something new from the queue if they hit the stop button
+ if (!($env{'form.stop'} && $target eq 'webgrade')) {
+ $todo=&get_from_queue('gradingqueue');
+ }
+ if ($todo) {
+ &setup_env_for_other_user($todo,$safeeval);
+ my ($symb,$uname,$udom)=&decode_queue_key($todo);
+ $result.="\n".'
Found '.
+ &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'
';
+ if ($env{'form.stop'}) {
+ $result.=&mt("Stopped grading.");
+ } else {
+ $result.=&mt("No user to be graded.");
+ }
+ $result.='
';
+ }
+ my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
}
} else {
# page_start returned a starting result, delete it if we don't need it
@@ -170,6 +313,7 @@ sub end_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result='';
my $status=$Apache::inputtags::status['-1'];
+ my ($version,$previous)=&get_version();
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
$target eq 'tex') {
if (
@@ -177,25 +321,111 @@ sub end_Task {
($target eq 'answer') || ($target eq 'tex')
) {
if ($target eq 'web') {
- if ($status eq 'CAN_ANSWER') {
- $result.='