Diff for /loncom/homework/inputtags.pm between versions 1.98 and 1.104

version 1.98, 2003/05/06 15:31:45 version 1.104, 2003/06/07 03:57:28
Line 52  sub initialize_inputtags { Line 52  sub initialize_inputtags {
   @Apache::inputtags::previous_version=();    @Apache::inputtags::previous_version=();
   # id of current part, 0 means that no part is current (inside <problem> only    # id of current part, 0 means that no part is current (inside <problem> only
   $Apache::inputtags::part='';    $Apache::inputtags::part='';
     # list of all part ids seen
     @Apache::inputtags::partlist=();
   # list of problem date statuses, the first element is for <problem>    # list of problem date statuses, the first element is for <problem>
   # if there is a second element it is for the current <part>    # if there is a second element it is for the current <part>
   @Apache::inputtags::status=();    @Apache::inputtags::status=();
Line 59  sub initialize_inputtags { Line 61  sub initialize_inputtags {
   %Apache::inputtags::params=();    %Apache::inputtags::params=();
   # list of all ids, for <import>, these get join()ed and prepended    # list of all ids, for <import>, these get join()ed and prepended
   @Apache::inputtags::import=();    @Apache::inputtags::import=();
     # list of all import ids seen
     @Apache::inputtags::importlist=();
   }
   
   sub check_for_duplicate_ids {
       my %check;
       foreach my $id (@Apache::inputtags::partlist,
       @Apache::inputtags::responselist,
       @Apache::inputtags::importlist) {
    $check{$id}++;
       }
       my @duplicates;
       foreach my $id (sort(keys(%check))) {
    if ($check{$id} > 1) {
       push(@duplicates,$id);
    }
       }
       if (@duplicates) {
    &Apache::lonxml::error("Duplicated ids found, problem will operate incorrectly. Duplicated ids seen: ",join(', ',@duplicates));
       }
 }  }
   
 sub start_input {  sub start_input {
Line 160  sub start_textline { Line 182  sub start_textline {
   my $result = "";    my $result = "";
   if ($target eq 'web') {    if ($target eq 'web') {
     $Apache::lonxml::evaluate--;      $Apache::lonxml::evaluate--;
       my $partid=$Apache::inputtags::part;
       my $id=$Apache::inputtags::response[-1];
     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
       my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);        my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
       my $maxlength;        my $maxlength;
       if ($size eq '') { $size=20; } else {        if ($size eq '') { $size=20; } else {
  if ($size < 20) { $maxlength=$size; }   if ($size < 20) { $maxlength=$size; }
       }        }
       my $partid=$Apache::inputtags::part;  
       my $id=$Apache::inputtags::response[-1];  
       my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});        my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
       if ($Apache::lonhomework::type ne 'exam') {        if ($Apache::lonhomework::type ne 'exam') {
         $result= '<input type="text" name="HWVAL_'.$id.'" value="'.          $result= '<input type="text" name="HWVAL_'.$id.'" value="'.
Line 251  sub finalizeawards { Line 273  sub finalizeawards {
   if ($result eq '' ) {    if ($result eq '' ) {
     foreach $award (@_) { if ($award eq 'NO_RESPONSE') {$result='NO_RESPONSE'; last;} }      foreach $award (@_) { if ($award eq 'NO_RESPONSE') {$result='NO_RESPONSE'; last;} }
   }    }
     if ($result eq '' ) {
       foreach $award (@_) { if ($award eq 'TOO_LONG') {$result='TOO_LONG'; last;}}
     }
   if ($result eq '' ) {    if ($result eq '' ) {
     foreach $award (@_) {       foreach $award (@_) { 
       if ($award eq 'UNIT_FAIL' ||        if ($award eq 'UNIT_FAIL' ||
Line 312  sub decideoutput { Line 336  sub decideoutput {
   } else {    } else {
       $message = "<b>You are correct.</b>";        $message = "<b>You are correct.</b>";
   }    }
   $message=' Your receipt is '.&Apache::lonnet::receipt;    $message.=' Your receipt is '.&Apache::lonnet::receipt;
       }        }
       $button=0;        $button=0;
       $previousmsg='';        $previousmsg='';
Line 336  sub decideoutput { Line 360  sub decideoutput {
   } elsif ($award eq 'MISSING_ANSWER') {    } elsif ($award eq 'MISSING_ANSWER') {
       $message = 'Some parts were not submitted';        $message = 'Some parts were not submitted';
       $button = 1;        $button = 1;
     } elsif ($award eq 'ERROR') {
         $message = 'An error occured while trying to grade answer.';
         $button = 1;
     } elsif ($award eq 'TOO_LONG') {
         $message = "The submitted answer was too long.";
         $button=1;
   } elsif ($award eq 'WANTED_NUMERIC') {    } elsif ($award eq 'WANTED_NUMERIC') {
       $message = "This question expects a numeric answer";        $message = "This question expects a numeric answer";
       $button=1;        $button=1;
Line 404  sub setgradedata { Line 434  sub setgradedata {
     $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;      $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;
     return '';      return '';
   } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~    } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
        /^correct/ || $Apache::lonhomework::scantronmode) {         /^correct/ || $Apache::lonhomework::scantronmode ||
       lc($Apache::lonhomework::problemstatus) eq 'no') {
     #handle assignment of tries and solved status      #handle assignment of tries and solved status
     my $solvemsg;      my $solvemsg;
     if ($Apache::lonhomework::scantronmode) {      if ($Apache::lonhomework::scantronmode) {
Line 420  sub setgradedata { Line 451  sub setgradedata {
     $Apache::lonhomework::history{"resource.$id.tries"} + 1;      $Apache::lonhomework::history{"resource.$id.tries"} + 1;
  $Apache::lonhomework::results{"resource.$id.solved"} =   $Apache::lonhomework::results{"resource.$id.solved"} =
     $solvemsg;      $solvemsg;
  my $numawards=scalar(@Apache::inputtags::responselist);   my $numawards=scalar(@Apache::inputtags::response);
  &Apache::lonxml::debug("Whaaa!");  
  $Apache::lonhomework::results{"resource.$id.awarded"} = 0;   $Apache::lonhomework::results{"resource.$id.awarded"} = 0;
  foreach my $res (@Apache::inputtags::responselist) {   foreach my $res (@Apache::inputtags::response) {
     $Apache::lonhomework::results{"resource.$id.awarded"}+=      $Apache::lonhomework::results{"resource.$id.awarded"}+=
        $Apache::lonhomework::results{"resource.$id.$res.awarded"};         $Apache::lonhomework::results{"resource.$id.$res.awarded"};
  }   }
Line 456  sub setgradedata { Line 486  sub setgradedata {
     } else {      } else {
       $Apache::lonhomework::results{"resource.$id.solved"} =        $Apache::lonhomework::results{"resource.$id.solved"} =
  'incorrect_attempted';   'incorrect_attempted';
         if (lc($Apache::lonhomework::problemstatus) eq 'no') {
     $Apache::lonhomework::results{"resource.$id.tries"} =
         $Apache::lonhomework::history{"resource.$id.tries"} + 1;
         }
     }      }
   
     # check if this was a previous submission if it was delete the      # check if this was a previous submission if it was delete the
     # unneeded data and update the previously_used attribute      # unneeded data and update the previously_used attribute
     if ( $previously_used eq 'PREVIOUSLY_USED') {      if ( $previously_used eq 'PREVIOUSLY_USED') {
       delete($Apache::lonhomework::results{"resource.$id.tries"});   if (lc($Apache::lonhomework::problemstatus) ne 'no') {
       $Apache::lonhomework::results{"resource.$id.previous"} = '1';      delete($Apache::lonhomework::results{"resource.$id.tries"});
       $Apache::lonhomework::results{"resource.$id.previous"} = '1';
    }
     } elsif ( $previously_used eq 'PREVIOUSLY_LAST') {      } elsif ( $previously_used eq 'PREVIOUSLY_LAST') {
       #delete all data as they student didn't do anything, but save        #delete all data as they student didn't do anything, but save
       #the list of collaborators.        #the list of collaborators.
Line 488  sub grade { Line 524  sub grade {
   my $response='';    my $response='';
   if ( defined $ENV{'form.submitted'}) {    if ( defined $ENV{'form.submitted'}) {
     my @awards = ();      my @awards = ();
     foreach $response (@Apache::inputtags::responselist) {      foreach $response (@Apache::inputtags::response) {
       &Apache::lonxml::debug("looking for response.$id.$response.awarddetail");        &Apache::lonxml::debug("looking for response.$id.$response.awarddetail");
       my $value=$Apache::lonhomework::results{"resource.$id.$response.awarddetail"};        my $value=$Apache::lonhomework::results{"resource.$id.$response.awarddetail"};
       &Apache::lonxml::debug("keeping $value from $response for $id");        &Apache::lonxml::debug("keeping $value from $response for $id");

Removed from v.1.98  
changed lines
  Added in v.1.104


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