Diff for /loncom/interface/lonstatistics.pm between versions 1.148.2.6 and 1.156.2.8

version 1.148.2.6, 2010/11/09 15:01:53 version 1.156.2.8, 2020/11/11 22:27:41
Line 64  use Apache::lonpercentage; Line 64  use Apache::lonpercentage;
 use Apache::lonstudentsubmissions();  use Apache::lonstudentsubmissions();
 use Apache::lonsurveyreports();  use Apache::lonsurveyreports();
 use Apache::longradinganalysis();  use Apache::longradinganalysis();
   use Apache::lonquickgrades();
 use LONCAPA;  use LONCAPA;
   
 #  #
Line 365  sub section_or_group_text { Line 366  sub section_or_group_text {
   
 sub get_students {  sub get_students {
     if (! @Students) {      if (! @Students) {
         &PrepareClasslist()          &PrepareClasslist();
     }      }
     return @Students;      return @Students;
 }  }
Line 405  sub StudentDataSelect { Line 406  sub StudentDataSelect {
     $Str .= 'size="'.$numvisible.'" >'."\n";      $Str .= 'size="'.$numvisible.'" >'."\n";
     #      #
     # Deal with 'all'      # Deal with 'all'
     $Str .= '    <option value="all" ';      $Str .= '    <option value="all"';
     foreach (@SelectedStudentData) {      foreach (@SelectedStudentData) {
         if ($_ eq 'all') {          if ($_ eq 'all') {
             $Str .= 'selected ';              $Str .= ' selected="selected"';
             last;              last;
         }          }
     }      }
     $Str .= ">all</option>\n";      $Str .= '>'.&mt('all')."</option>\n";
     #      #
     # Loop through the student data fields      # Loop through the student data fields
     foreach my $item (@StudentDataOrder) {      foreach my $item (@StudentDataOrder) {
         $Str .= '    <option value="'.$item.'" ';          $Str .= '    <option value="'.$item.'"';
         foreach (@SelectedStudentData) {          foreach (@SelectedStudentData) {
             if ($item eq $_ ) {              if ($item eq $_ ) {
                 $Str .= 'selected ';                  $Str .= ' selected="selected"';
                 last;                  last;
             }              }
         }          }
         $Str .= '>'.$item."</option>\n";          $Str .= '>'.&mt($item)."</option>\n";
     }      }
     $Str .= "</select>\n";      $Str .= "</select>\n";
     return $Str;      return $Str;
Line 456  sub selected_sequences_with_assessments Line 457  sub selected_sequences_with_assessments
         return ('Can not open Coursemap');          return ('Can not open Coursemap');
     }      }
     #      #
     my $mapurl;      my @sequences = $navmap->retrieveResources(undef,
     if (&Apache::loncommon::needs_gci_custom()) {  
         my $cid = $env{'request.course.id'};  
         if ($cid) {  
             $mapurl = '/uploaded/'.$env{'course.'.$cid.'.domain'}.'/'.$env{'course.'.$cid.'.num'}.'/default_1261144274.sequence';  
         }  
     }  
     my @sequences = $navmap->retrieveResources($mapurl,  
                                                sub { shift->is_map(); },1,0,1);                                                 sub { shift->is_map(); },1,0,1);
     unless (&Apache::loncommon::needs_gci_custom()) {      my $toplevelseq = $navmap->getById('0.0');
         my $toplevelseq = $navmap->getById('0.0');      if (!grep(/^\Q$toplevelseq\E$/,@sequences)) {
         if (!grep(/^\Q$toplevelseq\E$/,@sequences)) {          unshift(@sequences,$toplevelseq);
             unshift(@sequences,$toplevelseq);  
         }  
     }      }
   
     my @sequences_with_assessments;      my @sequences_with_assessments;
Line 513  sub map_select { Line 505  sub map_select {
         $form .= 'multiple="multiple" ';          $form .= 'multiple="multiple" ';
     }      }
     $form .= 'size="'.$numvisible.'" >'."\n";      $form .= 'size="'.$numvisible.'" >'."\n";
     unless (&Apache::loncommon::needs_gci_custom()) {      #
         #      # Put in option for 'all'
         # Put in option for 'all'      $form .= '    <option value="all"';
         $form .= '    <option value="all" ';      if ($selected_maps[0] eq 'all') {
         if ($selected_maps[0] eq 'all') {          $form .= ' selected="selected"';
             $form .= 'selected ';  
         }  
         $form .= ">all</option>\n";  
     }      }
       $form .= '>'.&mt('all').'</option>'."\n";
     #      #
     # Loop through the sequences      # Loop through the sequences
     my @sequences = &selected_sequences_with_assessments('all');      my @sequences = &selected_sequences_with_assessments('all');
Line 532  sub map_select { Line 522  sub map_select {
         $navmap = shift(@sequences);          $navmap = shift(@sequences);
     }      }
     foreach my $seq (@sequences){      foreach my $seq (@sequences){
         $form .= '    <option value="'.$seq->symb.'" ';          $form .= '    <option value="'.$seq->symb.'"';
         if ((&Apache::loncommon::needs_gci_custom()) && (@selected_maps == 1)) {          foreach (@selected_maps) {
             $form .= 'selected ';              if ($seq->symb eq $_) {
         } else {                  $form .= ' selected="selected"';
             foreach (@selected_maps) {                  last;
                 if ($seq->symb eq $_) {  
                     $form .= 'selected ';  
                     last;  
                 }  
             }              }
         }          }
         $form .= '>'.$seq->compTitle."</option>\n";          $form .= '>'.$seq->compTitle."</option>\n";
Line 561  sub SectionSelect { Line 547  sub SectionSelect {
         &PrepareClasslist()          &PrepareClasslist()
     }      }
     #      #
       # Make sure course's student table is up to date
       if (@Sections) {
           &Apache::loncoursedata::ensure_current_sections();
       }
       #
     # Build the form element      # Build the form element
     my $Str = "\n";      my $Str = "\n";
     $Str .= '<select name="'.$elementname.'" ';      $Str .= '<select name="'.$elementname.'" ';
Line 571  sub SectionSelect { Line 562  sub SectionSelect {
     #      #
     # Loop through the sequences      # Loop through the sequences
     foreach my $s (@Sections) {      foreach my $s (@Sections) {
         $Str .= '    <option value="'.$s.'" ';          $Str .= '    <option value="'.$s.'"';
         foreach (&get_selected_sections()) {          foreach (&get_selected_sections()) {
             if ($s eq $_) {              if ($s eq $_) {
                 $Str .= 'selected ';                  $Str .= ' selected="selected"';
                 last;                  last;
             }              }
         }          }
Line 596  sub GroupSelect { Line 587  sub GroupSelect {
         &PrepareClasslist();          &PrepareClasslist();
     }      }
     #      #
       # Make sure course's groupnames and studentgroups tables
       # are up to date.
       #
       if (@Groups) {
           &Apache::loncoursedata::ensure_current_groups();
           &Apache::loncoursedata::ensure_current_students_groups();
       }
       #
     # Build the form element      # Build the form element
     my $Str = "\n";      my $Str = "\n";
     $Str .= '<select name="'.$elementname.'" ';      $Str .= '<select name="'.$elementname.'" ';
Line 606  sub GroupSelect { Line 605  sub GroupSelect {
     #      #
     # Loop through the groups      # Loop through the groups
     foreach my $s (@Groups) {      foreach my $s (@Groups) {
         $Str .= '    <option value="'.$s.'" ';          $Str .= '    <option value="'.$s.'"';
         foreach my $group (&get_selected_groups()) {          foreach my $group (&get_selected_groups()) {
             if ($s eq $group) {              if ($s eq $group) {
                 $Str .= 'selected ';                  $Str .= ' selected="selected"';
                 last;                  last;
             }              }
         }          }
Line 629  sub DisplayClasslist { Line 628  sub DisplayClasslist {
     # Output some of the standard interface components      # Output some of the standard interface components
     my $Str;      my $Str;
     $Str .= &Apache::lonhtmlcommon::breadcrumbs('Select One Student');      $Str .= &Apache::lonhtmlcommon::breadcrumbs('Select One Student');
     $Str .= '<p><table cellspacing="5">'."\n";      $Str .= '<table cellspacing="5">'."\n";
     $Str .= '<tr>';      $Str .= '<tr>';
     $Str .= '<th align="center"><b>'.&mt('Sections').'</b></th>';      $Str .= '<th align="center"><b>'.&mt('Sections').'</b></th>';
     $Str .= '<th align="center"><b>'.&mt('Groups').'</b></th>';      $Str .= '<th align="center"><b>'.&mt('Groups').'</b></th>';
Line 647  sub DisplayClasslist { Line 646  sub DisplayClasslist {
         '</td>';          '</td>';
           
     $Str .= '</tr>'.$/;      $Str .= '</tr>'.$/;
     $Str .= '</table></p>';      $Str .= '</table>';
     $Str .= '<input type="submit" name="selectstudent" value="'.      $Str .= '<input type="submit" name="selectstudent" value="'.
         &mt('Update Display').'" />';          &mt('Update Display').'" />';
     $r->print($Str);      $r->print($Str);
Line 705  sub DisplayClasslist { Line 704  sub DisplayClasslist {
     }      }
   
     $Str .= '<h2>'.&mt('Select One Student').'</h2>'      $Str .= '<h2>'.&mt('Select One Student').'</h2>'
            .'<p>'.&mt("Click on a student's name or username to view their chart").'</p>'             .'<p>'.&mt("Click on a student's name or username to view their chart.").'</p>'
            .&Apache::loncommon::start_data_table()             .&Apache::loncommon::start_data_table()
            .&Apache::loncommon::start_data_table_header_row();             .&Apache::loncommon::start_data_table_header_row();
     foreach my $field (@Fields) {      foreach my $field (@Fields) {
         $Str .= '<th><a href="/adm/statistics?'.          $Str .= '<th><a href="/adm/statistics?'.
             'reportSelected=student_assessment&'.              'reportSelected=student_assessment&amp;'.
             'selectstudent=1&'.              'selectstudent=1&amp;'.
             'sort='.$field.'">'.&mt($field).              'sort='.$field.'">'.&mt($field).
             '</a></th>';              '</a></th>';
     }      }
Line 726  sub DisplayClasslist { Line 725  sub DisplayClasslist {
             if ($field eq 'fullname' || $field eq 'username') {              if ($field eq 'fullname' || $field eq 'username') {
                 $Str .= '<a href="/adm/statistics?reportSelected=';                  $Str .= '<a href="/adm/statistics?reportSelected=';
                 $Str .= &escape('student_assessment');                  $Str .= &escape('student_assessment');
                 $Str .= '&sort='.&escape($env{'form.sort'});                  $Str .= '&amp;sort='.&escape($env{'form.sort'});
                 $Str .= '&SelectedStudent=';                  $Str .= '&amp;SelectedStudent=';
                 $Str .= &escape($sname).'">';                  $Str .= &escape($sname).'">';
                 $Str .= $student->{$field}.'&nbsp;';                  $Str .= $student->{$field};
                 $Str .= '</a>';                  $Str .= '</a>';
             } elsif ($field eq 'status') {              } elsif ($field eq 'status') {
                 $Str .= &mt($student->{$field});                  $Str .= &mt($student->{$field});
             } else {              } else {
                 $Str .= $student->{$field};                  if ($student->{$field} eq 'none') {
                       $Str .= &mt('none')
                   } else {
                       $Str .= $student->{$field};
                   }
             }              }
             $Str .= '</td>';              $Str .= '</td>';
         }          }
Line 764  sub CreateMainMenu { Line 767  sub CreateMainMenu {
                 
             {url => '/adm/statistics?reportSelected=problem_analysis',              {url => '/adm/statistics?reportSelected=problem_analysis',
  permission => 'F',   permission => 'F',
              icon => 'edit-find.png',               icon => 'prob_ana.png',
              linktext => ('Detailed Problem Analysis'),               linktext => ('Detailed Problem Analysis'),
              linktitle => ('Detailed statistics and graphs of student performance on problems.')},               linktitle => ('Detailed statistics and graphs of student performance on problems.')},
          ]},           ]},
Line 781  sub CreateMainMenu { Line 784  sub CreateMainMenu {
              icon => 'coprplot.png',               icon => 'coprplot.png',
              linktext => ('Correct Problems Plot'),               linktext => ('Correct Problems Plot'),
              linktitle => ('Display a histogram of student performance in the course.')},               linktitle => ('Display a histogram of student performance in the course.')},
          ]});           ]},
     if (&Apache::loncommon::needs_gci_custom()) {  
         push(@reports,  
         {categorytitle => 'Reports',  
          items => [  
             {url => '/adm/statistics?reportSelected=student_submission_reports',  
                          permission => 'F',  
              icon => 'edit-copy.png',  
              linktext => ('Student Submission Reports'),  
              linktitle => ('Prepare reports of student submissions.')},  
          ]});  
     } else {  
         push(@reports,  
         {categorytitle => 'Reports',          {categorytitle => 'Reports',
          items => [           items => [
             {url => '/adm/statistics?reportSelected=student_submission_reports',              {url => '/adm/statistics?reportSelected=student_submission_reports',
Line 804  sub CreateMainMenu { Line 795  sub CreateMainMenu {
                                           
             {url => '/adm/statistics?reportSelected=survey_reports',              {url => '/adm/statistics?reportSelected=survey_reports',
  permission => 'F',   permission => 'F',
              icon => 'docs.png',               icon => 'survey_rep.png',
  linktext => ('Survey Reports'),   linktext => ('Survey Reports'),
              linktitle => ('Prepare reports on survey results.')},               linktitle => ('Prepare reports on survey results.')},
          ]});           ]});
     }  
           
 return &Apache::lonhtmlcommon::generate_menu(@reports);  return &Apache::lonhtmlcommon::generate_menu(@reports);
     
Line 820  sub handler { Line 810  sub handler {
     my $r=shift;      my $r=shift;
     my $c = $r->connection();      my $c = $r->connection();
     #      #
     # Check for overloading  
     my $loaderror=&Apache::lonnet::overloaderror($r);  
     if ($loaderror) { return $loaderror; }  
     $loaderror=  
        &Apache::lonnet::overloaderror($r,  
          $env{'course.'.$env{'request.course.id'}.'.home'});  
     if ($loaderror) { return $loaderror; }  
     #  
     # Check for access      # Check for access
     if (! &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {      if (! &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
         $env{'user.error.msg'}=          $env{'user.error.msg'}=
Line 845  sub handler { Line 827  sub handler {
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
     if ($r->header_only) { return OK; }      if ($r->header_only) { return OK; }
     my $gcicustom = &Apache::loncommon::needs_gci_custom();  
     if ($gcicustom) {  
         my $now = time;  
         my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};  
         my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};  
         my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);  
         my $duedate = $courseopt->{$env{'request.course.id'}.'.0.duedate'};  
         if ((!$duedate) || ($duedate > $now)) {  
             my $brcrum = [{href=> '/adm/statistics',  
                            text=> 'Statistics',}];  
             my $args = {bread_crumbs           => $brcrum,  
                         bread_crumbs_component => 'Statistics Main Page'};  
             $r->print(&Apache::loncommon::start_page('Course Statistics',undef,$args));  
             $r->print('<h3>'.&mt('Display of statistics').'</h3>');  
             if ($duedate > $now) {   
                 $r->print('<p>'.&mt('Aggregate test performance data will be available after the Concept Test end date: [_1].',  
                          &Apache::lonlocal::locallocaltime($duedate)).'</p>');  
             } else {  
                 $r->print('<p>'.  
                           &mt('Aggregate test performance data unavailable without definition of an end date for the Concept Test.').'</p>');  
             }  
             $r->print(&Apache::loncommon::end_page());  
             return OK;  
         }  
     }  
   
     #      #
     # Extract form elements from query string      # Extract form elements from query string
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['sort','reportSelected',                                              ['sort','reportSelected',
                                              'SelectedStudent']);                                               'SelectedStudent']);
       my $GoToPage = $env{'form.reportSelected'};
   
     #      #
     # Give the LON-CAPA page header      # Give the LON-CAPA page header
     my $style = <<ENDSTYLE;      my $style = <<ENDSTYLE;
Line 886  sub handler { Line 844  sub handler {
     td.essay          { border: 1px solid gray; }      td.essay          { border: 1px solid gray; }
 </style>  </style>
 ENDSTYLE  ENDSTYLE
   
       my $head_extra = $style;
       if (($env{'form.reportSelected'} eq 'student_submission_reports') &&
           ($env{'form.renderprob'})) {
           my @Symbs = &Apache::lonstathelpers::get_selected_symbs('problemchoice');
           if (scalar(@Symbs) == 1) {
               $head_extra .= &Apache::loncommon::css_links($Symbs[0]);
           }
       } elsif ($env{'form.reportSelected'} eq 'submissiontime_analysis') {
           my ($navmap,$current_problem) =
               &Apache::lonsubmissiontimeanalysis::get_current_problem();
           if (ref($current_problem) eq 'HASH') {
               my $symb = $current_problem->{'symb'};
               if ($symb) {
                   $head_extra .= &Apache::loncommon::css_links($symb);
               }
           }
       } elsif (($env{'form.reportSelected'} eq 'problem_analysis') &&
                 ($env{'form.show_prob'})) {
           my $problem_types = &Apache::lonproblemanalysis::analyzable_types();
           my ($navmap,$current_problem) =
               &Apache::lonproblemanalysis::get_current_problem($problem_types);
           if (ref($current_problem) eq 'HASH') {
               my $symb = $current_problem->{'symb'};
               my $res = $current_problem->{'resource'};
               if ($symb) {
                   $head_extra .= &Apache::loncommon::css_links($symb);
               }
           }
       }
               
     $r->print(&Apache::loncommon::start_page('Course Statistics and Charts',      $r->print(&Apache::loncommon::start_page('Course Statistics and Charts',
      $style));       $head_extra));
     $r->rflush();      $r->rflush();
     #       # 
     # Either print out a menu for them or send them to a report      # Either print out a menu for them or send them to a report
Line 898  ENDSTYLE Line 886  ENDSTYLE
                                             text =>'Statistics',                                              text =>'Statistics',
                                             faq=>139,                                              faq=>139,
                                             bug=>'Statistics and Charts'});                                              bug=>'Statistics and Charts'});
     if (! exists($env{'form.reportSelected'}) ||       if ($GoToPage eq '') {
         $env{'form.reportSelected'} eq '') {  
         $r->print(&Apache::lonhtmlcommon::breadcrumbs('Statistics Main Page').          $r->print(&Apache::lonhtmlcommon::breadcrumbs('Statistics Main Page').
                   &CreateMainMenu());                    &CreateMainMenu());
     } else {      } else {
     #      #
         if (! &Apache::lonmysql::verify_sql_connection()) {          if (! &Apache::lonmysql::verify_sql_connection()) {
             my $serveradmin = $r->dir_config('lonAdmEMail');              my $serveradmin = $r->dir_config('lonAdmEMail');
             $r->print('<h2 class="LC_error">'.              $r->print('<p class="LC_error">'.
                       &mt('Unable to connect to database!').                        &mt('Unable to connect to database!').
                       '</h2>');                        '</p>');
             $r->print('<p>'              $r->print('<p>'
                      .&mt('Please notify the server administrator [_1]',                       .&mt('Please notify the server administrator [_1]',
                          ,'<b>'.$serveradmin.'</b>')                           ,'<b>'.$serveradmin.'</b>')
Line 924  ENDSTYLE Line 911  ENDSTYLE
         #          #
         # Clean out the caches          # Clean out the caches
         if (exists($env{'form.ClearCache'})) {          if (exists($env{'form.ClearCache'})) {
             &Apache::loncoursedata::delete_caches($env{'requres.course.id'});              &Apache::loncoursedata::delete_caches($env{'request.course.id'});
         }          }
         #          #
         # Begin form output          # Begin form output
         $r->print('<form name="Statistics" ');          $r->print('<form name="Statistics" ');
           if ($GoToPage eq 'student_submission_reports') {
               $r->print('onsubmit="return checkanon();" ');
           }
         $r->print('method="post" action="/adm/statistics">');          $r->print('method="post" action="/adm/statistics">');
         $r->rflush();          $r->rflush();
         #  
         my $GoToPage = $env{'form.reportSelected'};  
         #  
         $r->print('<input type="hidden" name="reportSelected" value="'.          $r->print('<input type="hidden" name="reportSelected" value="'.
                   $GoToPage.'">');                    $GoToPage.'" />');
         if($GoToPage eq 'activitylog') {          if($GoToPage eq 'activitylog') {
 #        &Apache::lonproblemstatistics::Activity();  #        &Apache::lonproblemstatistics::Activity();
         } elsif($GoToPage eq 'problem_statistics') {          } elsif($GoToPage eq 'problem_statistics') {
Line 956  ENDSTYLE Line 943  ENDSTYLE
             &Apache::lonsubmissiontimeanalysis::BuildSubmissionTimePage($r,$c);              &Apache::lonsubmissiontimeanalysis::BuildSubmissionTimePage($r,$c);
         } elsif($GoToPage eq 'student_submission_reports') {          } elsif($GoToPage eq 'student_submission_reports') {
             &Apache::lonhtmlcommon::add_breadcrumb              &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>                  ({href=>
               '/adm/statistics?reportselected=student_submission_reports',                    '/adm/statistics?reportselected=student_submission_reports',
               text=>'Student Submission Reports'});                    text=>'Student Submission Reports'});
             &Apache::lonstudentsubmissions::BuildStudentSubmissionsPage($r,$c);              &Apache::lonstudentsubmissions::BuildStudentSubmissionsPage($r,$c);
         } elsif($GoToPage eq 'survey_reports') {          } elsif($GoToPage eq 'survey_reports') {
             &Apache::lonhtmlcommon::add_breadcrumb              &Apache::lonhtmlcommon::add_breadcrumb
Line 976  ENDSTYLE Line 963  ENDSTYLE
             &Apache::lonhtmlcommon::add_breadcrumb              &Apache::lonhtmlcommon::add_breadcrumb
                 ({href=>'/adm/statistics?reportselected=student_assessment',                  ({href=>'/adm/statistics?reportselected=student_assessment',
                   text=>'Chart'});                    text=>'Chart'});
             if ($gcicustom) {              &Apache::lonstudentassessment::BuildStudentAssessmentPage($r,$c);
                 $r->print(&mt('Only aggregate performance data are available for Concept Tests.'));    
             } else {  
                 &Apache::lonstudentassessment::BuildStudentAssessmentPage($r,$c);  
             }  
         } elsif($GoToPage eq 'grading_analysis') {          } elsif($GoToPage eq 'grading_analysis') {
             &Apache::lonhtmlcommon::add_breadcrumb              &Apache::lonhtmlcommon::add_breadcrumb
                 ({href=>'/adm/statistics?reportselected=grading_anaylsis',                  ({href=>'/adm/statistics?reportselected=grading_anaylsis',

Removed from v.1.148.2.6  
changed lines
  Added in v.1.156.2.8


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