--- loncom/homework/bridgetask.pm 2006/03/30 22:39:17 1.134
+++ loncom/homework/bridgetask.pm 2018/01/31 15:28:28 1.270
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.134 2006/03/30 22:39:17 albertel Exp $
+# $Id: bridgetask.pm,v 1.270 2018/01/31 15:28:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,26 +37,29 @@ use Apache::lonmenu;
use Apache::lonlocal;
use Apache::lonxml;
use Apache::slotrequest();
+use Apache::structuretags();
use Time::HiRes qw( gettimeofday tv_interval );
+use LONCAPA;
+
BEGIN {
- &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Instance','InstanceText','Criteria','ClosingParagraph'));
+ &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','CriteriaText','GraderNote','ClosingParagraph'));
}
+my %dimension;
+my $top = 'top';
+
sub initialize_bridgetask {
# id of current Dimension, 0 means that no dimension is current
# (inside only)
- $Apache::bridgetask::dimension='';
- # list of all Dimension ids seen
- @Apache::bridgetask::dimensionlist=();
- # mandatory attribute of all Dimensions seen
- %Apache::bridgetask::dimensionmandatory=();
+ @Apache::bridgetask::dimension=();
# list of all current Instance ids
- @Apache::bridgetask::instance=();
+ %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='';
+ undef(%dimension);
}
sub proctor_check_auth {
@@ -66,7 +69,7 @@ sub proctor_check_auth {
my @allowed=split(",",$slot->{'proctor'});
foreach my $possible (@allowed) {
- my ($puser,$pdom)=(split('@',$possible));
+ my ($puser,$pdom)=(split(':',$possible));
if ($puser eq $user && $pdom eq $domain) {
my $authenticated=0;
if ( $slot->{'secret'} =~ /\S/ &&
@@ -79,39 +82,137 @@ sub proctor_check_auth {
$authenticated=1;
}
}
- if ($authenticated && $type eq 'Task') {
- # increment version
- my $version=
- $Apache::lonhomework::history{'resource.0.version'};
- $version++;
-
- #clean out all current results
- foreach my $key (keys(%Apache::lonhomework::history)) {
- if ($key=~/^resource\.0\./) {
- $Apache::lonhomework::results{$key}='';
- }
- }
-
- #setup new version and who did it
- $Apache::lonhomework::results{'resource.0.version'}=$version;
- $Apache::lonhomework::results{"resource.$version.0.checkedin"}=
- $user.'@'.$domain;
- $Apache::lonhomework::results{"resource.$version.0.checkedin.slot"}=
- $slot_name;
-
+ if ($authenticated) {
+ my $check = &check_in($type,$user,$domain,$slot_name,$slot->{'iptied'});
+ if ($check =~ /^error:/) {
+ return 0;
+ }
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;
}
}
}
return 0;
}
+sub check_in {
+ my ($type,$user,$domain,$slot_name,$needsiptied) = @_;
+ my $useslots = &Apache::lonnet::EXT("resource.0.useslots");
+ my $ip=$ENV{'REMOTE_ADDR'} || $env{'request.host'};
+ if ( $useslots eq 'map_map') {
+ my $result = &check_in_sequence($user,$domain,$slot_name,$ip,$needsiptied);
+ if ($result =~ /^error: /) {
+ return $result;
+ }
+ } else {
+ my ($symb) = &Apache::lonnet::whichuser();
+ my $result = &create_new_version($type,$user,$domain,$slot_name,$symb,$ip,$needsiptied);
+ if ($result eq 'ok') {
+ &Apache::structuretags::finalize_storage();
+ }
+ return $result;
+ }
+ return 1;
+}
+
+sub check_in_sequence {
+ my ($user,$domain,$slot_name,$ip,$needsiptied) = @_;
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ return 'error: No navmap';
+ }
+ my ($symb) = &Apache::lonnet::whichuser();
+ my ($map) = &Apache::lonnet::decode_symb($symb);
+ my @resources =
+ $navmap->retrieveResources($map, sub { $_[0]->is_problem() || $_[0]->is_tool() },0,0);
+ my %old_history = %Apache::lonhomework::history;
+ my %old_results = %Apache::lonhomework::results;
+
+ my $errorcount;
+ foreach my $res (@resources) {
+ &Apache::lonxml::debug("doing ".$res->src);
+ &Apache::structuretags::initialize_storage($res->symb);
+ my $type;
+ if ($res->is_task()) {
+ $type = 'Task';
+ } elsif ($res->is_tool) {
+ $type = 'tool';
+ } else {
+ $type = 'problem';
+ }
+ my $result = &create_new_version($type,$user,$domain,$slot_name,$res->symb,$ip,$needsiptied);
+ if ($result eq 'ok') {
+ &Apache::structuretags::finalize_storage($res->symb);
+ } else {
+ $errorcount ++;
+ }
+ }
+
+ %Apache::lonhomework::history = %old_history;
+ %Apache::lonhomework::results = %old_results;
+ if ($errorcount) {
+ return 'error: IP taken';
+ }
+}
+
+sub create_new_version {
+ my ($type,$user,$domain,$slot_name,$symb,$ip,$needsiptied) = @_;
+
+ if ($needsiptied) {
+ my $uniqkey = "$slot_name\0$symb\0$ip";
+ my ($cdom,$cnum);
+ if ($env{'request.course.id'}) {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my %hash = (
+ "$slot_name\0$symb\0$ip" => $env{'user.name'}.':'.$env{'user.domain'},
+ );
+ unless (&Apache::lonnet::newput('slot_uniqueips',\%hash,$cdom,$cnum) eq 'ok') {
+ return 'error: IP taken';
+ }
+ }
+ }
+
+ my $id = '0';
+ if ($type eq 'Task') {
+ # increment version
+ my $version=
+ $Apache::lonhomework::history{'resource.0.version'};
+ $version++;
+ &Apache::lonxml::debug("Making version $version");
+ #clean out all current results
+ foreach my $key (keys(%Apache::lonhomework::history)) {
+ if ($key=~/^resource\.0\./) {
+ $Apache::lonhomework::results{$key}='';
+ }
+ }
+
+ #setup new version and who did it
+ $Apache::lonhomework::results{'resource.0.version'}=$version;
+ $id = "$version.0";
+ if (!defined($user) || !defined($domain)) {
+ $user = $env{'user.name'};
+ $domain = $env{'user.domain'};
+ }
+
+ } elsif (($type eq 'problem') || ($type eq 'tool')) {
+ &Apache::lonxml::debug("authed $slot_name");
+ }
+ if (!defined($user) || !defined($domain)) {
+ $user = $env{'user.name'};
+ $domain = $env{'user.domain'};
+ }
+
+ $Apache::lonhomework::results{"resource.$id.checkedin"}=
+ $user.':'.$domain;
+ $Apache::lonhomework::results{"resource.$id.checkedin.ip"}=$ip;
+
+ if (defined($slot_name)) {
+ $Apache::lonhomework::results{"resource.$id.checkedin.slot"}=
+ $slot_name;
+ }
+ return 'ok';
+}
+
sub get_version {
my ($version,$previous);
if ($env{'form.previousversion'} &&
@@ -120,7 +221,11 @@ sub get_version {
$version=$env{'form.previousversion'};
$previous=1;
} else {
- $version=$Apache::lonhomework::history{'resource.0.version'};
+ if (defined($Apache::lonhomework::results{'resource.0.version'})) {
+ $version=$Apache::lonhomework::results{'resource.0.version'};
+ } elsif (defined($Apache::lonhomework::history{'resource.0.version'})) {
+ $version=$Apache::lonhomework::history{'resource.0.version'};
+ }
$previous=0;
}
if (wantarray) {
@@ -131,6 +236,10 @@ sub get_version {
sub add_previous_version_button {
my ($status)=@_;
+ my (undef,undef,$udom,$uname)=&Apache::lonnet::whichuser();
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
+ return;
+ }
my $result;
if ($Apache::lonhomework::history{'resource.0.version'} eq '') {
return '';
@@ -167,45 +276,68 @@ sub add_previous_version_button {
}
sub add_grading_button {
- my (undef,$cid)=&Apache::lonxml::whichuser();
+ my (undef,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
+ return;
+ }
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
- my %sections;
- my $numsections=&Apache::loncommon::get_sections($cdom,$cnum,\%sections);
+ my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
+
my $size=5;
if (scalar(keys(%sections)) < 3) {
$size=scalar(keys(%sections))+2;
}
- my $sec_select = '\n";
+
+ my $uri=$env{'request.uri'};
+ if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
+ my $result =
+ '
'."\n";
+ }
+ $result .= ''."\n";
+ return $result;
+}
+
+sub add_slotlist_button {
+ my (undef,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
+ return;
+ }
+ my $symb=&Apache::lonnet::symbread();
+ my $result;
+ if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'}) ||
+ &Apache::lonnet::allowed('mgq',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ $result = '';
+ my $target_id =
+ &Apache::lonstathelpers::make_target_id({symb => $symb,
+ part => '0'});
+ if (!§ion_restricted()) {
+ $result.='';
+ }
+ }
return $result;
}
sub add_request_another_attempt_button {
my ($text)=@_;
- if (!$text) { $text="Request another attempt"; }
+ my (undef,$cid,$udom,$uname)=&Apache::lonnet::whichuser();
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
+ return;
+ }
+ if (!$text) { $text=&mt('Request another attempt'); }
my $result;
my $symb=&Apache::lonnet::symbread();
+ # not a slot access based resource
+ my $useslots = &Apache::lonnet::EXT("resource.0.useslots",$symb);
+ if ($useslots =~ /^\s*no\s*$/i) {
+ return '';
+ }
+
my ($slot_name,$slot)=&Apache::slotrequest::check_for_reservation($symb);
my $action='get_reservation';
if ($slot_name) {
- $text="Change reservation.";
+ $text=&mt('Change reservation');
$action='change_reservation';
my $description=&Apache::slotrequest::get_description($slot_name,
$slot);
- $result.=(< Will be next available: $description
-STUFF
+ $result.='
'
+ .&mt('Will be next available:')
+ .' '.$description
+ .'
';
}
if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); }
- $symb=&Apache::lonnet::escape($symb);
- $result.='';
+ $text.'" />'."\n\t".
+ ''."\n";
return $result;
}
@@ -262,9 +437,22 @@ sub style {
my ($target) = @_;
if ($target eq 'web'
|| $target eq 'webgrade') {
- return (<
STYLE
+ if ($env{'browser.type'} eq 'explorer'
+ && $env{'browser.os'} eq 'win' ) {
+ if ($env{'browser.version'} < 7) {
+ $style .= (<
+STYLE
+ } else {
+ $style .= (<
+STYLE
+ }
+ }
+ return $style;
}
return;
}
@@ -276,27 +464,70 @@ sub show_task {
( $status eq 'BANNED') ||
( $status eq 'UNAVAILABLE') ||
( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NOT_YET_VIEWED') ||
( $status eq 'NEEDS_CHECKIN') ||
( $status eq 'WAITING_FOR_GRADE') ||
- ( $status eq 'INVALID_ACCESS') )) {
+ ( $status eq 'INVALID_ACCESS') ||
+ ( &get_version() eq ''))) {
return 0;
}
if ($env{'form.donescreen'}) { return 0; }
return 1;
}
+my @delay;
+sub nest {
+ if (@delay) {
+ return $delay[-1];
+ } else {
+ return;
+ }
+}
+
+sub start_delay {
+ push(@delay,1);
+}
+sub end_delay {
+ pop(@delay);
+}
+
+sub nested_parse {
+ my ($str,$env,$args) = @_;
+ my @old_env = @Apache::scripttag::parser_env;
+ @Apache::scripttag::parser_env = @$env;
+ if (exists($args->{'set_dim_id'})) {
+ &enable_dimension_parsing($args->{'set_dim_id'});
+ }
+ push(@delay,(($args->{'delayed_dim_results'})? 1 : 0));
+ my $result = &Apache::scripttag::xmlparse($$str);
+ pop(@delay);
+ if (exists($args->{'set_dim_id'})) {
+ &disable_dimension_parsing();
+ }
+ @Apache::scripttag::parser_env = @old_env;
+ if ($args->{'delayed_dim_results'}) {
+ my $dim = &get_dim_id();
+ &Apache::lonxml::debug(" tossing out $result ");
+ &Apache::lonxml::debug(" usining out $dim 's ". $dimension{$dim}{'result'});
+ return $dimension{$dim}{'result'};
+ }
+ return $result;
+}
+
sub internal_location {
my ($id)=@_;
return '';
}
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;
@@ -307,16 +538,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;
@@ -325,7 +558,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/';
@@ -334,39 +567,130 @@ sub file_list {
my $file=$file_url.$partial_file;
$file=~s|/+|/|g;
&Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
- $file_list.='
'.&mt('Message sent to instructor: [_1]',
+ $comment_status).'
';
+ }
+
+ return "
$title
"
+ .$shown
+ .$message_status
+ .$comment_status;
}
sub start_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my ($status,$accessmsg,$slot);
+ &Apache::structuretags::init_problem_globals('Task');
if ($target ne 'webgrade') {
- &Apache::structuretags::init_problem_globals('Task');
&Apache::structuretags::initialize_storage();
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
if ($env{'request.state'} eq 'construct') {
@@ -375,112 +699,125 @@ sub start_Task {
}
$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);
-
- $head_tag_start .= &style($target);
- $body_tag_start .= '
'."\n";
+ my $name;
if ($target eq 'web' || $target eq 'webgrade') {
- $head_tag_start.=''.
- &Apache::structuretags::get_resource_name($parstack,$safeeval).
- '';
+ $name = &Apache::structuretags::get_resource_name($parstack,$safeeval);
+ }
+
+ my ($result,$form_tag_start);
+ if ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex'
+ || $target eq 'edit') {
+ ($result,$form_tag_start) =
+ &Apache::structuretags::page_start($target,$token,$tagstack,
+ $parstack,$parser,$safeeval,
+ $name,&style($target));
+
+ }
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex') {
+ if ($env{'form.markaccess'}) {
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ my ($timelimit) = ($interval[0] =~ /^(\d+)/);
+ &Apache::lonnet::set_first_access($interval[1],$timelimit);
+ }
}
if ($target eq 'web' && $env{'request.state'} ne 'construct') {
- if ($Apache::lonhomework::modifygrades) {
- $body_tag_start.='";
+ if ($Apache::lonhomework::queuegrade
+ || $Apache::lonhomework::modifygrades) {
+ $result .= &add_grading_button();
my $symb=&Apache::lonnet::symbread();
- if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
- $body_tag_start.='';
- my $target_id =
- &Apache::lonstathelpers::make_target_id({symb => $symb,
- part => '0'});
- $body_tag_start.='';
+ if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('mgq',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ $result .= &add_slotlist_button();
}
}
}
- if ($target eq 'web' && $env{'request.state'} eq 'construct') {
+ if ($target =~/(web|webgrade)/ && $env{'request.state'} eq 'construct') {
$form_tag_start.=&Apache::structuretags::problem_web_to_edit_header($env{'form.rndseed'});
}
- if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
- $target eq 'tex') {
+ if ($target eq 'web'
+ || ($target eq 'grade' && !$env{'form.webgrade'})
+ || $target eq 'answer'
+ || $target eq 'tex') {
my ($version,$previous)=&get_version();
($status,$accessmsg,my $slot_name,$slot) =
&Apache::lonhomework::check_slot_access('0','Task');
+ if ((($status eq 'CAN_ANSWER') || ($status eq 'NOT_YET_VIEWED')) && ($version eq '')) {
+ # CAN_ANSWER or NOT_YET_VIEWED mode, and no current version, unproctored access
+ # thus self-checkedin
+ my $needsiptied;
+ if (ref($slot)) {
+ $needsiptied = $slot->{'iptied'};
+ }
+ my $check = &check_in('Task',undef,undef,$slot_name,$needsiptied);
+ if ($check =~ /^error:\s+(.*)$/) {
+ my $symb=&Apache::lonnet::symbread();
+ &Apache::lonnet::logthis("Error: $1 during self-checkin of version $version of Task (symb: $symb) using slot: $slot_name");
+ }
+ &add_to_queue('gradingqueue',{'type' => 'Task',
+ 'time' => time,
+ 'slot' => $slot_name});
+ ($version,$previous)=&get_version();
+ }
+ if (($target eq 'web') && ($version ne '') && ($slot_name ne '')) {
+ if (ref($slot) eq 'HASH') {
+ if ($slot->{'endtime'} > time()) {
+ $result .=
+ &Apache::lonhtmlcommon::set_due_date($slot->{'endtime'});
+ }
+ }
+ }
+
+ my $status_id = 'LC_task_take';
+ if ($previous && $target eq 'answer') {
+ $status_id = 'LC_task_answer';
+ } elsif ($previous || $status eq 'SHOW_ANSWER') {
+ $status_id = 'LC_task_feedback';
+ }
+ $result .= '
'."\n";
+
push(@Apache::inputtags::status,$status);
$Apache::inputtags::slot_name=$slot_name;
my $expression='$external::datestatus="'.$status.'";';
$expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.0.solved"}.'";';
&Apache::run::run($expression,$safeeval);
&Apache::lonxml::debug("Got $status");
- $body_tag_start.=&add_previous_version_button($status);
+ $result.=&add_previous_version_button($status);
if (!&show_task($status,$previous)) {
my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
if ( $target eq "web" ) {
- $result.= $head_tag_start.''.$body_tag_start;
if ($env{'request.state'} eq 'construct') {
$result.=$form_tag_start;
}
my $msg;
if ($status eq 'UNAVAILABLE') {
- $msg.='
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'
';
+ $msg.='
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'
';
}
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 {
@@ -490,19 +827,21 @@ DONESCREEN
if ($status eq 'NEEDS_CHECKIN') {
if(&proctor_check_auth($slot_name,$slot,'Task')
&& defined($Apache::inputtags::slot_name)) {
- my $result=&add_to_queue('gradingqueue',
- [$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') {
- $result.="$head_tag_start
- $body_tag_start \n";
-
+
$result.=&preserve_grade_info();
- $result.=&internal_location();
- $result.=$form_tag_start.
+ $result.=&internal_location();
+ $result.=$form_tag_start."\t".
'';
&Apache::lonxml::startredirection();
}
@@ -510,29 +849,28 @@ DONESCREEN
$target eq 'webgrade') {
my $webgrade='yes';
if ($target eq 'webgrade') {
- $result.=$head_tag_start.
- ''.$body_tag_start.
- "\n".'
'."\n".
+ $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,$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.'
'.
+ &mt('Grading [_1] for [_2] at [_3]',
+ &Apache::lonnet::gettitle($symb),$uname,$udom).'
';
$form_tag_start.=
'';
+ &escape($todo).'" />';
$Apache::bridgetask::queue_key=$todo;
&Apache::structuretags::initialize_storage();
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
@@ -547,6 +885,22 @@ DONESCREEN
&mt('Return to resource').'';
if ($status_code eq 'stop') {
$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 requested record.")
.''.$back;
@@ -567,6 +921,8 @@ DONESCREEN
}
}
$webgrade='no';
+ }
+ if (!$todo || $env{'form.cancel'}) {
my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
}
if ($target eq 'webgrade' && defined($env{'form.queue'})) {
@@ -582,26 +938,42 @@ DONESCREEN
$result.='';
}
- if ($env{'form.chosensections'}) {
- my @chosen_sections=
- &Apache::loncommon::get_env_multiple('form.chosensections');
+ 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.=$head_tag_start."".$body_tag_start.$form_tag_start.
+ $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.")." ";
- my $temp=&Apache::edit::insertlist($target,$token);
- $result.=$temp;
+ $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
$result = '';
@@ -609,10 +981,30 @@ DONESCREEN
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';
@@ -632,18 +1024,25 @@ sub get_key_todo {
}
- my $me=$env{'user.name'}.'@'.$env{'user.domain'};
+ 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::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'};
- my $udom = $env{'form.gradingdomain'};
-
+ 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;
@@ -657,18 +1056,34 @@ sub get_key_todo {
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'}=&Apache::lonnet::escape($gradingkey);
+ $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');
@@ -678,7 +1093,7 @@ sub get_key_todo {
#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'}));
+ $who,$env{'form.gradinguser'}.':'.$env{'form.gradingdomain'}));
}
@@ -688,13 +1103,17 @@ sub get_key_todo {
$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,'select_user');
}
@@ -740,12 +1159,17 @@ 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)
@@ -775,82 +1199,126 @@ sub end_Task {
}
if ($status eq 'CAN_ANSWER' && !$previous &&
!$env{'form.donescreen'}) {
- $result.="\n".'
'.
+ 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.0.$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, of which you passed [_4].',$man_count,$opt_req,$opt_count,$opt_passed)."
\n";
my $internal_location=&internal_location();
$result=~s/\Q$internal_location\E/$status/;
}
- }
- if ($target eq 'web') {
- $result.="\n