Diff for /loncom/interface/loncoursedata.pm between versions 1.75 and 1.84

version 1.75, 2003/06/02 17:18:33 version 1.84, 2003/08/21 21:03:38
Line 104  sub get_sequence_assessment_data { Line 104  sub get_sequence_assessment_data {
     my $fn=$ENV{'request.course.fn'};      my $fn=$ENV{'request.course.fn'};
     ##      ##
     ## use navmaps      ## use navmaps
     my $navmap = Apache::lonnavmaps::navmap->new($fn.".db",      my $navmap = Apache::lonnavmaps::navmap->new();
                                                  $fn."_parms.db",1,0);  
     if (!defined($navmap)) {      if (!defined($navmap)) {
         return 'Can not open Coursemap';          return 'Can not open Coursemap';
     }      }
Line 121  sub get_sequence_assessment_data { Line 120  sub get_sequence_assessment_data {
     ## We are going to loop until we run out of sequences/pages to explore for      ## We are going to loop until we run out of sequences/pages to explore for
     ## resources.  This means we have to start out with something to look      ## resources.  This means we have to start out with something to look
     ## at.      ## at.
     my $title = $top_level_map->title();      my $title = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
     my $symb  = $top_level_map->symb();      my $symb  = $top_level_map->symb();
     my $src   = $top_level_map->src();      my $src   = $top_level_map->src();
     my $randompick = $top_level_map->randompick();      my $randompick = $top_level_map->randompick();
Line 143  sub get_sequence_assessment_data { Line 142  sub get_sequence_assessment_data {
     #      #
     # We need to keep track of which sequences contain homework problems      # We need to keep track of which sequences contain homework problems
     #       # 
       my $previous_too;
     my $previous;      my $previous;
     while (scalar(@Nested_Sequences)) {      while (scalar(@Nested_Sequences)) {
           $previous_too = $previous;
         $previous = $curRes;          $previous = $curRes;
         $curRes = $iterator->next();          $curRes = $iterator->next();
         my $currentmap = $Nested_Sequences[-1]; # Last one on the stack          my $currentmap = $Nested_Sequences[-1]; # Last one on the stack
         if ($curRes == $iterator->BEGIN_MAP()) {          if ($curRes == $iterator->BEGIN_MAP()) {
               if (! ref($previous)) {
                   $previous = $previous_too;
               }
               if (! ref($previous)) {
                   next;
               }
             # get the map itself, instead of BEGIN_MAP              # get the map itself, instead of BEGIN_MAP
             $title = $previous->title();              $title = $previous->title();
               $title =~ s/\:/\&\#058;/g;
             $symb  = $previous->symb();              $symb  = $previous->symb();
             $src   = $previous->src();              $src   = $previous->src();
               # pick up the filename if there is no title available
               if (! defined($title) || $title eq '') {
                   ($title) = ($src=~/\/([^\/]*)$/);
               }
             $randompick = $previous->randompick();              $randompick = $previous->randompick();
             my $newmap = { title    => $title,              my $newmap = { title    => $title,
                            src      => $src,                             src      => $src,
Line 175  sub get_sequence_assessment_data { Line 187  sub get_sequence_assessment_data {
         next if (! $curRes->is_problem());# && !$curRes->randomout);          next if (! $curRes->is_problem());# && !$curRes->randomout);
         # Okay, from here on out we only deal with assessments          # Okay, from here on out we only deal with assessments
         $title = $curRes->title();          $title = $curRes->title();
           $title =~ s/\:/\&\#058;/g;
         $symb  = $curRes->symb();          $symb  = $curRes->symb();
         $src   = $curRes->src();          $src   = $curRes->src();
         my $parts = $curRes->parts();          my $parts = $curRes->parts();
Line 908  sub update_student_data { Line 921  sub update_student_data {
                                  $sname.':'.$sdom.' in course '.$courseid.                                   $sname.':'.$sdom.' in course '.$courseid.
                                  ':'.$tmp[0]);                                   ':'.$tmp[0]);
         $returnstatus = 'error getting data';          $returnstatus = 'error getting data';
         return $returnstatus;          return ($returnstatus,undef);
     }      }
     if (scalar(@tmp) < 1) {      if (scalar(@tmp) < 1) {
         return ('no data',undef);          return ('no data',undef);
Line 932  sub update_student_data { Line 945  sub update_student_data {
     my $num_parameters = 0;      my $num_parameters = 0;
     my $store_performance_command = 'INSERT INTO '.$performance_table.      my $store_performance_command = 'INSERT INTO '.$performance_table.
         ' VALUES '."\n";          ' VALUES '."\n";
     return 'error' if (! defined($dbh));      return ('error',undef) if (! defined($dbh));
     while (my ($current_symb,$param_hash) = each(%student_data)) {      while (my ($current_symb,$param_hash) = each(%student_data)) {
         #          #
         # make sure the symb is set up properly          # make sure the symb is set up properly
Line 986  sub update_student_data { Line 999  sub update_student_data {
         &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());          &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());
         &Apache::lonnet::logthis('command = '.$store_parameters_command);          &Apache::lonnet::logthis('command = '.$store_parameters_command);
         $returnstatus = 'error: unable to insert parameters into database';          $returnstatus = 'error: unable to insert parameters into database';
         return $returnstatus,\%student_data;          return ($returnstatus,\%student_data);
     }      }
     $dbh->do($store_performance_command);      $dbh->do($store_performance_command);
     if ($dbh->err()) {      if ($dbh->err()) {
         &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());          &Apache::lonnet::logthis(' bigass insert error:'.$dbh->errstr());
         &Apache::lonnet::logthis('command = '.$store_performance_command);          &Apache::lonnet::logthis('command = '.$store_performance_command);
         $returnstatus = 'error: unable to insert performance into database';          $returnstatus = 'error: unable to insert performance into database';
         return $returnstatus,\%student_data;          return ($returnstatus,\%student_data);
     }      }
     $elapsed += Time::HiRes::time - $start;      $elapsed += Time::HiRes::time - $start;
     #      #
Line 1049  sub ensure_current_data { Line 1062  sub ensure_current_data {
         !$found_student     || !$found_part   ||          !$found_student     || !$found_part   ||
         !$found_performance || !$found_parameters) {          !$found_performance || !$found_parameters) {
         if (&init_dbs($courseid)) {          if (&init_dbs($courseid)) {
             return 'error';              return ('error',undef);
         }          }
     }      }
     #      #
Line 1205  sub get_current_state { Line 1218  sub get_current_state {
     return () if (! defined($sname) || ! defined($sdom));      return () if (! defined($sname) || ! defined($sdom));
     #      #
     my ($status,$data) = &ensure_current_data($sname,$sdom,$courseid);      my ($status,$data) = &ensure_current_data($sname,$sdom,$courseid);
     &Apache::lonnet::logthis  #    &Apache::lonnet::logthis
         ('sname = '.$sname.  #        ('sname = '.$sname.
          ' domain = '.$sdom.  #         ' domain = '.$sdom.
          ' status = '.$status.  #         ' status = '.$status.
          ' data is '.(defined($data)?'defined':'undefined'));  #         ' data is '.(defined($data)?'defined':'undefined'));
 #    while (my ($symb,$hash) = each(%$data)) {  #    while (my ($symb,$hash) = each(%$data)) {
 #        &Apache::lonnet::logthis($symb."\n----------------------------------");  #        &Apache::lonnet::logthis($symb."\n----------------------------------");
 #        while (my ($key,$value) = each (%$hash)) {  #        while (my ($key,$value) = each (%$hash)) {
Line 1217  sub get_current_state { Line 1230  sub get_current_state {
 #        }  #        }
 #    }  #    }
     #      #
     if (defined($data)) {      if (defined($data) && defined($symb) && ref($data->{$symb})) {
         if (defined($symb)) {          return %{$data->{$symb}};
             return %{$data->{$symb}};      } elsif (defined($data) && ! defined($symb) && ref($data)) {
         } else {          return %$data;
             return %$data;      } 
         }      if ($status eq 'no data') {
     } elsif ($status eq 'no data') {  
         return ();          return ();
     } else {      } else {
         if ($status ne 'okay' && $status ne '') {          if ($status ne 'okay' && $status ne '') {
Line 1364  sub get_problem_statistics { Line 1376  sub get_problem_statistics {
     }      }
     #      #
     $dbh->do('DROP TABLE '.$stats_table);  # May return an error      $dbh->do('DROP TABLE '.$stats_table);  # May return an error
       #
       # Store in metadata
       #
       if ($num) {
    my %storestats=();
   
           my $urlres=(split(/\_\_\_/,$symb))[2];
   
    $storestats{$courseid.'___'.$urlres.'___timestamp'}=time;       
    $storestats{$courseid.'___'.$urlres.'___stdno'}=$num;
    $storestats{$courseid.'___'.$urlres.'___avetries'}=$mean;   
    $storestats{$courseid.'___'.$urlres.'___difficulty'}=$DegOfDiff;
   
    $urlres=~/^(\w+)\/(\w+)/; 
    &Apache::lonnet::put('nohist_resevaldata',\%storestats,$1,$2); 
       }
       #
       # Return result
       #
     return { num_students => $num,      return { num_students => $num,
              tries        => $tries,               tries        => $tries,
              max_tries    => $mod,               max_tries    => $mod,
Line 1373  sub get_problem_statistics { Line 1404  sub get_problem_statistics {
              num_solved   => $Solved,               num_solved   => $Solved,
              num_override => $solved,               num_override => $solved,
              per_wrong    => $wrongpercent,               per_wrong    => $wrongpercent,
              deg_of_diff  => $DegOfDiff }               deg_of_diff  => $DegOfDiff };
 }  }
   
 sub execute_SQL_request {  sub execute_SQL_request {

Removed from v.1.75  
changed lines
  Added in v.1.84


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