'."\n";
-
+ 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));
+ $result .= '
'."\n";
+ }
if ($target eq 'web' && $env{'request.state'} ne 'construct') {
- if ($Apache::lonhomework::modifygrades) {
+ if ($Apache::lonhomework::queuegrade
+ || $Apache::lonhomework::modifygrades) {
$result.='
";
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{$dim}{$instance.'.criterias'}},
+ @{$dimension{$dim}{'criterias'}}) {
+ my $type = $dimension{$dim}{'criteria.'.$id.'.type'};
+ if ($type eq 'dimension') {
+ $result.=$dimension{$id}{'result'};
+ next;
+ }
+ 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 {
@@ -1742,15 +2219,16 @@ 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.=
+ &nested_parse(\$dimension{$dim}{'criteria.'.$id},
+ [@_],{'set_dim_id' => $id});
$result.='
'.$status_display.'
';
- if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}) {
- $result.='';
+ if ($comment) {
+ $result.='';
}
$result.='
';
}
@@ -1758,19 +2236,31 @@ sub get_instance {
}
} 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"};
+ &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;
+ }
+
+ my $link=&link($id);
+ my $status= &get_criteria('status',$version,$dim,$id);
$result.='
'."\n";
- $result.=&grading_history($version,$dim,$instance,$id);
+ $result.=&grading_history($version,$dim,$id);
$last_link=$link;
}
+ 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;
- 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');
+
+ $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') {
@@ -1810,10 +2324,18 @@ sub get_instance {
$ungraded++;
}
}
- if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
+ # FIXME optional required can apply to only
right now...
+ 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{$instance.'.criterias'}})." results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
+ &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';
@@ -1831,17 +2353,55 @@ sub get_instance {
# any other targets no output
undef($result);
}
+ &disable_dimension_parsing();
+ pop(@Apache::bridgetask::dimension);
+ return $result;
+ }
+
+ 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.$dim.$id";
foreach my $t (1..$Apache::lonhomework::history{'version'}) {
if (exists($Apache::lonhomework::history{$t.':resource.0.regrader'})) {
my ($gname,$gdom) =
@@ -1870,11 +2430,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();
}
@@ -1891,15 +2453,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 '';
}
@@ -1909,10 +2472,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 '';
}
@@ -1923,14 +2487,25 @@ 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 $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);
+ &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 '';
}