Diff for /loncom/homework/bridgetask.pm between versions 1.224 and 1.225

version 1.224, 2007/01/26 19:06:37 version 1.225, 2007/02/18 02:04:04
Line 43  use LONCAPA; Line 43  use LONCAPA;
     
   
 BEGIN {  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;  my %dimension;
Line 813  sub start_Task { Line 813  sub start_Task {
     &Apache::structuretags::problem_edit_header();      &Apache::structuretags::problem_edit_header();
  $Apache::lonxml::warnings_error_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 />";      &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.= &Apache::edit::text_arg('Required number of passed optional elements to pass the Task:','OptionalRequired',$token,10)." <br />\n";
  $result.=$temp;   $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 {      } else {
  # page_start returned a starting result, delete it if we don't need it   # page_start returned a starting result, delete it if we don't need it
  $result = '';   $result = '';
Line 2070  sub start_ClosingParagraph { Line 2077  sub start_ClosingParagraph {
     if ($target eq 'web') {      if ($target eq 'web') {
     } elsif ($target eq 'webgrade') {      } elsif ($target eq 'webgrade') {
  &Apache::lonxml::startredirection();   &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;      return $result;
 }  }
Line 2101  sub get_id { Line 2116  sub get_id {
   
 sub start_Setup {  sub start_Setup {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     #undef(%dimension);      my $result;
     my $dim = &get_id($parstack,$safeeval);      my $dim = &get_id($parstack,$safeeval);
     push(@Apache::bridgetask::dimension,$dim);      push(@Apache::bridgetask::dimension,$dim);
     &Apache::lonxml::startredirection();      if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
     return;# &internal_location($dim);   &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;
 }  }
   
 {  {
Line 2132  sub start_Dimension { Line 2160  sub start_Dimension {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $dim = &get_id($parstack,$safeeval);      my $dim = &get_id($parstack,$safeeval);
     my $previous_dim;      my $previous_dim;
     if (@Apache::bridgetask::dimension) {      my $result;
  $previous_dim = $Apache::bridgetask::dimension[-1];      if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
  push(@{$Apache::bridgetask::dimension{$previous_dim}{'contains'}},   if (@Apache::bridgetask::dimension) {
      $dim);      $previous_dim = $Apache::bridgetask::dimension[-1];
  if(&skip_dimension_parsing($dim)) {      push(@{$Apache::bridgetask::dimension{$previous_dim}{'contains'}},
     $dimension{$previous_dim}{'criteria.'.$dim} =   $dim);
  $token->[4]      if(&skip_dimension_parsing($dim)) {
  .&Apache::lonxml::get_all_text('/'.$tagstack->[-1],$parser,   $dimension{$previous_dim}{'criteria.'.$dim} =
       $style)      $token->[4]
  .'</'.$tagstack->[-1].'>';      .&Apache::lonxml::get_all_text('/'.$tagstack->[-1],$parser,
  }     $style)
  $dimension{$previous_dim}{'criteria.'.$dim.'.type'}='dimension';      .'</'.$tagstack->[-1].'>';
  $dimension{$previous_dim}{'criteria.'.$dim.'.mandatory'}=      }
     &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);      $dimension{$previous_dim}{'criteria.'.$dim.'.type'}='dimension';
  push(@{$dimension{$previous_dim}{'criterias'}},$dim);      $dimension{$previous_dim}{'criteria.'.$dim.'.mandatory'}=
  $dimension{$dim}{'nested'}=$previous_dim;   &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
  $dimension{$dim}{'depth'} = 1 + $dimension{$previous_dim}{'depth'};      push(@{$dimension{$previous_dim}{'criterias'}},$dim);
       $dimension{$dim}{'nested'}=$previous_dim;
  &Apache::lonxml::debug("adding $dim as criteria to $previous_dim");      $dimension{$dim}{'depth'} = 1 + $dimension{$previous_dim}{'depth'};
     } else {      
  $dimension{$top}{'depth'}=0;      &Apache::lonxml::debug("adding $dim as criteria to $previous_dim");
  $dimension{$top}{'criteria.'.$dim.'.type'}='dimension';   } else {
  $dimension{$top}{'criteria.'.$dim.'.mandatory'}=      $dimension{$top}{'depth'}=0;
     &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);      $dimension{$top}{'criteria.'.$dim.'.type'}='dimension';
  push(@{$dimension{$top}{'criterias'}},$dim);      $dimension{$top}{'criteria.'.$dim.'.mandatory'}=
  $dimension{$dim}{'nested'}=$top;   &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
     }      push(@{$dimension{$top}{'criterias'}},$dim);
     push(@Apache::bridgetask::dimension,$dim);      $dimension{$dim}{'nested'}=$top;
     &Apache::lonxml::startredirection();   }
     if (!&skip_dimension_parsing($dim)) {          push(@Apache::bridgetask::dimension,$dim);
  &enable_dimension_parsing($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 {  sub start_QuestionText {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $dim = &get_dim_id();      my $result;
     my $text=&Apache::lonxml::get_all_text('/questiontext',$parser,$style);  
     if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {      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;   $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 {  sub end_QuestionText {
Line 2242  sub link { Line 2300  sub link {
 sub end_Question { return &end_Dimension(@_); }  sub end_Question { return &end_Dimension(@_); }
 sub end_Dimension {  sub end_Dimension {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result=&Apache::lonxml::endredirection();      my $result;
     my $dim=&get_id($parstack,$safeeval);      my $dim=&get_id($parstack,$safeeval);
     if (&skip_dimension_parsing($dim)) {      if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
  pop(@Apache::bridgetask::dimension);   $result=&Apache::lonxml::endredirection();
  return;   if (&skip_dimension_parsing($dim)) {
       pop(@Apache::bridgetask::dimension);
       return;
    }
     }      }
     my $instance=&get_instance($dim);      my $instance=&get_instance($dim);
     my $version=&get_version();      my $version=&get_version();
Line 2445  sub end_Dimension { Line 2506  sub end_Dimension {
     $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=      $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
  'pass';   'pass';
  }   }
       } elsif ($target eq 'edit') {
       } elsif ($target eq 'modified') {
     } else {      } else {
  # any other targets no output   # any other targets no output
  undef($result);   undef($result);
     }      }
     &disable_dimension_parsing();      if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {
     pop(@Apache::bridgetask::dimension);   &disable_dimension_parsing();
    pop(@Apache::bridgetask::dimension);
       }
     return $result;      return $result;
 }  }
   
Line 2553  sub get_counts { Line 2618  sub get_counts {
   
 sub end_Setup {  sub end_Setup {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result=&Apache::lonxml::endredirection();      my $result;
     my $dim=&get_id($parstack,$safeeval);      my $dim=&get_id($parstack,$safeeval);
     my $instance=&get_instance($dim);      my $instance=&get_instance($dim);
     my $version=&get_version();      my $version=&get_version();
       if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
    $result=&Apache::lonxml::endredirection();
       }
     if ($target eq 'web') {      if ($target eq 'web') {
  @Apache::scripttag::parser_env = @_;   @Apache::scripttag::parser_env = @_;
  $result.=&Apache::scripttag::xmlparse($dimension{$dim}{'intro'});   $result.=&Apache::scripttag::xmlparse($dimension{$dim}{'intro'});
Line 2635  sub start_IntroParagraph { Line 2703  sub start_IntroParagraph {
     &Apache::lonxml::startredirection();      &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;      return $result;
 }  }
Line 2659  sub start_Instance { Line 2734  sub start_Instance {
     if (lc($disabled) eq 'yes') {      if (lc($disabled) eq 'yes') {
  $dimension{$dim}{$id.'.disabled'}='1';   $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 {  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 {  sub start_InstanceText {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $dim = &get_dim_id();      my $result;
     my $instance_id=$Apache::bridgetask::instance{$dim}[-1];  
     my $text=&Apache::lonxml::get_all_text('/instancetext',$parser,$style);  
     if ($target eq 'grade' || $target eq 'web' || $target eq 'webgrade') {      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;   $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 {  sub end_InstanceText {
Line 2682  sub end_InstanceText { Line 2793  sub end_InstanceText {
   
 sub start_Criteria {  sub start_Criteria {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser,$style);  
     my $result = '';      my $result = '';
     if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {      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 $dim = &get_dim_id();
  my $id=&get_id($parstack,$safeeval);   my $id=&get_id($parstack,$safeeval);
  if ($target eq 'web' || $target eq 'webgrade') {   if ($target eq 'web' || $target eq 'webgrade') {
Line 2711  sub start_Criteria { Line 2822  sub start_Criteria {
  &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);   &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
     push(@{$dimension{$dim}{'criterias'}},$id);      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;      return $result;
 }  }
Line 2797  END_CRITERIA Line 2952  END_CRITERIA
 }  }
   
 sub end_Criteria {  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 {  sub start_GraderNote {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
           my $result;
     if ($target eq 'webgrade') {      if ($target eq 'webgrade') {
  return '<div class="LC_GRADING_gradernote"><b>'.   $result = '<div class="LC_GRADING_gradernote"><b>'.
     &mt('Note to graders:').'</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 $result;
     return;  
 }  }
   
 sub end_GraderNote {  sub end_GraderNote {

Removed from v.1.224  
changed lines
  Added in v.1.225


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>