';
+ &Apache::lonxml::startredirection();
+ &start_delay();
+ $dimension{$top}{'result'}=$result;
+ undef($result);
}
} elsif ($target eq 'edit') {
$result.=$form_tag_start.
@@ -611,6 +817,20 @@ 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;
@@ -640,7 +860,7 @@ sub get_key_todo {
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'};
@@ -659,18 +879,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');
@@ -690,13 +926,15 @@ 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.next'}) {
return (undef,'select_user');
}
@@ -742,7 +980,8 @@ 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'})
+ && $target eq 'webgrade')
&& !$env{'form.gradingaction'}) {
&Apache::lonxml::debug("Getting anew $queue");
return (&get_from_queue($queue));
@@ -789,7 +1028,12 @@ sub end_Task {
if (!$previous && $status ne 'SHOW_ANSWER' &&
&show_task($status,$previous)) {
$result.=&Apache::inputtags::gradestatus('0');
- $result.='';
+ }
+
+ $result.='';
+
+ if (!$previous && $status ne 'SHOW_ANSWER' &&
+ &show_task($status,$previous)) {
my $action = &Apache::lonenc::check_encrypt($env{'request.uri'});
$result.=<
@@ -803,54 +1047,78 @@ DONEBUTTON
my $bt_status=$Apache::lonhomework::history{"resource.$version.0.status"};
my $title=&Apache::lonnet::gettitle();
+ my $start_time;
+
my $slot_name=
$Apache::lonhomework::history{"resource.$version.0.checkedin.slot"};
- my %slot=&Apache::lonnet::get_slot($slot_name);
- my $start_time=
- &Apache::lonlocal::locallocaltime($slot{'starttime'});
+ if ($slot_name) {
+ my %slot=&Apache::lonnet::get_slot($slot_name);
+
+ $start_time=$slot{'starttime'}
+ } else {
+ $start_time=
+ &Apache::lonnet::EXT('resource.0.opendate');
+ }
+ $start_time=&Apache::lonlocal::locallocaltime($start_time);
- my $status = "\n\n";
+ my $status =
+ "\n
\n\t";
+ my $dim = $top;
+ my %counts = &get_counts($dim,undef,$parstack,
+ $safeeval);
+ my $question_status ="\n\t
".
+ &question_status_message(\%counts,-1).
+ "
\n";
+
if ($bt_status eq 'pass') {
$status.='
You passed the '.$title.' given on '.
$start_time.' ';
+ $status.=$question_status;
}
if ($bt_status eq 'fail') {
$status.='
You did not pass the '.$title.' given on '.
$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 \n".
&Apache::loncommon::end_page({'discussion' => 1});
}
}
- if ($target eq 'grade' && !$env{'form.webgrade'} && !$previous) {
+
+ my $useslots = &Apache::lonnet::EXT("resource.0.useslots");
+ my %queue_data = ('type' => 'Task',
+ 'time' => time,);
+ if (defined($Apache::inputtags::slot_name)) {
+ $queue_data{'slot'} = $Apache::inputtags::slot_name;
+ } elsif (defined($Apache::lonhomework::history{"resource.$version.0.checkedin.slot"})) {
+ $queue_data{'slot'} = $Apache::lonhomework::history{"resource.$version.0.checkedin.slot"};
+ }
+
+
+ if ($target eq 'grade' && !$env{'form.webgrade'} && !$previous
+ && $status eq 'CAN_ANSWER') {
my $award='SUBMITTED';
&Apache::essayresponse::file_submission("$version.0",'bridgetask',
'portfiles',\$award);
@@ -871,14 +1139,16 @@ DONEBUTTON
}
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
&Apache::structuretags::finalize_storage();
- if ($award eq 'SUBMITTED'
- && defined($Apache::inputtags::slot_name)) {
- &add_to_queue('gradingqueue',[$Apache::inputtags::slot_name]);
+ if ($award eq 'SUBMITTED') {
+ &add_to_queue('gradingqueue',\%queue_data);
}
- } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
- &Apache::structuretags::finalize_storage();
}
- if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
+ if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes'
+ && exists($env{'form.cancel'})) {
+ &check_queue_unlock($env{'form.queue'});
+ &Apache::lonxml::debug(" cancelled grading .".$env{'form.queue'});
+ } elsif ($target eq 'grade' && $env{'form.webgrade'} eq 'yes'
+ && !exists($env{'form.cancel'})) {
my $optional_required=
&Apache::lonxml::get_param('OptionalRequired',$parstack,
$safeeval);
@@ -887,19 +1157,29 @@ DONEBUTTON
my $ungraded=0;
my $review=0;
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
- foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
+ my $dim = $top;
+ foreach my $id (@{$dimension{$dim}{'criterias'}}) {
+ my $link=&link($id);
+
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+
+ if ($type eq 'criteria') {
+ # dimensional 'criteria' don't get assigned grades
+ $Apache::lonhomework::results{"resource.$version.0.$id.status"}=$env{'form.HWVAL_'.$link};
+ $Apache::lonhomework::results{"resource.$version.0.$id.comment"}=$env{'form.HWVAL_comment_'.$link};
+ }
my $status=
- $Apache::lonhomework::results{"resource.$version.0.$dim_id.status"};
- my $mandatory=
- ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
+ $Apache::lonhomework::results{"resource.$version.0.$id.status"};
+ my $mandatory=($dimension{$dim}{'criteria.'.$id.'.mandatory'} ne 'N');
+
if ($status eq 'pass') {
if (!$mandatory) { $optional_passed++; }
} elsif ($status eq 'fail') {
if ($mandatory) { $mandatory_failed++; }
- } elsif ($status eq 'ungraded') {
- $ungraded++;
} elsif ($status eq 'review') {
$review++;
+ } elsif ($status eq 'ungraded') {
+ $ungraded++;
} else {
$ungraded++;
}
@@ -907,34 +1187,19 @@ DONEBUTTON
if ($optional_passed < $optional_required) {
$mandatory_failed++;
}
- &Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
+ &Apache::lonxml::debug(" task results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
$Apache::lonhomework::results{'resource.0.regrader'}=
$env{'user.name'}.':'.$env{'user.domain'};
if ($review) {
$Apache::lonhomework::results{"resource.$version.0.status"}='review';
- if ($env{'form.queue'} eq 'reviewqueue') {
- &check_queue_unlock($env{'form.queue'});
- &Apache::lonxml::debug(" still needs review not changing status.");
- } else {
- &move_between_queues($env{'form.queue'},'reviewqueue');
- }
} elsif ($ungraded) {
$Apache::lonhomework::results{"resource.$version.0.status"}='ungraded';
- if ($env{'form.queue'} eq 'reviewqueue' ||
- $env{'form.queue'} eq 'none' ) {
- &Apache::lonxml::debug("moving back.");
- &move_between_queues($env{'form.queue'},'gradingqueue');
- } else {
- &check_queue_unlock($env{'form.queue'});
- }
} elsif ($mandatory_failed) {
$Apache::lonhomework::results{"resource.$version.0.status"}='fail';
$Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
$Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
$Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
- &remove_from_queue($env{'form.queue'});
-
- my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
if ($env{'form.regrade'} ne 'yes') {
$Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
@@ -950,9 +1215,7 @@ DONEBUTTON
$Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
$Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
$Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
- &remove_from_queue($env{'form.queue'});
-
- my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
if ($env{'form.regrade'} ne 'yes') {
$Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
@@ -975,9 +1238,67 @@ DONEBUTTON
}
&minimize_storage();
&Apache::structuretags::finalize_storage();
+
+ # data stored, now handle queue
+ if ($review) {
+ if ($env{'form.queue'} eq 'reviewqueue') {
+ &check_queue_unlock($env{'form.queue'});
+ &Apache::lonxml::debug(" still needs review not changing status.");
+ } else {
+ if ($env{'form.queue'} ne 'none') {
+ &move_between_queues($env{'form.queue'},'reviewqueue');
+ } else {
+ &add_to_queue('reviewqueue',\%queue_data);
+ }
+ }
+ } elsif ($ungraded) {
+ if ($env{'form.queue'} eq 'reviewqueue') {
+ &Apache::lonxml::debug("moving back.");
+ &move_between_queues($env{'form.queue'},
+ 'gradingqueue');
+ } elsif ($env{'form.queue'} eq 'none' ) {
+ &add_to_queue('gradingqueue',\%queue_data);
+ } else {
+ &check_queue_unlock($env{'form.queue'});
+ }
+ } elsif ($mandatory_failed) {
+ &remove_from_queue($env{'form.queue'});
+ } else {
+ &remove_from_queue($env{'form.queue'});
+ }
+ }
+ if (exists($Apache::lonhomework::results{'INTERNAL_store'})) {
+ # instance generation occured and hasn't yet been stored
+ &Apache::structuretags::finalize_storage();
}
} elsif ($target eq 'webgrade') {
- $result.="";
+ if (&nest()) {
+ &Apache::lonxml::endredirection();
+ &end_delay();
+ $result.=$dimension{$top}{'result'};
+ } else {
+ $result.=&Apache::lonxml::endredirection();
+ }
+ my $dim = $top;
+ foreach my $id (@{$dimension{$dim}{'criterias'}} ) {
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+ if ($type eq 'dimension') {
+ # dimensional 'criteria' don't get assigned grades
+ next;
+ } else {
+ my $criteria =&nested_parse(\$dimension{$dim}{'criteria.'.$id},
+ [@_]);
+ $criteria = &layout_webgrade_Criteria($dim,$id,$criteria);
+ my $internal_location=&internal_location($id);
+ if ($result =~ m/\Q$internal_location\E/) {
+ $result=~s/\Q$internal_location\E/$criteria/;
+ } else {
+ $result.=$criteria;
+ }
+
+ }
+ }
+ $result.="";
#$result.='\n";
- if ($dim_status eq 'pass') {
- $dim_info.='
Question : you passed this '.$mandatory.' question ';
- }
- if ($dim_status eq 'fail') {
- $dim_info.='
Question : you did not pass this '.$mandatory.' question ';
- }
- my $man_count=0;
- my $man_passed=0;
- my $opt_count=0;
- my $opt_passed=0;
- foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- if ($dimension{$instance.'.criteria.'.$id.'.mandatory'}
- eq 'N') {
- $opt_count++;
- if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') {
- $opt_passed++;
- }
- } else {
- $man_count++;
- if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') {
- $man_passed++;
- }
- }
+sub get_criteria {
+ my ($what,$version,$dim,$id) = @_;
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+ my $prefix = ($type eq 'criteria' && $dim ne $top) ? "$dim.$id"
+ : "$id";
+ my $entry = "resource.$version.0.$prefix.$what";
+ if (exists($Apache::lonhomework::results{$entry})) {
+ return $Apache::lonhomework::results{$entry};
+ }
+ return $Apache::lonhomework::history{$entry};
+}
+
+sub link {
+ my ($id) = @_;
+ $id =~ s/\./_/g;
+ return 'LC_GRADING_criteria_'.$id;
+}
+sub end_Question { return &end_Dimension(@_); }
+sub end_Dimension {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my $result=&Apache::lonxml::endredirection();
+ my $dim=&get_id($parstack,$safeeval);
+ if (&skip_dimension_parsing($dim)) {
+ &disable_dimension_parsing($dim);
+ pop(@Apache::bridgetask::dimension);
+ return;
+ }
+ my $instance=&get_instance($dim);
+ my $version=&get_version();
+ if ($target eq 'web') {
+ $result .= &nested_parse(\$dimension{$dim}{'intro'},[@_]);
+ my @instances = $instance;
+ if (&Apache::response::showallfoils()) {
+ @instances = @{$dimension{$dim}{'instances'}};
+ }
+ my $shown_question_text;
+ foreach my $instance (@instances) {
+ $result .= &nested_parse(\$dimension{$dim}{$instance.'.text'},
+ [@_]);
+ $result .= &nested_parse(\$dimension{$dim}{'questiontext'},
+ [@_],{'set_dim_id' => undef});
+ my $task_status =
+ $Apache::lonhomework::history{"resource.$version.0.status"};
+ if ($task_status ne 'pass' && $task_status ne 'fail') {
+
+ foreach my $id (@{$dimension{$dim}{$instance.'.criterias'}},
+ @{$dimension{$dim}{'criterias'}}) {
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+ &Apache::lonxml::debug("$id is $type");
+ if ($type eq 'dimension') {
+ $result.=
+ &nested_parse(\$dimension{$dim}{'criteria.'.$id},
+ [@_],{'set_dim_id' => $id});
}
- if ($man_passed eq $man_count) { $man_passed='all'; }
- my $opt_req=$dimension{$instance.'.optionalrequired'};
- if ($opt_req !~ /\S/) { $opt_req='0'; }
- $dim_info.="\n
".&mt('You passed [_1] of the [_2] mandatory components and [_3] of the [_4] optional components, of which you were required to pass [_5].',$man_passed,$man_count,$opt_passed,$opt_count,$opt_req)."
\n
";
-
- my $internal_location=&internal_location($dim);
- $result=~s/\Q$internal_location\E/$dim_info/;
-
- foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"};
- my $comment=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"};
- my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
- if ($mandatory) {
- $mandatory='Mandatory';
- } else {
- $mandatory='Optional';
- }
- if ($status eq 'fail') {
- } elsif ($status eq 'pass') {
+ }
+ } else {
+ my $dim_status=$Apache::lonhomework::history{"resource.$version.0.$dim.status"};
+ my $mandatory='Mandatory';
+ if (&Apache::lonxml::get_param('Mandatory',$parstack,$safeeval) eq 'N') {
+ $mandatory='Optional';
+ }
+ my $dim_info=
+ "\n};
+ } else {
+ $result = "\n".'
'.
+ "\n".$result;
}
- } elsif ($target eq 'webgrade') {
- # in case of any side effects that we need
- @Apache::scripttag::parser_env = @_;
- &Apache::scripttag::xmlparse($dimension{'intro'});
- @Apache::scripttag::parser_env = @_;
- &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
- foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- my $link=&link($instance,$id);
- my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"};
- $result.='
'."\n";
- $result.=&grading_history($version,$dim,$instance,$id);
- $last_link=$link;
- }
- } elsif ($target eq 'grade' && $env{'form.webgrade'}) {
- my $optional_passed=0;
- my $mandatory_failed=0;
- my $ungraded=0;
- my $review=0;
- foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- my $link=&link($instance,$id);
- my $status=$Apache::lonhomework::results{"resource.$version.0.$dim.$instance.$id.status"}=$env{'form.HWVAL_'.$link};
- $Apache::lonhomework::results{"resource.$version.0.$dim.$instance.$id.comment"}=$env{'form.HWVAL_comment_'.$link};
- my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
- if ($status eq 'pass') {
- if (!$mandatory) { $optional_passed++; }
- } elsif ($status eq 'fail') {
- if ($mandatory) { $mandatory_failed++; }
- } elsif ($status eq 'review') {
- $review++;
- } elsif ($status eq 'ungraded') {
- $ungraded++;
+ $result .= "\n
\n";
+ }
+ } elsif ($target eq 'webgrade') {
+ # in case of any side effects that we need
+ &nested_parse(\$dimension{$dim}{'intro'},[@_]);
+ &nested_parse(\$dimension{$dim}{$instance.'.text'},[@_]);
+ $result.=
+ &nested_parse(\$dimension{$dim}{'questiontext'},[@_],
+ {'set_dim_id' => undef,
+ 'delayed_dim_results' => 1});
+ foreach my $id (@{$dimension{$dim}{$instance.'.criterias'}},
+ @{$dimension{$dim}{'criterias'}} ) {
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+ if ($type eq 'dimension') {
+ # dimensional 'criteria' don't get assigned grades
+ $result.=
+ &nested_parse(\$dimension{$dim}{'criteria.'.$id},
+ [@_],{'set_dim_id' => $id});
+ next;
+ } else {
+ my $criteria =&nested_parse(\$dimension{$dim}{'criteria.'.$id},
+ [@_]);
+ $criteria = &layout_webgrade_Criteria($dim,$id,$criteria);
+ my $internal_location=&internal_location($id);
+ if ($result =~ m/\Q$internal_location\E/) {
+ $result =~ s/\Q$internal_location\E/$criteria/;
} else {
- $ungraded++;
+ $result.=$criteria ;
}
}
- if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
- $mandatory_failed++;
- }
- &Apache::lonxml::debug("all instance ".join(':',@{$dimension{$instance.'.criterias'}})." results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
- if ($review) {
- $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
- 'review';
- } elsif ($ungraded) {
- $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
- 'ungraded';
- } elsif ($mandatory_failed) {
- $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
- 'fail';
+ }
+ if (&nest()) {
+ &Apache::lonxml::debug(" for $dim stashing results into ".$dimension{$dim}{'nested'});
+ $dimension{$dimension{$dim}{'nested'}}{'result'}.=$result;
+ undef($result);
+ }
+ } elsif ($target eq 'grade' && $env{'form.webgrade'}) {
+ my $optional_passed=0;
+ my $mandatory_failed=0;
+ my $ungraded=0;
+ my $review=0;
+
+ $result .= &nested_parse(\$dimension{$dim}{'intro'},[@_]);
+ $result .= &nested_parse(\$dimension{$dim}{$instance.'.text'},
+ [@_]);
+ $result .= &nested_parse(\$dimension{$dim}{'questiontext'},
+ [@_],{'set_dim_id' => undef});
+
+ foreach my $id (@{$dimension{$dim}{$instance.'.criterias'}},
+ @{$dimension{$dim}{'criterias'}}) {
+ my $link=&link($id);
+
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+ if ($type eq 'criteria') {
+ # dimensional 'criteria' don't get assigned grades
+ $Apache::lonhomework::results{"resource.$version.0.$dim.$id.status"}=$env{'form.HWVAL_'.$link};
+ $Apache::lonhomework::results{"resource.$version.0.$dim.$id.comment"}=$env{'form.HWVAL_comment_'.$link};
+ } else {
+ $result .=
+ &nested_parse(\$dimension{$dim}{'criteria.'.$id},
+ [@_],{'set_dim_id' => $id});
+ }
+ my $status= &get_criteria('status',$version,$dim,$id);
+
+ my $mandatory=($dimension{$dim}{'criteria.'.$id.'.mandatory'} ne 'N');
+ if ($status eq 'pass') {
+ if (!$mandatory) { $optional_passed++; }
+ } elsif ($status eq 'fail') {
+ if ($mandatory) { $mandatory_failed++; }
+ } elsif ($status eq 'review') {
+ $review++;
+ } elsif ($status eq 'ungraded') {
+ $ungraded++;
} else {
- $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
- 'pass';
+ $ungraded++;
}
+ }
+
+ my $opt_req=$dimension{$dim}{$instance.'.optionalrequired'};
+ if ($opt_req !~ /\S/) {
+ $opt_req=
+ &Apache::lonxml::get_param('OptionalRequired',
+ $parstack,$safeeval);
+ if ($opt_req !~ /\S/) { $opt_req = 0; }
+ }
+ if ($optional_passed < $opt_req) {
+ $mandatory_failed++;
+ }
+ &Apache::lonxml::debug("all instance ".join(':',@{$dimension{$dim}{$instance.'.criterias'}})." results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
+ if ($review) {
+ $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
+ 'review';
+ } elsif ($ungraded) {
+ $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
+ 'ungraded';
+ } elsif ($mandatory_failed) {
+ $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
+ 'fail';
} else {
- # any other targets no output
- undef($result);
+ $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
+ 'pass';
}
- return $result;
+ } else {
+ # any other targets no output
+ undef($result);
+ }
+ &disable_dimension_parsing();
+ pop(@Apache::bridgetask::dimension);
+ return $result;
+}
+
+sub question_status_message {
+ my ($counts,$depth) = @_;
+ my %req = ('man' => 'mandatory',
+ 'opt' => 'optional',);
+ my %type = ('cri' => 'criteria',
+ 'dim' => ('sub'x($depth+1)).'questions',);
+ my @sections;
+ foreach my $req ('man','opt') {
+ foreach my $type ('cri','dim') {
+ if ($counts->{$req.'_'.$type}) {
+ push(@sections,
+ $counts->{$req.'_'.$type.'_passed'}.' of the '.
+ $counts->{$req.'_'.$type}.' '.
+ $req{$req}.' '.$type{$type});
+ }
+ }
+ }
+
+ my $status = 'You passed ';
+ if (@sections == -1) {
+ } elsif (@sections == 1) {
+ $status .= $sections[0];
+ } elsif (@sections == 2) {
+ $status .= $sections[0].' and '.$sections[1];
+ } else {
+ my $last = pop(@sections);
+ $status .= join(', ',@sections).', and '.$last;
+ }
+ $status .= '.';
+ if ($counts->{'opt'}) {
+ $status .= ' You were required to pass '.$counts->{'opt_req'}.
+ ' optional component'.($counts->{'opt_req'} == 1?'':'s');
+ }
+ return $status;
+}
+
+sub get_counts {
+ my ($dim,$instance,$parstack,$safeeval) = @_;
+ my %counts;
+ my @possible = ('man_cri','man_dim',
+ 'opt_cri','opt_dim',
+ 'man_cri_passed', 'man_dim_passed',
+ 'opt_cri_passed', 'opt_dim_passed',
+ 'man_passed',
+ 'opt_passed',
+ 'opt_req');
+ foreach my $which (@possible) { $counts{$which} = 0; }
+
+ my $version = &get_version();
+
+ foreach my $id ( @{$dimension{$dim}{$instance.'.criterias'}},
+ @{$dimension{$dim}{'criterias'}} ) {
+ my $status = &get_criteria('status',$version,$dim,$id);
+ my $which;
+ if ($dimension{$dim}{'criteria.'.$id.'.mandatory'}
+ eq 'N') {
+ $which = 'opt';
+ } else {
+ $which = 'man';
+ }
+ $counts{$which}++;
+ if ($status eq 'pass') { $counts{$which.'_passed'}++; }
+ if ($dimension{$dim}{'criteria.'.$id.'.type'}
+ eq 'dimension') {
+ $which .= '_dim';
+ } else {
+ $which .= '_cri';
+ }
+ $counts{$which}++;
+ if ($status eq 'pass') { $counts{$which.'_passed'}++; }
+
+
+ }
+ if ($counts{'man_dim_passed'} eq $counts{'man_dim'}) {
+ $counts{'man_dim_passed'}='all';
+ }
+ if ($counts{'man_cri_passed'} eq $counts{'man_cri'}) {
+ $counts{'man_cri_passed'}='all';
}
+
+ $counts{'opt_req'}=$dimension{$dim}{$instance.'.optionalrequired'};
+ if ($counts{'opt_req'} !~ /\S/) {
+ $counts{'opt_req'}= &Apache::lonxml::get_param('OptionalRequired',
+ $parstack,$safeeval);
+ if ($counts{'opt_req'} !~ /\S/) { $counts{'opt_req'} = 0; }
+ }
+ return %counts;
+}
+
+sub end_Setup {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my $result=&Apache::lonxml::endredirection();
+ my $dim=&get_id($parstack,$safeeval);
+ my $instance=&get_instance($dim);
+ my $version=&get_version();
+ if ($target eq 'web') {
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{$dim}{'intro'});
+ my @instances = $instance;
+ if (&Apache::response::showallfoils()) {
+ @instances = @{$dimension{$dim}{'instances'}};
+ }
+ foreach my $instance (@instances) {
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{$dim}{$instance.'.text'});
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{$dim}{'questiontext'});
+ }
+ } elsif ($target eq 'webgrade'
+ || $target eq 'grade' && $env{'form.webgrade'}) {
+ # in case of any side effects that we need
+ @Apache::scripttag::parser_env = @_;
+ &Apache::scripttag::xmlparse($dimension{$dim}{'intro'});
+ @Apache::scripttag::parser_env = @_;
+ &Apache::scripttag::xmlparse($dimension{$dim}{$instance.'.text'});
+ @Apache::scripttag::parser_env = @_;
+ &Apache::scripttag::xmlparse($dimension{$dim}{'questiontext'});
+ } else {
+ # any other targets no output
+ undef($result);
+ }
+ pop(@Apache::bridgetask::dimension);
+ return $result;
}
sub grading_history {
- my ($version,$dim,$instance,$criteria) = @_;
+ my ($version,$dim,$id) = @_;
if (!&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
return '';
}
my ($result,$grader);
- my $scope="resource.$version.0.$dim.$instance.$criteria";
+ my $scope="resource.$version.0.";
+ $scope .= ($dim ne $top) ? "$dim.$id"
+ : "$id";
foreach my $t (1..$Apache::lonhomework::history{'version'}) {
if (exists($Apache::lonhomework::history{$t.':resource.0.regrader'})) {
my ($gname,$gdom) =
@@ -1865,11 +2583,12 @@ sub grading_history {
$entry.=' comment: "'.$Apache::lonhomework::history{"$t:$scope.comment"}.'"';
}
if ($entry) {
- $result.= "
$grader : $entry ";
+ $result.= "\n\t\t
\n\t\t\t$grader :\n\t\t\t $entry \n\t\t ";
}
}
if ($result) {
- return '
';
+ return "\n\t".'
'."\n";
}
return '';
}
@@ -1877,11 +2596,13 @@ sub grading_history {
sub start_IntroParagraph {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $result;
- if ($target eq 'web' || $target eq 'webgrade') {
- if ($tagstack->[-2] eq 'Dimension') {
- $dimension{'intro'}=&Apache::lonxml::get_all_text('/introparagraph',$parser,$style);
-
- } elsif ($tagstack->[-2] eq 'Task' && $target eq 'webgrade') {
+ my $dim = &get_dim_id();
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ if ($tagstack->[-2] eq 'Dimension' || $tagstack->[-2] eq 'Question' ) {
+ $dimension{$dim}{'intro'}=
+ &Apache::lonxml::get_all_text('/introparagraph',
+ $parser,$style);
+ } elsif ($tagstack->[-2] eq 'Task' && $target eq 'webgrade') {
&Apache::lonxml::startredirection();
}
@@ -1898,15 +2619,16 @@ sub end_IntroParagraph {
sub start_Instance {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- my $id=&get_id($parstack,$safeeval);
- push(@{$dimension{'instances'}},$id);
- push(@Apache::bridgetask::instance,$id);
+ my $dim = &get_dim_id();
+ my $id = &get_id($parstack,$safeeval);
+ push(@{$dimension{$dim}{'instances'}},$id);
+ push(@{$Apache::bridgetask::instance{$dim}},$id);
push(@Apache::bridgetask::instancelist,$id);
- $dimension{$id.'.optionalrequired'}=
+ $dimension{$dim}{$id.'.optionalrequired'}=
&Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval);
my $disabled = &Apache::lonxml::get_param('Disabled',$parstack,$safeeval);
if (lc($disabled) eq 'yes') {
- $dimension{$id.'.disabled'}='1';
+ $dimension{$dim}{$id.'.disabled'}='1';
}
return '';
}
@@ -1916,10 +2638,11 @@ sub end_Instance {
sub start_InstanceText {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- my $instance_id=$Apache::bridgetask::instance[-1];
+ my $dim = &get_dim_id();
+ my $instance_id=$Apache::bridgetask::instance{$dim}[-1];
my $text=&Apache::lonxml::get_all_text('/instancetext',$parser,$style);
- if ($target eq 'web' || $target eq 'webgrade') {
- $dimension{$instance_id.'.text'}=$text;
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ $dimension{$dim}{$instance_id.'.text'}=$text;
}
return '';
}
@@ -1930,24 +2653,148 @@ sub end_InstanceText {
sub start_Criteria {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- my $instance_id=$Apache::bridgetask::instance[-1];
my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser,$style);
+ my $result = '';
if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
+ my $dim = &get_dim_id();
my $id=&get_id($parstack,$safeeval);
- $dimension{$instance_id.'.criteria.'.$id}=$criteria;
- $dimension{$instance_id.'.criteria.'.$id.'.mandatory'}=
- &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
- push(@{$dimension{$instance_id.'.criterias'}},$id);
+ if ($target eq 'web' || $target eq 'webgrade') {
+ if ($target eq 'webgrade') {
+ &Apache::lonxml::debug(" for $dim $id stashing results into $dim ");
+ $dimension{$dim}{'result'} .= &internal_location($id);
+ } else {
+ &Apache::lonxml::debug(" not stashing $dim $id");
+ #$result .= &internal_location($id);
+ }
+ }
+ &Apache::lonxml::debug("Criteria $id with $dim");
+ if (&Apache::londefdef::is_inside_of($tagstack,'Instance')) {
+ my $instance_id=$Apache::bridgetask::instance{$dim}[-1];
+ $dimension{$dim}{"criteria.$instance_id.$id"}=$criteria;
+ $dimension{$dim}{"criteria.$instance_id.$id.type"}='criteria';
+ $dimension{$dim}{"criteria.$instance_id.$id.mandatory"}=
+ &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
+ push(@{$dimension{$dim}{$instance_id.'.criterias'}},"$instance_id.$id");
+ } else {
+ $dimension{$dim}{'criteria.'.$id}=$criteria;
+ $dimension{$dim}{'criteria.'.$id.'.type'}='criteria';
+ $dimension{$dim}{'criteria.'.$id.'.mandatory'}=
+ &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
+ push(@{$dimension{$dim}{'criterias'}},$id);
+ }
}
- return '';
+ return $result;
+}
+
+sub layout_web_Criteria {
+ my ($dim,$id,$criteria) = @_;
+
+ my $version = &get_version();
+ my $status= &get_criteria('status', $version,$dim,$id);
+ my $comment=&get_criteria('comment',$version,$dim,$id);
+ my $mandatory=($dimension{$dim}{'criteria.'.$id.'.mandatory'} ne 'N');
+ if ($mandatory) {
+ $mandatory='Mandatory';
+ } else {
+ $mandatory='Optional';
+ }
+ my $status_display=$status;
+ $status_display=~s/^([a-z])/uc($1)/e;
+ my $criteria_info.=
+ '
'."\n\t".'
'
+ .$mandatory.' Criteria '."\n\t".'
'
+ ."\n";
+ $criteria =~ s/^\s*//s;
+ $criteria =~ s/\s*$//s;
+ $criteria_info.= $criteria;
+ $criteria_info.="\n\t".'
'.
+ "\n\t".'
'.$status_display.'
';
+ if ($comment =~ /\w/) {
+ $criteria_info.=
+ "\n\t".
+ '';
+ }
+ $criteria_info.="\n".'
'."\n";
+
+ return $criteria_info;
+}
+
+sub layout_webgrade_Criteria {
+ my ($dim,$id,$criteria) = @_;
+ my $link=&link($id);
+ my $version = &get_version();
+ my $status = &get_criteria('status',$version,$dim,$id);
+ my %lt = ( 'ungraded' => 'Ungraded',
+ 'fail' => 'Fail',
+ 'pass' => 'Pass',
+ 'review' => 'Review',
+ 'comment' => 'Additional Comment for Student',
+ );
+ %lt = &Apache::lonlocal::texthash(%lt);
+ my $comment = &get_criteria('comment',$version,$dim,$id);
+ $comment = &HTML::Entities::encode($comment,'<>"&');
+ my %checked;
+ foreach my $which ('ungraded','fail','pass','review') {
+ if ($status eq $which) { $checked{$which} = 'checked="checked"'; }
+ }
+ if (!%checked) { $checked{'ungraded'} = 'checked="checked"'; }
+ my $buttons;
+ foreach my $which ('ungraded','fail','pass','review') {
+ $buttons .= <
+
+ $lt{$which}
+
+END_BUTTON
+ }
+ $criteria =~ s/^\s*//s;
+ $criteria =~ s/\s*$//s;
+ my $result = <
+
+ $criteria
+
+
+$buttons
+
+
+
+END_CRITERIA
+ $result .= &grading_history($version,$dim,$id);
+ return $result;
}
sub end_Criteria {
}
+sub start_GraderNote {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+
+ if ($target eq 'webgrade') {
+ return '