'.
+ &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;
+}
+
+sub file_list {
+ my ($files,$uname,$udom) = @_;
+ if (!defined($uname) || !defined($udom)) {
+ (undef,undef,$udom,$uname) = &Apache::lonnet::whichuser();
+ }
+ my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
+
+ my $file_list="
\n";
+ foreach my $partial_file (split(',',$files)) {
+ my $file=$file_url.$partial_file;
+ $file=~s|/+|/|g;
+ &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
+ $file_list.='
';
}
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
$msg.='The problem '.$accessmsg;
}
$result.=$msg.' ';
} elsif ($target eq 'tex') {
- $result.='\begin{document}\noindent \vskip 1 mm \begin{minipage}{\textwidth}\vskip 0 mm';
+ $result.='\noindent \vskip 1 mm \begin{minipage}{\textwidth}\vskip 0 mm';
if ($status eq 'UNAVAILABLE') {
$result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
} else {
@@ -359,76 +781,110 @@ sub start_Task {
}
} elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
if ($status eq 'NEEDS_CHECKIN') {
- &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',
+ {'type' => 'Task',
+ 'time' => time,
+ 'slot' =>
+ $Apache::inputtags::slot_name});
+ &Apache::lonxml::debug("add_to_queue said $result");
+ }
}
}
} elsif ($target eq 'web') {
- my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
- $result.="$head_tag_start$name
- $body_tag_start \n".&style();
-
- $result.=$form_tag_start.
- '';
+
$result.=&preserve_grade_info();
- $result.=&internal_location();
+ $result.=&internal_location();
+ $result.=$form_tag_start."\t".
+ '';
&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 .= '
'."\n";
+ $result.= "\n".'
'."\n".
+ '';
#$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...
- # Hrrm, vaildation pass should perhaps say 'not_locked'
- # perhaps do a search if there is a key that is mine and if
- # there isn't reshow the queue....
- my ($todo,$status_code)=&get_key_todo($target);
+
+ my ($todo,$status_code,$msg)=&get_key_todo($target);
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 ($status_code eq 'stop') {
- $result.=''.&mt("Stopped grading.").'';
+ $result.=''.&mt("Stopped grading.").''.$back;
+ } elsif ($status_code eq 'cancel') {
+ $result.=''.&mt("Cancelled grading.").''.$back;
+ } elsif ($status_code eq 'terminated') {
+ $result.= ''.&mt('Terminated grading').' '.
+ ''.
+ &mt('Grading for [_1] has not been saved because of a grading key mismatch.',
+ ''.$env{'form.terminated'}.'').' '.$back;
+ } elsif ($status_code eq 'never_versioned') {
+ $result.=''.
+ &mt("Requested user has never accessed the task.").
+ ''.$back;
+ } elsif ($status_code =~ /still_open:(.*)/) {
+ my $date = &Apache::lonlocal::locallocaltime($1);
+ $result.=''.
+ &mt("Task is still open, will close at [_1].",$date).
+ ''.$back;
} elsif ($status_code eq 'lock_failed') {
- $result.=''.&mt("Failed to lock the request record.").'';
+ $result.=''.&mt("Failed to lock the requested 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();
+ } elsif ($status_code eq 'unable') {
+ $result.=''.&mt("Unable to aqcuire a user to grade.").''.$back;
+ } elsif ($status_code eq 'not_allowed') {
+ $result.=''.&mt('Not allowed to grade the requested user.').' '.$msg.''.$back;
} else {
- $result.=''.&mt("No user to be graded.").'';
+ $result.=''.&mt("No user to be graded.").''.$back;
}
}
$webgrade='no';
- my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
+ }
+ if (!$todo || $env{'form.cancel'}) {
+ my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
}
if ($target eq 'webgrade' && defined($env{'form.queue'})) {
+ if ($webgrade eq 'yes') {
+ $result.=&submission_time_stamp();
+ }
$result.=$form_tag_start;
$result.='';
@@ -438,6 +894,41 @@ sub start_Task {
$result.='';
}
+ if ($env{'form.chosensections'} || §ion_restricted()) {
+ my @chosen_sections = &get_allowed_sections();
+ foreach my $sec (@chosen_sections) {
+ $result.='';
+ }
+ }
+ if ($webgrade eq 'yes') { $result.=&webgrade_standard_info(); }
+ } elsif ($target eq 'webgrade'
+ && $env{'request.state'} eq 'construct') {
+ $result.=$form_tag_start;
+ $result.='';
+ $result.=&webgrade_standard_info();
+ }
+ if ($target eq 'webgrade') {
+ $result.="\n".'
';
+ &Apache::lonxml::startredirection();
+ &start_delay();
+ $dimension{$top}{'result'}=$result;
+ undef($result);
+ }
+ } elsif ($target eq 'edit') {
+ $result.=$form_tag_start.
+ &Apache::structuretags::problem_edit_header();
+ $Apache::lonxml::warnings_error_header=
+ &mt("Editor Errors - these errors might not effect the running of the problem, but they will likely cause problems with further use of the Edit mode. Please use the EditXML mode to fix these errors.")." ";
+ $result.= &Apache::edit::text_arg('Required number of passed optional elements to pass the Task:','OptionalRequired',$token,10)." \n";
+ $result.= &Apache::edit::insertlist($target,$token);
+ } elsif ($target eq 'modified') {
+ my $constructtag=
+ &Apache::edit::get_new_args($token,$parstack,$safeeval,
+ 'OptionalRequired');
+ if ($constructtag) {
+ $result = &Apache::edit::rebuild_tag($token);
}
} else {
# page_start returned a starting result, delete it if we don't need it
@@ -446,10 +937,30 @@ sub start_Task {
return $result;
}
+sub get_task_end_time {
+ my ($queue_entry,$symb,$udom,$uname) = @_;
+
+ my $end_time;
+ if (my $slot = &slotted_access($queue_entry)) {
+ my %slot_data=&Apache::lonnet::get_slot($slot);
+ $end_time = $slot_data{'endtime'};
+ } else {
+ $end_time = &Apache::lonhomework::due_date('0',$symb,
+ $udom,$uname);
+ }
+ return $end_time;
+}
+
sub get_key_todo {
my ($target)=@_;
my $todo;
+ if ($env{'request.state'} eq 'construct') {
+ my ($symb,$cid,$udom,$uname) = &Apache::lonnet::whichuser();
+ my $gradingkey=&encode_queue_key($symb,$udom,$uname);
+ return ($gradingkey);
+ }
+
if (defined($env{'form.reviewasubmission'})) {
&Apache::lonxml::debug("review a submission....");
$env{'form.queue'}='reviewqueue';
@@ -468,26 +979,104 @@ sub get_key_todo {
return (undef,'select_user');
}
+
+ my $me=$env{'user.name'}.':'.$env{'user.domain'};
+
+ #need to try both queues..
+ if (defined($env{'form.regradeaspecificsubmission'}) &&
+ defined($env{'form.gradinguser'}) &&
+ defined($env{'form.gradingdomain'}) ) {
+ my ($symb,$cid)=&Apache::lonnet::whichuser();
+ my $cnum = $env{'course.'.$cid.'.num'};
+ my $cdom = $env{'course.'.$cid.'.domain'};
+ my $uname = &LONCAPA::clean_username($env{'form.gradinguser'});
+ my $udom = &LONCAPA::clean_domain($env{'form.gradingdomain'});
+
+ if (§ion_restricted()) {
+ my $classlist=&get_limited_classlist();
+ if (!&allow_grade_user($classlist->{$uname.':'.$udom})) {
+ return (undef,'not_allowed',
+ &mt('Requested student ([_1]) is in a section you aren\'t allowed to grade.',$uname.':'.$udom));
+ }
+ }
+ my $gradingkey=&encode_queue_key($symb,$udom,$uname);
+
+ my $queue;
+
+ if (&in_queue('gradingqueue',$symb,$cdom,$cnum,$udom,$uname)) {
+ $env{'form.queue'} = $queue = 'gradingqueue';
+ } elsif (&in_queue('reviewqueue' ,$symb,$cdom,$cnum,$udom,$uname)) {
+ $env{'form.queue'} = $queue = 'reviewqueue';
+ }
+
+ if (!$queue) {
+ $env{'form.queue'} = $queue = 'none';
+ #not queued so doing either a re or pre grade
+ my %status = &Apache::lonnet::restore($symb,$cid,$udom,$uname);
+ if ($status{'resource.0.version'} < 1) {
+ return (undef,'never_versioned');
+ }
+ return ($gradingkey);
+ }
+
+ if ($queue) {
+ my $queue_entry = &get_queue_data($queue,$udom,$uname);
+
+ my $end_time = &get_task_end_time($queue_entry,$symb,
+ $udom,$uname);
+ if ($end_time > time) {
+ return (undef,"still_open:$end_time");
+ }
+ }
+
+ my $who=&queue_key_locked($queue,$gradingkey);
+ 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');
+ }
+ }
+
+ #otherwise (defined($who) && $who ne $me) some else has it...
+ return (undef,'not_allowed',
+ &mt('Another user ([_1]) currently has the record for [_2] locked.',
+ $who,$env{'form.gradinguser'}.':'.$env{'form.gradingdomain'}));
+ }
+
+
my $queue=$env{'form.queue'};
if (!defined($queue)) {
$env{'form.queue'}=$queue='gradingqueue';
}
- my $gradingkey=&Apache::lonnet::unescape($env{'form.gradingkey'});
+ my $gradingkey=&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.cancel'}) {
+ return (undef,'cancel');
+ } elsif ($env{'form.terminated'}) {
+ return (undef, 'terminated');
} elsif ($env{'form.next'}) {
- return (undef,'show_list');
+ return (undef,'select_user');
}
}
return ($gradingkey,'selected');
} else {
- return (undef,'show_list');
+ return (undef,'select_user');
}
}
if (defined($env{'form.queue'}) && defined($env{'form.gradingkey'})
@@ -495,7 +1084,6 @@ sub get_key_todo {
&& $env{'form.queuemode'} eq 'selected') {
my $who=&queue_key_locked($queue,$gradingkey);
- my $me=$env{'user.name'}.'@'.$env{'user.domain'};
if ($who eq $me) {
&Apache::lonxml::debug("Found a key was given to me");
return ($gradingkey,'selected');
@@ -527,17 +1115,32 @@ 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'} || $env{'form.terminated'})
+ && $target eq 'webgrade')
&& !$env{'form.gradingaction'}) {
&Apache::lonxml::debug("Getting anew $queue");
return (&get_from_queue($queue));
} else {
- return (undef,'stop');
+ if ($env{'form.terminated'}) {
+ return (undef,'terminated');
+ } else {
+ return (undef,'stop');
+ }
}
}
return (undef,undef)
}
+sub minimize_storage {
+ foreach my $key (keys(%Apache::lonhomework::results)) {
+ if ($key =~ /regrader$/) { next; }
+ if ($Apache::lonhomework::results{$key} eq
+ $Apache::lonhomework::history{$key}) {
+ delete($Apache::lonhomework::results{$key});
+ }
+ }
+}
+
sub end_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result='';
@@ -545,77 +1148,133 @@ sub end_Task {
my ($version,$previous)=&get_version();
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
$target eq 'tex') {
- if (
- (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
- ($target eq 'answer') || ($target eq 'tex')
- ) {
+ if ($target eq 'web' || $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".'
'.
+ if ($status eq 'CAN_ANSWER' && !$previous &&
+ !$env{'form.donescreen'}) {
+ my ($portheader,$porttext);
+ if ($Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"}) {
+ $portheader = &mt('Submit Additional Portfolio Files for Grading');
+ $porttext = &mt('Indicate which additional files from your portfolio are to be evaluated in grading this task.');
+ } else {
+ $portheader = &mt('Submit Portfolio Files for Grading');
+ $porttext = &mt('Indicate the files from your portfolio to be evaluated in grading this task.');
+ }
+ $result.="\n".'
You did not pass the '.$title.' given on '.
- $start_time.'.
';
+ $status.='
'
+ .&mt('You did not pass the [_1] given on [_2].',$title,$start_time)
+ .'
';
+ $status.=$question_status;
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++;
+
+ $status.="\n".'
'."\n";
+
+ foreach my $id (@{$dimension{$dim}{'criterias'}}) {
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+ if ($type eq 'dimension') {
+ $result.=$dimension{$id}{'result'};
+ next;
}
+ my $criteria =
+ &nested_parse(\$dimension{$dim}{'criteria.'.$id},
+ [@_]);
+ $status .= &layout_web_Criteria($dim,$id,$criteria);
}
- 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().'