Diff for /loncom/homework/structuretags.pm between versions 1.234 and 1.242

version 1.234, 2004/02/12 19:07:12 version 1.242, 2004/02/16 20:30:34
Line 158  sub setup_rndseed { Line 158  sub setup_rndseed {
     $rndseed=$Apache::lonhomework::history{'rndseed'};      $rndseed=$Apache::lonhomework::history{'rndseed'};
     if (!$rndseed) {      if (!$rndseed) {
  $rndseed=time;   $rndseed=time;
  $ENV{'form.rndseed'}=$rndseed;  
     }      }
       $ENV{'form.rndseed'}=$rndseed;
  }   }
  if ($ENV{'form.resetdata'} eq &mt('New Problem Variation') ||   if ($ENV{'form.resetdata'} eq &mt('New Problem Variation') ||
     $ENV{'form.newrandomization'} eq &mt('New Randomization')) {      $ENV{'form.newrandomization'} eq &mt('New Randomization')) {
Line 200  sub problem_edit_footer { Line 200  sub problem_edit_footer {
     <input type="submit" name="submit" value="'.&mt('Submit Changes and View').'" />';      <input type="submit" name="submit" value="'.&mt('Submit Changes and View').'" />';
 }  }
   
   sub option {
       my ($value,$name) = @_;
       my $result ="<option value='".$value."' ";
       if ($ENV{'form.'.$name} eq $value) {
    $result.=" selected='on' ";
       }
       $result.='>';
       return $result;
   }
   
 sub problem_web_to_edit_header {  sub problem_web_to_edit_header {
     my ($rndseed)=@_;      my ($rndseed)=@_;
     my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />      my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />
Line 216  sub problem_web_to_edit_header { Line 226  sub problem_web_to_edit_header {
     $result.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').      $result.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').
  &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').   &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
  '<hr />';   '<hr />';
       $result.="
   <nobr>
   Problem Status:
   <select name='problemstate'>
     <option name=''></option>
     ".&option('CLOSED'               ,'problemstate').&mt("Closed")."</option>
     ".&option('CAN_ANSWER'           ,'problemstate').&mt("Answerable")."</option>
     ".&option('CANNOT_ANSWER_tries'  ,'problemstate').&mt("Open with full tries")."</option>
     ".&option('CANNOT_ANSWER_correct','problemstate').&mt("Open and correct")."</option>
     ".&option('SHOW_ANSWER'          ,'problemstate').&mt("Show Answer")."</option>
   </select>
   </nobr>
   <nobr>
   Problem Type:
   <select name='problemtype'>
     <option name=''></option>
     ".&option('exam'   ,'problemtype').&mt("Exam Problem")."</option>
     ".&option('problem','problemtype').&mt("Homework problem")."</option>
     ".&option('survey' ,'problemtype').&mt("Survey Question")."</option>
   </select>
   </nobr>
   <nobr>
   Feedback Mode:
   <select name='problemstatus'>
     <option value=''></option>
     ".&option('yes','problemstatus').&mt("Show Feedback")."</option>
     ".&option('no', 'problemstatus').&mt("Don't Show Feedback")."</option>
   </select>
   </nobr>
   <input type='submit' name='changeproblemmode' value='".&mt("Change")."' />
   <hr />";
     my $numtoanalyze=$ENV{'form.numtoanalyze'};      my $numtoanalyze=$ENV{'form.numtoanalyze'};
     if (!$numtoanalyze) { $numtoanalyze=20; }      if (!$numtoanalyze) { $numtoanalyze=20; }
     $result.= '<input type="submit" name="problemmode" value='.      $result.= '<input type="submit" name="problemmode" value='.
Line 295  sub init_problem_globals { Line 336  sub init_problem_globals {
     if ($type eq 'problem') {      if ($type eq 'problem') {
  $Apache::inputtags::part='0';   $Apache::inputtags::part='0';
  @Apache::inputtags::partlist=('0');   @Apache::inputtags::partlist=('0');
  $Apache::lonhomework::problemstatus=  
     &Apache::lonnet::EXT('resource.0.problemstatus');   $Apache::lonhomework::problemstatus=&get_problem_status('0')
     } else {      } else {
  $Apache::inputtags::part='';   $Apache::inputtags::part='';
  @Apache::inputtags::partlist=();   @Apache::inputtags::partlist=();
Line 326  sub reset_problem_globals { Line 367  sub reset_problem_globals {
     undef($Apache::lonhomework::name);      undef($Apache::lonhomework::name);
 }  }
   
   sub set_problem_state {
       my ($part)=@_;
       if ($ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct') {
    $Apache::lonhomework::history{"resource.$part.solved"}=
       'correct_by_student';
       }
   }
   
   sub get_problem_status {
       my ($part)=@_;
       my $problem_status=&Apache::lonnet::EXT("resource.$part.problemstatus");
       &Apache::lonxml::debug("problem status for $part is $problem_status");
       &Apache::lonxml::debug("env probstat is ".$ENV{'form.problemstatus'});
       if ($ENV{'request.state'} eq 'construct' &&
    defined($ENV{'form.problemstatus'})) {
    $problem_status=$ENV{'form.problemstatus'};
       }
       return $problem_status;
   }
   
 sub start_problem {  sub start_problem {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   
Line 348  sub start_problem { Line 409  sub start_problem {
  if ($target eq 'web') {   if ($target eq 'web') {
     &Apache::lonhomework::showhash(%Apache::lonhomework::history);      &Apache::lonhomework::showhash(%Apache::lonhomework::history);
  }   }
           if ($ENV{'request.state'} eq 'construct') { &set_problem_state('0'); }
  $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');   $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
  &Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:");   if (($ENV{'request.state'} eq 'construct') &&
       defined($ENV{'form.problemtype'})) {
       $Apache::lonhomework::type=$ENV{'form.problemtype'};
    }
    &Apache::lonxml::debug("Found this to be of type :$Apache::ltonhomework::type:");
     }      }
     if ($Apache::lonhomework::type eq '' ) {      if ($Apache::lonhomework::type eq '' ) {
  my $uri=$ENV{'request.uri'};   my $uri=$ENV{'request.uri'};
Line 934  sub start_part { Line 1000  sub start_part {
     @Apache::inputtags::response=();      @Apache::inputtags::response=();
     @Apache::inputtags::previous=();      @Apache::inputtags::previous=();
     @Apache::inputtags::previous_version=();      @Apache::inputtags::previous_version=();
     $Apache::lonhomework::problemstatus=      $Apache::lonhomework::problemstatus=&get_problem_status($id);
  &Apache::lonnet::EXT("resource.$id.problemstatus");  
     my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);      my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
     my $expression='$external::part=\''.$Apache::inputtags::part.'\';';      my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
     &Apache::run::run($expression,$safeeval);      &Apache::run::run($expression,$safeeval);
Line 954  sub start_part { Line 1019  sub start_part {
     my $expression='$external::datestatus="'.$status.'";';      my $expression='$external::datestatus="'.$status.'";';
     $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";';      $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";';
     &Apache::run::run($expression,$safeeval);      &Apache::run::run($expression,$safeeval);
       if ($ENV{'request.state'} eq 'construct') {
    &set_problem_state($Apache::inputtags::part); 
       }
     if (( $status eq 'CLOSED' ) ||      if (( $status eq 'CLOSED' ) ||
  ( $status eq 'UNCHECKEDOUT') ||   ( $status eq 'UNCHECKEDOUT') ||
  ( $status eq 'BANNED') ||   ( $status eq 'BANNED') ||
Line 1039  sub end_part { Line 1107  sub end_part {
 sub start_preduedate {  sub start_preduedate {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
    &Apache::lonxml::debug("State in preduedate is ". $Apache::inputtags::status['-1']);
  if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&   if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
     $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER' &&      $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
     $Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {      &Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER'));
     &Apache::lonxml::get_all_text("/preduedate",$parser);      &Apache::lonxml::get_all_text("/preduedate",$parser);
  }   }
     }      }
Line 1074  sub start_notsolved { Line 1143  sub start_notsolved {
  $target eq 'tex') {   $target eq 'tex') {
  my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};   my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
  &Apache::lonxml::debug("not solved has :$gradestatus:");   &Apache::lonxml::debug("not solved has :$gradestatus:");
  if ($gradestatus =~ /^correct/) {   if ($gradestatus =~ /^correct/ &&
       &Apache::response::show_answer()) {
     &Apache::lonxml::debug("skipping");      &Apache::lonxml::debug("skipping");
     &Apache::lonxml::get_all_text("/notsolved",$parser);      &Apache::lonxml::get_all_text("/notsolved",$parser);
  }   }
Line 1091  sub start_solved { Line 1161  sub start_solved {
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  $target eq 'tex') {   $target eq 'tex') {
  my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};   my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
  if ($gradestatus !~ /^correct/) {   if ($gradestatus !~ /^correct/ ||
       !&Apache::response::show_answer()) {
     &Apache::lonxml::get_all_text("/solved",$parser);      &Apache::lonxml::get_all_text("/solved",$parser);
  }   }
     }      }

Removed from v.1.234  
changed lines
  Added in v.1.242


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