@@ -1526,7 +1687,7 @@ sub select_user {
$seclist
- | $fullname->{$student} ($studentdis) |
+ $classlist->{$student}[&Apache::loncoursedata::CL_FULLNAME()] ($student) |
RESULT
}
@@ -1620,6 +1781,7 @@ sub get_id {
}
my %dimension;
+sub start_Question { return &start_Dimension(@_); }
sub start_Dimension {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
undef(%dimension);
@@ -1662,9 +1824,11 @@ sub get_instance {
}
@instances = &Math::Random::random_permutation(@instances);
$instance = $instances[($version-1)%scalar(@instances)];
- $Apache::lonhomework::results{"resource.$version.0.$dim.instance"} =
- $instance;
- $Apache::lonhomework::results{'INTERNAL_store'} = 1;
+ if ($version =~ /^\d$/) {
+ $Apache::lonhomework::results{"resource.$version.0.$dim.instance"} =
+ $instance;
+ $Apache::lonhomework::results{'INTERNAL_store'} = 1;
+ }
&Apache::response::poprandomnumber();
return $instance;
}
@@ -1673,9 +1837,11 @@ sub get_instance {
{
my $last_link;
sub link {
- my ($instance,$id) = @_;
- return 'LC_GRADING_criteria_'.$instance.'_'.$id;
+ 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();
@@ -1711,11 +1877,12 @@ sub get_instance {
my $man_passed=0;
my $opt_count=0;
my $opt_passed=0;
- foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- if ($dimension{$instance.'.criteria.'.$id.'.mandatory'}
+ foreach my $id ( @{$dimension{$instance.'.criterias'}},
+ @{$dimension{'criterias'}} ) {
+ if ($dimension{'criteria.'.$id.'.mandatory'}
eq 'N') {
$opt_count++;
- if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') {
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim.$id.status"} eq 'pass') {
$opt_passed++;
}
} else {
@@ -1726,17 +1893,24 @@ sub get_instance {
}
}
if ($man_passed eq $man_count) { $man_passed='all'; }
+
my $opt_req=$dimension{$instance.'.optionalrequired'};
- if ($opt_req !~ /\S/) { $opt_req='0'; }
+ if ($opt_req !~ /\S/) {
+ $opt_req=
+ &Apache::lonxml::get_param('OptionalRequired',
+ $parstack,$safeeval);
+ 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');
+ foreach my $id (@{$dimension{$instance.'.criterias'}},
+ @{$dimension{'criterias'}}) {
+ my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$id.status"};
+ my $comment=$Apache::lonhomework::history{"resource.$version.0.$dim.$id.comment"};
+ my $mandatory=($dimension{'criteria.'.$id.'.mandatory'} ne 'N');
if ($mandatory) {
$mandatory='Mandatory';
} else {
@@ -1749,15 +1923,14 @@ sub get_instance {
}
my $status_display=$status;
$status_display=~s/^([a-z])/uc($1)/e;
- @Apache::scripttag::parser_env = @_;
$result.=
''
.$mandatory.' Criteria';
@Apache::scripttag::parser_env = @_;
- $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
+ $result.=&Apache::scripttag::xmlparse($dimension{'criteria.'.$id});
$result.=' '.$status_display.' ';
- if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}) {
- $result.='';
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim.$id.comment"}) {
+ $result.='';
}
$result.=' ';
}
@@ -1769,15 +1942,16 @@ sub get_instance {
&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"};
+ foreach my $id (@{$dimension{$instance.'.criterias'}},
+ @{$dimension{'criterias'}} ) {
+ my $link=&link($id);
+ my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$id.status"};
$result.=''."\n";
- $result.=&grading_history($version,$dim,$instance,$id);
+ $result.=&grading_history($version,$dim,$id);
$last_link=$link;
}
} elsif ($target eq 'grade' && $env{'form.webgrade'}) {
@@ -1800,11 +1974,17 @@ sub get_instance {
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');
+
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
+ foreach my $id (@{$dimension{$instance.'.criterias'}},
+ @{$dimension{'criterias'}}) {
+ my $link=&link($id);
+ @Apache::scripttag::parser_env = @_;
+ $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
+ my $status=$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};
+ my $mandatory=($dimension{'criteria.'.$id.'.mandatory'} ne 'N');
if ($status eq 'pass') {
if (!$mandatory) { $optional_passed++; }
} elsif ($status eq 'fail') {
@@ -1817,7 +1997,15 @@ sub get_instance {
$ungraded++;
}
}
- if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
+ # FIXME optional required can apply to only right now...
+ my $opt_req=$dimension{$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{$instance.'.criterias'}})." results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
@@ -1843,12 +2031,12 @@ sub get_instance {
}
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.$dim.$id";
foreach my $t (1..$Apache::lonhomework::history{'version'}) {
if (exists($Apache::lonhomework::history{$t.':resource.0.regrader'})) {
my ($gname,$gdom) =
@@ -1877,11 +2065,12 @@ 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') {
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ if ($tagstack->[-2] eq 'Dimension' || $tagstack->[-2] eq 'Question' ) {
+ $dimension{'intro'}=
+ &Apache::lonxml::get_all_text('/introparagraph',
+ $parser,$style);
+ } elsif ($tagstack->[-2] eq 'Task' && $target eq 'webgrade') {
&Apache::lonxml::startredirection();
}
@@ -1918,7 +2107,7 @@ sub start_InstanceText {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $instance_id=$Apache::bridgetask::instance[-1];
my $text=&Apache::lonxml::get_all_text('/instancetext',$parser,$style);
- if ($target eq 'web' || $target eq 'webgrade') {
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
$dimension{$instance_id.'.text'}=$text;
}
return '';
@@ -1930,14 +2119,21 @@ 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);
if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
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 (&Apache::londefdef::is_inside_of($tagstack,'Instance')) {
+ my $instance_id=$Apache::bridgetask::instance[-1];
+ $dimension{"criteria.$instance_id.$id"}=$criteria;
+ $dimension{"criteria.$instance_id.$id.mandatory"}=
+ &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
+ push(@{$dimension{$instance_id.'.criterias'}},"$instance_id.$id");
+ } else {
+ $dimension{'criteria.'.$id}=$criteria;
+ $dimension{'criteria.'.$id.'.mandatory'}=
+ &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
+ push(@{$dimension{'criterias'}},$id);
+ }
}
return '';
}
|