[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Sun, 18 Feb 2007 02:04:08 -0000
This is a MIME encoded message
--albertel1171764248
Content-Type: text/plain
albertel Sat Feb 17 21:04:08 2007 EDT
Modified files:
/loncom/homework bridgetask.pm
Log:
- make task's editable (Requied the creation of <CriteriaText>)
--albertel1171764248
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20070217210408.txt"
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.224 loncom/homework/bridgetask.pm:1.225
--- loncom/homework/bridgetask.pm:1.224 Fri Jan 26 14:06:37 2007
+++ loncom/homework/bridgetask.pm Sat Feb 17 21:04:04 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.224 2007/01/26 19:06:37 albertel Exp $
+# $Id: bridgetask.pm,v 1.225 2007/02/18 02:04:04 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,7 +43,7 @@
BEGIN {
- &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','GraderNote','ClosingParagraph'));
+ &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','CriteriaText','GraderNote','ClosingParagraph'));
}
my %dimension;
@@ -813,8 +813,15 @@
&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.")."<br />";
- 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)." <br />\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 = '';
@@ -2070,6 +2077,14 @@
if ($target eq 'web') {
} elsif ($target eq 'webgrade') {
&Apache::lonxml::startredirection();
+ } elsif ($target eq 'edit') {
+ my $bodytext=&Apache::lonxml::get_all_text("/closingparagraph",
+ $parser);
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.= &Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ } elsif ($target eq 'modified') {
+ $result = $token->[4].&Apache::edit::modifiedfield('/closingparagraph',
+ $parser);
}
return $result;
}
@@ -2101,11 +2116,24 @@
sub start_Setup {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- #undef(%dimension);
+ my $result;
my $dim = &get_id($parstack,$safeeval);
push(@Apache::bridgetask::dimension,$dim);
- &Apache::lonxml::startredirection();
- return;# &internal_location($dim);
+ if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
+ &Apache::lonxml::startredirection();
+ } elsif ($target eq 'edit') {
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.= &Apache::edit::text_arg('Id:','id',$token,10).
+ &Apache::edit::end_row().
+ &Apache::edit::start_spanning_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=
+ &Apache::edit::get_new_args($token,$parstack,$safeeval,'id');
+ if ($constructtag) {
+ $result = &Apache::edit::rebuild_tag($token);
+ }
+ }
+ return $result;
}
{
@@ -2132,49 +2160,79 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
my $dim = &get_id($parstack,$safeeval);
my $previous_dim;
- if (@Apache::bridgetask::dimension) {
- $previous_dim = $Apache::bridgetask::dimension[-1];
- push(@{$Apache::bridgetask::dimension{$previous_dim}{'contains'}},
- $dim);
- if(&skip_dimension_parsing($dim)) {
- $dimension{$previous_dim}{'criteria.'.$dim} =
- $token->[4]
- .&Apache::lonxml::get_all_text('/'.$tagstack->[-1],$parser,
- $style)
- .'</'.$tagstack->[-1].'>';
- }
- $dimension{$previous_dim}{'criteria.'.$dim.'.type'}='dimension';
- $dimension{$previous_dim}{'criteria.'.$dim.'.mandatory'}=
- &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
- push(@{$dimension{$previous_dim}{'criterias'}},$dim);
- $dimension{$dim}{'nested'}=$previous_dim;
- $dimension{$dim}{'depth'} = 1 + $dimension{$previous_dim}{'depth'};
-
- &Apache::lonxml::debug("adding $dim as criteria to $previous_dim");
- } else {
- $dimension{$top}{'depth'}=0;
- $dimension{$top}{'criteria.'.$dim.'.type'}='dimension';
- $dimension{$top}{'criteria.'.$dim.'.mandatory'}=
- &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
- push(@{$dimension{$top}{'criterias'}},$dim);
- $dimension{$dim}{'nested'}=$top;
- }
- push(@Apache::bridgetask::dimension,$dim);
- &Apache::lonxml::startredirection();
- if (!&skip_dimension_parsing($dim)) {
- &enable_dimension_parsing($dim);
+ my $result;
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ if (@Apache::bridgetask::dimension) {
+ $previous_dim = $Apache::bridgetask::dimension[-1];
+ push(@{$Apache::bridgetask::dimension{$previous_dim}{'contains'}},
+ $dim);
+ if(&skip_dimension_parsing($dim)) {
+ $dimension{$previous_dim}{'criteria.'.$dim} =
+ $token->[4]
+ .&Apache::lonxml::get_all_text('/'.$tagstack->[-1],$parser,
+ $style)
+ .'</'.$tagstack->[-1].'>';
+ }
+ $dimension{$previous_dim}{'criteria.'.$dim.'.type'}='dimension';
+ $dimension{$previous_dim}{'criteria.'.$dim.'.mandatory'}=
+ &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
+ push(@{$dimension{$previous_dim}{'criterias'}},$dim);
+ $dimension{$dim}{'nested'}=$previous_dim;
+ $dimension{$dim}{'depth'} = 1 + $dimension{$previous_dim}{'depth'};
+
+ &Apache::lonxml::debug("adding $dim as criteria to $previous_dim");
+ } else {
+ $dimension{$top}{'depth'}=0;
+ $dimension{$top}{'criteria.'.$dim.'.type'}='dimension';
+ $dimension{$top}{'criteria.'.$dim.'.mandatory'}=
+ &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
+ push(@{$dimension{$top}{'criterias'}},$dim);
+ $dimension{$dim}{'nested'}=$top;
+ }
+ push(@Apache::bridgetask::dimension,$dim);
+ &Apache::lonxml::startredirection();
+ if (!&skip_dimension_parsing($dim)) {
+ &enable_dimension_parsing($dim);
+ }
+ } elsif ($target eq 'edit') {
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.=
+ &Apache::edit::text_arg('Id:','id',$token,10).' '.
+ &Apache::edit::select_arg('Passing is Mandatory:','Mandatory',
+ [['yes', 'Yes'],
+ ['no','No'],],
+ $token).' <br /> '.
+ &Apache::edit::text_arg('Required number of passed optional elements to pass the '.$token->[1].':',
+ 'OptionalRequired',$token,4).
+ &Apache::edit::end_row().
+ &Apache::edit::start_spanning_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=
+ &Apache::edit::get_new_args($token,$parstack,$safeeval,
+ 'id','Mandatory','OptionalRequired');
+ if ($constructtag) {
+ $result = &Apache::edit::rebuild_tag($token);
+ }
}
- return;# &internal_location($dim);
+ return $result;# &internal_location($dim);
}
sub start_QuestionText {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- my $dim = &get_dim_id();
- my $text=&Apache::lonxml::get_all_text('/questiontext',$parser,$style);
+ my $result;
if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ my $text=&Apache::lonxml::get_all_text('/questiontext',$parser,$style);
+ my $dim = &get_dim_id();
$dimension{$dim}{'questiontext'}=$text;
+ } elsif ($target eq 'edit') {
+ my $bodytext=&Apache::lonxml::get_all_text("/questiontext",$parser);
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.= &Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ } elsif ($target eq 'modified') {
+ $result = $token->[4].&Apache::edit::modifiedfield('/questiontext',
+ $parser);
}
- return '';
+ return $result;
}
sub end_QuestionText {
@@ -2242,11 +2300,14 @@
sub end_Question { return &end_Dimension(@_); }
sub end_Dimension {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- my $result=&Apache::lonxml::endredirection();
+ my $result;
my $dim=&get_id($parstack,$safeeval);
- if (&skip_dimension_parsing($dim)) {
- pop(@Apache::bridgetask::dimension);
- return;
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ $result=&Apache::lonxml::endredirection();
+ if (&skip_dimension_parsing($dim)) {
+ pop(@Apache::bridgetask::dimension);
+ return;
+ }
}
my $instance=&get_instance($dim);
my $version=&get_version();
@@ -2445,12 +2506,16 @@
$Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
'pass';
}
+ } elsif ($target eq 'edit') {
+ } elsif ($target eq 'modified') {
} else {
# any other targets no output
undef($result);
}
- &disable_dimension_parsing();
- pop(@Apache::bridgetask::dimension);
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ &disable_dimension_parsing();
+ pop(@Apache::bridgetask::dimension);
+ }
return $result;
}
@@ -2553,10 +2618,13 @@
sub end_Setup {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
- my $result=&Apache::lonxml::endredirection();
+ my $result;
my $dim=&get_id($parstack,$safeeval);
my $instance=&get_instance($dim);
my $version=&get_version();
+ if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
+ $result=&Apache::lonxml::endredirection();
+ }
if ($target eq 'web') {
@Apache::scripttag::parser_env = @_;
$result.=&Apache::scripttag::xmlparse($dimension{$dim}{'intro'});
@@ -2635,6 +2703,13 @@
&Apache::lonxml::startredirection();
}
+ } elsif ($target eq 'edit') {
+ my $bodytext=&Apache::lonxml::get_all_text("/introparagraph",$parser);
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.= &Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ } elsif ($target eq 'modified') {
+ $result = $token->[4].&Apache::edit::modifiedfield('/introparagraph',
+ $parser);
}
return $result;
}
@@ -2659,21 +2734,57 @@
if (lc($disabled) eq 'yes') {
$dimension{$dim}{$id.'.disabled'}='1';
}
- return '';
+ my $result;
+ if ($target eq 'edit') {
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.=
+ &Apache::edit::text_arg('Id:','id',$token,10).' '.
+ &Apache::edit::select_arg('Instance is Disabled:','Disabled',
+ [['no', 'No'],
+ ['yes','Yes'],],
+ $token)
+ .' <br /> '.
+ &Apache::edit::text_arg('Required number of passed optional elements to pass the Instance:',
+ 'OptionalRequired',$token,4)
+ .&Apache::edit::end_row().
+ &Apache::edit::start_spanning_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=
+ &Apache::edit::get_new_args($token,$parstack,$safeeval,
+ 'id','OptionalRequired','Disabled');
+ if ($constructtag) {
+ $result = &Apache::edit::rebuild_tag($token);
+ }
+ }
+ return $result;
}
sub end_Instance {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my $result;
+ if ($target eq 'edit') {
+ $result = &Apache::edit::tag_end($target,$token);
+ }
+ return $result;
}
sub start_InstanceText {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- my $dim = &get_dim_id();
- my $instance_id=$Apache::bridgetask::instance{$dim}[-1];
- my $text=&Apache::lonxml::get_all_text('/instancetext',$parser,$style);
+ my $result;
if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+ my $text=&Apache::lonxml::get_all_text('/instancetext',$parser,$style);
+ my $dim = &get_dim_id();
+ my $instance_id=$Apache::bridgetask::instance{$dim}[-1];
$dimension{$dim}{$instance_id.'.text'}=$text;
+ } elsif ($target eq 'edit') {
+ my $bodytext=&Apache::lonxml::get_all_text("/instancetext",$parser);
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.= &Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ } elsif ($target eq 'modified') {
+ $result = $token->[4].&Apache::edit::modifiedfield('/instancetext',
+ $parser);
}
- return '';
+ return $result;
}
sub end_InstanceText {
@@ -2682,9 +2793,9 @@
sub start_Criteria {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
- my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser,$style);
my $result = '';
if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
+ my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser,$style);
my $dim = &get_dim_id();
my $id=&get_id($parstack,$safeeval);
if ($target eq 'web' || $target eq 'webgrade') {
@@ -2711,6 +2822,50 @@
&Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
push(@{$dimension{$dim}{'criterias'}},$id);
}
+ } elsif ($target eq 'edit') {
+ if (0) {
+ $result = &Apache::edit::tag_start($target,$token);
+ my $text=&Apache::lonxml::get_all_text("/criteria",$parser);
+ &Apache::lonnet::logthis("get_all_text criteria \n$text");
+ my $local_parser = HTML::LCParser->new(\$text);
+ $local_parser->xml_mode(1);
+ $local_parser->marked_sections(1);
+ while (1) {
+ my $criteria_text =
+ &Apache::lonxml::get_all_text('gradernote',$local_parser);
+ $result.=
+ &Apache::edit::editfield($token->[1],$criteria_text,'',80,4);
+
+ # check for a <GraderNote> next might be end
+ my $token = $local_parser->get_token();
+ # is the end
+ last if (!$token);
+ my $gradernote = &Apache::lonxml::get_all_text('/gradernote',
+ $local_parser);
+ # purge the end tag
+ my $token = $local_parser->get_token();
+ $gradernote = '<GraderNote>'.$gradernote.'</GraderNote>';
+ @Apache::scripttag::parser_env = @_;
+ $result .=
+ &Apache::edit::end_row().&Apache::edit::start_spanning_row().
+ &Apache::scripttag::xmlparse($gradernote).
+ &Apache::edit::end_row().&Apache::edit::start_spanning_row();
+ }
+ }
+ $result .=&Apache::edit::tag_start($target,$token);
+ $result.=
+ &Apache::edit::text_arg('Id:','id',$token,10).' '.
+ &Apache::edit::select_arg('Passing is Mandatory:','Mandatory',
+ [['yes', 'Yes'],
+ ['no','No'],],
+ $token)
+ .' <br /> '.&Apache::edit::end_row().
+ &Apache::edit::start_spanning_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=
+ &Apache::edit::get_new_args($token,$parstack,$safeeval,
+ 'id','Mandatory');
+ if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
}
return $result;
}
@@ -2797,17 +2952,49 @@
}
sub end_Criteria {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ if ($target eq 'edit') {
+ } elsif ($target eq 'modified') {
+ }
+}
+
+sub start_CriteriaText {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result;
+ if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
+
+ } elsif ($target eq 'edit') {
+ my $bodytext=&Apache::lonxml::get_all_text("/criteriatext",$parser);
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.= &Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ } elsif ($target eq 'modified') {
+ $result = $token->[4].&Apache::edit::modifiedfield('/criteriatext',
+ $parser);
+ }
+ return $result;
+}
+
+sub end_CriteriaText {
+ return '';
}
sub start_GraderNote {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-
+ my $result;
if ($target eq 'webgrade') {
- return '<div class="LC_GRADING_gradernote"><b>'.
+ $result = '<div class="LC_GRADING_gradernote"><b>'.
&mt('Note to graders:').'</b>';
+ } elsif ($target eq 'edit') {
+ my $bodytext=&Apache::lonxml::get_all_text("/gradernote",$parser);
+ $result = &Apache::edit::tag_start($target,$token);
+ $result.= &Apache::edit::editfield($token->[1],$bodytext,'',80,4);
+ } elsif ($target eq 'modified') {
+ $result = $token->[4].&Apache::edit::modifiedfield('/gradernote',
+ $parser);
+ } elsif ($target eq 'web' || $target eq 'grade') {
+ my $note=&Apache::lonxml::get_all_text('/gradernote',$parser,$style);
}
- my $note=&Apache::lonxml::get_all_text('/gradernote',$parser,$style);
- return;
+ return $result;
}
sub end_GraderNote {
--albertel1171764248--