- popwin=open('','popwin','width=400,height=100');
- popwin.document.writeln(''+
- 'LON-CAPA Statistics'+
- 'Computation Progress
'+
- ''+
- '');
- popwin.document.close();
-
-ENDPOP
- $r->rflush();
-}
-# update progress
-sub Update_PrgWin {
- my ($totalStudents,$index,$name,$r)=@_;
- $r->print('');
+sub DisplayClasslist {
+ my ($r)=@_;
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({text=>'Select One Student'});
+ #
+ # Output some of the standard interface components
+ my $Str;
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs('Select One Student');
+ $Str .= ''."\n";
+ $Str .= '';
+ $Str .= ''.&mt('Sections').' | ';
+ $Str .= ''.&mt('Groups').' | ';
+ $Str .= ''.&mt('Access Status').' | ';
+ $Str .= '
'.$/;
+ $Str .= '';
+ $Str .= ''.
+ &Apache::lonstatistics::SectionSelect('Section','multiple',5).
+ ' | ';
+ $Str .= ''.
+ &Apache::lonstatistics::GroupSelect('Group','multiple',5).
+ ' | ';
+ $Str .= ''.
+ &Apache::lonhtmlcommon::StatusOptions(undef,undef,5).
+ ' | ';
+
+ $Str .= '
'.$/;
+ $Str .= '
';
+ $Str .= '';
+ $r->print($Str);
+ $r->rflush();
+ #
+ my @Fields = ('fullname','username','domain','id','section','status','groups');
+ #
+ $Str = '';
+ my @selected_sections = &get_selected_sections();
+ if (! @Students) {
+ if ($selected_sections[0] eq 'all') {
+ if (lc($env{'form.Status'}) eq 'active') {
+ $Str .= ''.
+ &mt('There are no currently enrolled students in the course.').
+ '
';
+ } elsif (lc($env{'form.Status'}) eq 'expired') {
+ $Str .= ''.
+ &mt('There are no previously enrolled students in the course.').
+ '
';
+ } elsif (lc($env{'form.Status'}) eq 'future') {
+ $Str .= ''.
+ &mt('There are no students with future access in the course.').
+ '
';
+ } else { # 'any' and any others
+ $Str .= ''.
+ &mt('There are no students in the course.').
+ '
';
+ }
+ } else {
+ if (lc($env{'form.Status'}) eq 'active') {
+ $Str .= ''.
+ &mt('There are no currently enrolled students in the selected sections.').
+ '
';
+ } elsif (lc($env{'form.Status'}) eq 'expired') {
+ $Str .= ''.
+ &mt('There are no previously enrolled students in the selected sections.').
+ '
';
+ } elsif (lc($env{'form.Status'}) eq 'future') {
+ $Str .= ''.
+ &mt('There are no students with future access in the selected sections.').
+ '
';
+ } else { # 'any' and any others
+ $Str .= ''.
+ &mt('There are no students in the selected sections.').
+ '
';
+ }
+ }
+ $Str.= ''
+ .''
+ .&mt('Return to the chart').''
+ .'
';
+ $r->print($Str);
+ $r->rflush();
+ return;
+ }
+
+ $Str .= ''.&mt('Select One Student').'
'
+ .''.&mt("Click on a student's name or username to view their chart.").'
'
+ .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row();
+ foreach my $field (@Fields) {
+ $Str .= ''.&mt($field).
+ ' | ';
+ }
+ $Str .= &Apache::loncommon::end_data_table_header_row();
+ #
+ foreach my $student (@Students) { # @Students is a package variable
+ my $sname = $student->{'username'}.':'.$student->{'domain'};
+ $Str .= &Apache::loncommon::start_data_table_row();
+ #
+ foreach my $field (@Fields) {
+ $Str .= '';
+ if ($field eq 'fullname' || $field eq 'username') {
+ $Str .= '';
+ $Str .= $student->{$field};
+ $Str .= '';
+ } elsif ($field eq 'status') {
+ $Str .= &mt($student->{$field});
+ } else {
+ if ($student->{$field} eq 'none') {
+ $Str .= &mt('none')
+ } else {
+ $Str .= $student->{$field};
+ }
+ }
+ $Str .= ' | ';
+ }
+ $Str .= &Apache::loncommon::end_data_table_row();
+ }
+ $Str .= &Apache::loncommon::end_data_table();
+ #
+ $r->print($Str);
$r->rflush();
+ #
+ return;
}
-# close Progress Line
-sub Close_PrgWin {
- my ($r)=@_;
- $r->print('');
- $r->rflush();
+
+
+sub CreateMainMenu {
+ #
+ # Define menu data
+ my @reports = (
+ {categorytitle => 'Statistics and Analyses',
+ items => [
+ {url => '/adm/statistics?reportSelected=problem_statistics',
+ permission => 'F',
+ icon => 'document-open.png',
+ linktext => ('Overall Problem Statistics'),
+ linktitle => ('Student performance statistics on all problems.')},
+
+ {url => '/adm/statistics?reportSelected=problem_analysis',
+ permission => 'F',
+ icon => 'prob_ana.png',
+ linktext => ('Detailed Problem Analysis'),
+ linktitle => ('Detailed statistics and graphs of student performance on problems.')},
+ ]},
+ {categorytitle => 'Plots',
+ items => [
+ {url => '/adm/statistics?reportSelected=submissiontime_analysis',
+ permission => 'F',
+ icon => 'subtimpl.png',
+ linktext => ('Submission Time Plots'),
+ linktitle => ('Display and analysis of submission times on assessments.')},
+
+ {url => '/adm/statistics?reportSelected=correct_problems_plot',
+ permission => 'F',
+ icon => 'coprplot.png',
+ linktext => ('Correct Problems Plot'),
+ linktitle => ('Display a histogram of student performance in the course.')},
+ ]},
+ {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.')},
+
+ {url => '/adm/statistics?reportSelected=survey_reports',
+ permission => 'F',
+ icon => 'survey_rep.png',
+ linktext => ('Survey Reports'),
+ linktitle => ('Prepare reports on survey results.')},
+ ]});
+
+return &Apache::lonhtmlcommon::generate_menu(@reports);
+
}
-# For loading the colored table for display or un-colored for print
-sub setbgcolor {
- my $PrintTable=shift;
- my %color;
- if ($PrintTable){
- $color{"gb"}="#FFFFFF";
- $color{"red"}="#FFFFFF";
- $color{"yellow"}="#FFFFFF";
- $color{"green"}="#FFFFFF";
- $color{"purple"}="#FFFFFF";
- } else {
- $color{"gb"}="#DDFFFF";
- $color{"red"}="#FFDDDD";
- $color{"yellow"}="#EEFFCC";
- $color{"green"}="#DDFFDD";
- $color{"purple"}="#FFDDFF";
- }
-
- return \%color;
-}
-
-sub BuildClasslist {
- my ($cacheDB,$students,$studentInformation,$headings,$spacePadding)=@_;
-
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- return 'Unable to tie database.';
- }
-
- my $Str='';
- $Str .= ''."\n";
- $Str .= ''."\n";
-
- my $displayString = 'DISPLAYDATA  | '."\n";
- $Str .= &Apache::lonhtmlcommon::CreateStudentInformationHeadings(\%cache,
- $studentInformation,
- $headings,
- $displayString);
- $Str .= '';
- $Str .= '';
- $Str .= 'Last Updated  | '."\n";
- $Str .= ' '."\n";
- my $alternate=0;
- foreach (@$students) {
- my ($username, $domain) = split(':', $_);
- if($alternate) {
- $Str .= '';
- } else {
- $Str .= ' | ';
+
+
+sub handler {
+ my $r=shift;
+ my $c = $r->connection();
+ #
+ # Check for access
+ if (! &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
+ $env{'user.error.msg'}=
+ $r->uri.":vgr:0:0:Cannot view grades for complete course";
+ if (! &Apache::lonnet::allowed('vgr',
+ $env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ $env{'user.error.msg'}=
+ $r->uri.":vgr:0:0:Cannot view grades with given role";
+ return HTTP_NOT_ACCEPTABLE;
}
- $alternate = ($alternate + 1) % 2;
- foreach my $data (@$studentInformation) {
- if($data eq 'fullname') {
- $Str .= '';
- #$Str .= 'Student Assessment'.'">';
+ }
+ #
+ # Send the header
+ &Apache::loncommon::no_cache($r);
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ if ($r->header_only) { return OK; }
+ #
+ # Extract form elements from query string
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sort','reportSelected',
+ 'SelectedStudent']);
+ my $GoToPage = $env{'form.reportSelected'};
+
+ #
+ # Give the LON-CAPA page header
+ my $style = <
+ ul.sub_studentans { list-style-type: none }
+ ul.sub_correctans { list-style-type: none }
+ tr.even { background-color: \#CCCCCC }
+ td.essay { border: 1px solid gray; }
+
+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',
+ $head_extra));
+ $r->rflush();
+ #
+ # Either print out a menu for them or send them to a report
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/statistics',
+ title=>'Statistics',
+ text =>'Statistics',
+ faq=>139,
+ bug=>'Statistics and Charts'});
+ if ($GoToPage eq '') {
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Statistics Main Page').
+ &CreateMainMenu());
+ } else {
+ #
+ if (! &Apache::lonmysql::verify_sql_connection()) {
+ my $serveradmin = $r->dir_config('lonAdmEMail');
+ $r->print(' '.
+ &mt('Unable to connect to database!').
+ ' ');
+ $r->print(''
+ .&mt('Please notify the server administrator [_1]',
+ ,''.$serveradmin.'')
+ .' ');
+ $r->print(''.
+ &mt('Course Statistics and Charts cannot be '.
+ 'retrieved until the database is restarted. '.
+ 'Your data is intact but cannot be displayed '.
+ 'at this time.').' ');
+ $r->print(&Apache::loncommon::end_page());
+ return;
+ }
+ #
+ # Clean out the caches
+ if (exists($env{'form.ClearCache'})) {
+ &Apache::loncoursedata::delete_caches($env{'request.course.id'});
+ }
+ #
+ # Begin form output
+ $r->print('\n");
+ }
+ $r->print(&Apache::loncommon::end_page());
+ $r->rflush();
+ #
+ return OK;
+}
- $Str .= $cache{$_.':'.$data}.' ';
+1;
- if($data eq 'fullname') {
- $Str .= '';
- }
+__END__
- $Str .= ' | ';
- }
+=pod
- $Str .= '';
- my $downloadTime = $cache{$_.':lastDownloadTime'};
- if($downloadTime ne 'Not downloaded') {
- $downloadTime = localtime($downloadTime);
- }
- $Str .= $downloadTime;
+=head1 NAME
- $Str .= '  | '."\n";
- }
+lonstatistics
- $Str .= '
|
'."\n";
+=head1 SYNOPSIS
- untie(%cache);
+Main handler for statistics and chart.
- return $Str;
-}
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
-sub BuildStatistics {
- my ($r)=@_;
- my $c = $r->connection;
- my @studentInformation=('fullname','section','id','domain','username');
- my @headings=('Full Name', 'Section', 'PID', 'Domain', 'User Name');
- my $spacePadding = ' ';
- my %reports = ('classlist' => 'Class list',
- 'problem_statistics' => 'Problem Statistics',
- 'student_assessment' => 'Student Assessment',
- 'reportSelected' => 'Class list');
-
- my %cache;
- my $courseID=$ENV{'request.course.id'};
- my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
- "_$ENV{'user.domain'}_$courseID\_statistics.db";
-
- my %color=&setbgcolor(0);
- my ($returnValue, $students) = &PrepareData($c, $cacheDB);
- if($returnValue ne 'OK') {
- $r->print(''.$returnValue."\n".'');
- return OK;
- }
-
- my $GoToPage;
- if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- $GoToPage = $cache{'reportSelected'};
- $reports{'reportSelected'} = $cache{'reportSelected'};
-# if(defined($cache{'reportKey'}) && $cache{'reportKey'} ne 'false') {
-# $reports{$cache{'reportKey'}} = $cache{'reportSelected'};
-# }
+=head1 PACKAGE VARIABLES
- if(defined($cache{'OptionResponses'})) {
- $reports{'problem_analysis'} = 'Problem Analysis';
- }
+=over
- $r->print(&Apache::lonhtmlcommon::Title('LON-CAPA Statistics'));
- $r->print(''."\n");
- $r->print("\n".'