Total Number of Students opened the problem.';
- $Ptr .= '
';
- $Ptr .= 'Tries:
';
- $Ptr .= '
Total Number of Tries for solving the problem.';
- $Ptr .= '
';
- $Ptr .= 'Mod:
';
- $Ptr .= '
Maximunm Number of Tries for solving the problem.';
- $Ptr .= '
';
- $Ptr .= 'Mean:
';
- $Ptr .= '
Average Number of the tries. [ Tries / #Stdnts ]';
- $Ptr .= '
';
- $Ptr .= '#YES:
';
- $Ptr .= '
Number of students solved the problem correctly.';
- $Ptr .= '
';
- $Ptr .= '#yes:
';
- $Ptr .= '
Number of students solved the problem by override.';
- $Ptr .= '
';
- $Ptr .= '%Wrng:
';
- $Ptr .= '
Percentage of students tried to solve the problem ';
- $Ptr .= 'but still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]';
- $Ptr .= '
';
-# Kashy formula
-# ' DoDiff : Degree of Difficulty of the problem. '.
-# '[ Tries/(#YES+#yes+0.1) ] '.
- #Gerd formula
- $Ptr .= 'DoDiff:
';
- $Ptr .= '
Degree of Difficulty of the problem. ';
- $Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]';
- $Ptr .= '
';
- $Ptr .= 'S.D.:
';
- $Ptr .= '
Standard Deviation of the tries. ';
- $Ptr .= '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) ';
- $Ptr .= 'where Xi denotes every student\'s tries ]';
- $Ptr .= '
';
- $Ptr .= 'Skew.:
';
- $Ptr .= '
Skewness of the students tries.';
- $Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]';
- $Ptr .= '
';
- $Ptr .= 'Dis.F.:
';
- $Ptr .= '
Discrimination Factor: A Standard for evaluating the ';
- $Ptr .= 'problem according to a Criterion ';
- $Ptr .= '[Applied Criterion in %27 Upper Students - ';
- $Ptr .= 'Applied the same Criterion in %27 Lower Students] ';
- $Ptr .= '1st Criterion for Sorting the Students: ';
- $Ptr .= 'Sum of Partial Credit Awarded / Total Number of Tries ';
- $Ptr .= '2nd Criterion for Sorting the Students: ';
- $Ptr .= 'Total number of Correct Answers / Total Number of Tries';
- $Ptr .= '
';
- $Ptr .= '
Disc.
';
- $Ptr .= '
Number of Students had at least one discussion.';
- $Ptr .= '
';
-
- return $Ptr;
-}
-
-#---- END Problem Statistics Web Page ----------------------------------------
-
-#---- Problem Statistics Graph Web Page --------------------------------------
-
-# ------------------------------------------- Prepare data for Graphical chart
-
-sub GetGraphData {
- my $ylab = shift;
- my $Col;
- my $data='';
- my $count = 0;
- my $Max = 0;
- my $cid=$ENV{'request.course.id'};
- my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
- "_$ENV{'user.domain'}_$cid\_graph.db";
- foreach (keys %GraphDat) {delete $GraphDat{$_};}
- if (-e "$GraphDB") {
- if (tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) {
- if ( $ylab eq 'DoDiff Graph' ) {
- $ylab = 'Degree-of-Difficulty';
- $Col = 0;
- }
- else {
- $ylab = 'Wrong-Percentage';
- $Col = 1;
- }
- foreach (sort NumericSort keys %GraphDat) {
- my @Temp=split(/\:/,$GraphDat{$_});
- my $inf = $Temp[$Col];
- if ( $Max < $inf ) {$Max = $inf;}
- $data .= $inf.',';
- $count++;
- }
- if ( $Max > 1 ) {
- $Max += (10 - $Max % 10);
- $Max = int($Max);
- }
- else { $Max = 1; }
- untie(%GraphDat);
- my $Course = $ENV{'course.'.$cid.'.description'};
- $Course =~ s/\ /"_"/eg;
- $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.$Max.'&'.$count.'&'.$data;
- }
- else {
- $r->print("Unable to tie hash to db file");
- }
- }
-}
-#---- Problem Analysis Web Page ----------------------------------------------
-
-sub IntervalOptions {
- my ($cache)=@_;
-
- my $interval = 1;
- for(my $n=1; $n<=7; $n++) {
- if($cache->{'Interval'} == $n) {
- $interval = $n;
- }
- }
-
- my $Ptr = ' Select number of intervals'."\n".
- ''."\n";
+#######################################################
+#######################################################
- return $Ptr;
-}
+=pod
-sub OptionResponseTable {
- my ($cache)=@_;
- my $Str = '';
- $Str .= ' Option Response Problems in this course:'."\n";
- $Str .= '
'."\n";
- $Str .= "
\#
Problem Title
";
- $Str .= '
Resource
Analysis
'."\n";
-
- my $number=1;
- foreach (split(':::',$cache->{'OptionResponses'})) {
- my ($uri,$title,$part,$problem)=split('::',$_);
- my $Temp = ''.$title.'';
- $Str .= '
';
- $Str .= '
'.$number.'
';
- $Str .= '
'.$Temp.'
';
- $Str .= '
'.$uri.'
';
- $Str .= '
'."\n";
- $number++;
- }
- $Str .= '
'."\n";
+=item &clear_sequence_variables()
- return $Str;
+=cut
+
+#######################################################
+#######################################################
+sub clear_sequence_variables {
+ undef($top_map);
+ undef(@Sequences);
+ undef(@Assessments);
}
-#---- END Problem Analysis Web Page ------------------------------------------
+#######################################################
+#######################################################
-#---- Student Assessment Web Page --------------------------------------------
+=pod
-# ------ Create different Student Report
-sub StudentReport {
- my ($cache, $name)=@_;
+=item &SetSelectedMaps($elementname)
- my $Str = '';
- if($cache->{$name.':error'} =~ /course/) {
- my ($username)=split(':',$name);
- $Str .= 'No course data for student ';
- $Str .= ''.$username.'. ';
- return $Str;
- }
+Sets the @SelectedMaps array from $ENV{'form.'.$elementname};
- $Str .= "
\#
Set Title
";
- $Str .= '
Results
Tries
'."\n";
-
- my $codes;
- my $attempts;
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- if($cache->{'StudentAssessmentMap'} ne 'All Maps' &&
- $cache->{'StudentAssessmentMap'} ne $cache->{$sequence.':title'}) {
- next;
+=cut
+
+#######################################################
+#######################################################
+sub SetSelectedMaps {
+ my $elementname = shift;
+ if (exists($ENV{'form.'.$elementname})) {
+ if (ref($ENV{'form.'.$elementname})) {
+ @SelectedMaps = @{$ENV{'form.'.$elementname}};
+ } else {
+ @SelectedMaps = ($ENV{'form.'.$elementname});
}
+ } else {
+ @SelectedMaps = ('all');
+ }
+}
- $Str .= '
'.$sequence.'
';
- $Str .= '
'.$cache->{$sequence.':title'}.'
';
- $codes = '';
- $attempts = '';
- foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
- my $problem = $cache->{$problemID.':problem'};
- my $LatestVersion = $cache->{$name.':version:'.$problem};
-
- # Output dashes for all the parts of this problem if there
- # is no version information about the current problem.
- if(!$LatestVersion) {
- foreach my $part (split(/\:/,$cache->{$sequence.':'.
- $problemID.
- ':parts'})) {
- $codes .= "-,";
- $attempts .= "0,";
- }
- next;
- }
+#######################################################
+#######################################################
- my %partData=undef;
- # Initialize part data, display skips correctly
- # Skip refers to when a student made no submissions on that
- # part/problem.
- foreach my $part (split(/\:/,$cache->{$sequence.':'.
- $problemID.
- ':parts'})) {
- $partData{$part.':tries'}=0;
- $partData{$part.':code'}='-';
- }
+=pod
- # Looping through all the versions of each part, starting with the
- # oldest version. Basically, it gets the most recent
- # set of grade data for each part.
- for(my $Version=1; $Version<=$LatestVersion; $Version++) {
- foreach my $part (split(/\:/,$cache->{$sequence.':'.
- $problemID.
- ':parts'})) {
-
- if(!defined($cache->{$name.":$Version:$problem".
- ":resource.$part.solved"})) {
- # No grade for this submission, so skip
- next;
- }
+=item &Sequences_with_Assess()
- my $tries=0;
- my $code='U';
+Returns an array containing the subset of @Sequences which contain
+assessments.
- $tries = $cache->{$name.":$Version:$problem".
- ":resource.$part.tries"};
- $partData{$part.':tries'}=($tries) ? $tries : 0;
-
- my $val = $cache->{$name.":$Version:$problem".
- ":resource.$part.solved"};
- if ($val eq 'correct_by_student') {$code = 'Y';}
- elsif ($val eq 'correct_by_override') {$code = 'y';}
- elsif ($val eq 'incorrect_attempted') {$code = 'N';}
- elsif ($val eq 'incorrect_by_override'){$code = 'N';}
- elsif ($val eq 'excused') {$code = 'x';}
- $partData{$part.':code'}=$code;
- }
- }
+=cut
- # Loop through all the parts for the current problem in the
- # correct order and prepare the output
- foreach (split(/\:/,$cache->{$sequence.':'.$problemID.
- ':parts'})) {
- $codes .= $partData{$_.':code'}.',';
- $attempts .= $partData{$_.':tries'}.',';
+#######################################################
+#######################################################
+sub Sequences_with_Assess {
+ my ($mode) = @_;
+ $mode = 'selected' if (! defined($mode));
+ my @Sequences_to_Show;
+ foreach my $sequence (@Sequences) {
+ next if ($sequence->{'num_assess'} < 1);
+ if ($mode eq 'all') {
+ push (@Sequences_to_Show,$sequence);
+ } elsif ($mode eq 'selected') {
+ foreach my $map_symb (@SelectedMaps) {
+ if ($sequence->{'symb'} eq $map_symb || $map_symb eq 'all'){
+ push (@Sequences_to_Show,$sequence);
+ last; # Only put it in once
+ }
}
}
- $codes =~ s/,$//;
- $attempts =~ s/,$//;
- $Str .= '
'.$codes.'
';
- $Str .= '
'.$attempts.'
';
- $Str .= '
'."\n";
- }
-
- $Str .= '
'."\n";
- return $Str;
+ }
+ return @Sequences_to_Show;
}
-#---- END Student Assessment Web Page ----------------------------------------
-
-#---- Menu Web Page ----------------------------------------------------------
+#######################################################
+#######################################################
-#---- END Menu Web Page ------------------------------------------------------
+=pod
-#---- HELPER FUNCTIONS -------------------------------------------------------
+=item &PrepareCourseData($r)
-sub CheckFormElement {
- my ($cache, $ENVName, $cacheName, $default)=@_;
+=cut
- if(defined($ENV{'form.'.$ENVName})) {
- $cache->{$cacheName} = $ENV{'form.'.$ENVName};
- } elsif(!defined($cache->{$cacheName})) {
- $cache->{$cacheName} = $default;
+#######################################################
+#######################################################
+sub PrepareCourseData {
+ my ($r) = @_;
+ &clear_sequence_variables();
+ my ($top,$sequences,$assessments) =
+ &Apache::loncoursedata::get_sequence_assessment_data();
+ if (! defined($top) || ! ref($top)) {
+ # There has been an error, better report it
+ &Apache::lonnet::logthis('top is undefined');
+ return;
}
-
+ $top_map = $top if (ref($top));
+ @Sequences = @{$sequences} if (ref($sequences) eq 'ARRAY');
+ @Assessments = @{$assessments} if (ref($assessments) eq 'ARRAY');
return;
}
-sub ProcessFormData{
- my ($cache)=@_;
+#######################################################
+#######################################################
- $cache->{'reportKey'} = 'false';
+=pod
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['sort','download']);
- &CheckFormElement($cache, 'Status', 'Status', 'Active');
- &CheckFormElement($cache, 'postdata', 'reportSelected', 'Class list');
- &CheckFormElement($cache, 'reportSelected', 'reportSelected',
- 'Class list');
- &CheckFormElement($cache, 'DownloadAll', 'DownloadAll', 'false');
- &CheckFormElement($cache, 'sort', 'sort', 'fullname');
- &CheckFormElement($cache, 'download', 'download', 'false');
-
- if(defined($ENV{'form.CreateStudentAssessment'}) ||
- defined($ENV{'form.NextStudent'}) ||
- defined($ENV{'form.PreviousStudent'})) {
- $cache->{'reportSelected'} = 'Student Assessment';
- }
- if(defined($ENV{'form.NextStudent'})) {
- $cache->{'StudentAssessmentMove'} = 'next';
- } elsif(defined($ENV{'form.PreviousStudent'})) {
- $cache->{'StudentAssessmentMove'} = 'previous';
- } else {
- $cache->{'StudentAssessmentMove'} = 'selected';
+=item &log_sequence($sequence,$recursive,$padding)
+
+Write data about the sequence to a logfile. If $recursive is not
+undef the data is written recursively. $padding is used for recursive
+calls.
+
+=cut
+
+#######################################################
+#######################################################
+sub log_sequence {
+ my ($seq,$recursive,$padding) = @_;
+ $padding = '' if (! defined($padding));
+ if (ref($seq) ne 'HASH') {
+ &Apache::lonnet::logthis('log_sequence passed bad sequnce');
+ return;
}
- &CheckFormElement($cache, 'StudentAssessmentMap', 'StudentAssessmentMap',
- 'All Maps');
- &CheckFormElement($cache, 'StudentAssessmentStudent',
- 'StudentAssessmentStudent', 'No Student Selected');
-
- foreach (keys(%ENV)) {
- if(/form\.Analyze:::/) {
-# $cache->{'reportSelected'} = 'Analyze';
-# $cache->{'reportKey'} = 'Problem Analysis';
- my ($uri, $title, $part, $problem);
- (undef, $uri, $title, $part, $problem)=split(':::', $_);
- $cache->{'AnalyzeURI'} = $uri;
- $cache->{'AnalyzeTitle'} = $title;
- $cache->{'AnalyzePart'} = $part;
- $cache->{'AnalyzeProblem'} = $problem;
-
- &CheckFormElement($cache, 'Interval', 'Interval', '1');
+ &Apache::lonnet::logthis($padding.'sequence '.$seq->{'title'});
+ while (my($key,$value) = each(%$seq)) {
+ next if ($key eq 'contents');
+ if (ref($value) eq 'ARRAY') {
+ for (my $i=0;$i< scalar(@$value);$i++) {
+ &Apache::lonnet::logthis($padding.$key.'['.$i.']='.
+ $value->[$i]);
+ }
+ } else {
+ &Apache::lonnet::logthis($padding.$key.'='.$value);
}
}
-
- return;
-
- # Select page to display
- if(defined($ENV{'form.ProblemStatistics'}) ||
- defined($ENV{'form.ProblemStatisticsRecalculate'}) ||
- defined($ENV{'form.DisplayCSVFormat'})) {
- $cache->{'GoToPage'} = 'ProblemStatistics';
- &CheckFormElement($cache, 'DisplayCSVFormat',
- 'DisplayFormat', 'Display Table Format');
- &CheckFormElement($cache, 'Ascend','ProblemStatisticsAscend',
- 'Ascending');
- &CheckFormElement($cache, 'Maps', 'ProblemStatisticsMap',
- 'All Maps');
- } elsif(defined($ENV{'form.ProblemAnalysis'})) {
- $cache->{'GoToPage'} = 'ProblemAnalysis';
- &CheckFormElement($cache, 'Interval', 'Interval', '1');
- } elsif(defined($ENV{'form.DoDiffGraph'})) {
- $cache->{'GoToPage'} = 'DoDiffGraph';
- } elsif(defined($ENV{'form.PercentWrongGraph'})) {
- $cache->{'GoToPage'} = 'PercentWrongGraph';
- } elsif(defined($ENV{'form.ActivityLog'})) {
- $cache->{'GoToPage'} = 'ActivityLog';
- } else {
- $cache->{'GoToPage'} = 'Menu';
+ if (defined($recursive)) {
+ &Apache::lonnet::logthis($padding.'-'x20);
+ &Apache::lonnet::logthis($padding.'contains:');
+ foreach my $item (@{$seq->{'contents'}}) {
+ if ($item->{'type'} eq 'container') {
+ &log_sequence($item,$recursive,$padding.' ');
+ } else {
+ &Apache::lonnet::logthis($padding.'title = '.$item->{'title'});
+ while (my($key,$value) = each(%$item)) {
+ next if ($key eq 'title');
+ if (ref($value) eq 'ARRAY') {
+ for (my $i=0;$i< scalar(@$value);$i++) {
+ &Apache::lonnet::logthis($padding.$key.'['.$i.']='.
+ $value->[$i]);
+ }
+ } else {
+ &Apache::lonnet::logthis($padding.$key.'='.$value);
+ }
+ }
+ }
+ }
+ &Apache::lonnet::logthis($padding.'end contents of '.$seq->{'title'});
+ &Apache::lonnet::logthis($padding.'-'x20);
}
-
- &CheckFormElement($cache, 'Status', 'Status', 'Active');
-
return;
}
-=pod
+##############################################
+##############################################
-=item &SortStudents()
+=pod
-Determines which students to display and in which order. Which are
-displayed are determined by their status(active/expired). The order
-is determined by the sort button pressed (default to username). The
-type of sorting is username, lastname, or section.
+=item &StudentDataSelect($elementname,$status,$numvisible,$selected)
-=over 4
+Returns html for a selection box allowing the user to choose one (or more)
+of the fields of student data available (fullname, username, id, section, etc)
-Input: $students, $CacheData
-
-$students: A array pointer to a list of students (username:domain)
+=over 4
-$CacheData: A pointer to the hash tied to the cached data
+=item $elementname The name of the HTML form element
-Output: \@order
+=item $status 'multiple' or 'single' selection box
-@order: An ordered list of students (username:domain)
+=item $numvisible The number of options to be visible
=back
=cut
-sub SortStudents {
- my ($cache)=@_;
-
- my @students = split(':::',$cache->{'NamesOfStudents'});
- my @sorted1Students=();
- foreach (@students) {
- if($cache->{'Status'} eq 'Any' ||
- $cache->{$_.':Status'} eq $cache->{'Status'}) {
- push(@sorted1Students, $_);
+##############################################
+##############################################
+sub StudentDataSelect {
+ my ($elementname,$status,$numvisible)=@_;
+ if ($numvisible < 1) {
+ return;
+ }
+ #
+ # Build the form element
+ my $Str = "\n";
+ $Str .= '\n";
+ return $Str;
}
-sub PrepareData {
- my ($c, $cacheDB)=@_;
+##############################################
+##############################################
- # Test for access to the cache data
- my $courseID=$ENV{'request.course.id'};
- my $isRecalculate=0;
- if(defined($ENV{'form.Recalculate'})) {
- $isRecalculate=1;
- }
+=pod
- my $isCached = &Apache::loncoursedata::TestCacheData($cacheDB,
- $isRecalculate);
- if($isCached < 0) {
- return "Unable to tie hash to db file.";
- }
+=item &MapSelect($elementname,$status,$numvisible,$restriction)
- # Download class list information if not using cached data
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
- return "Unable to tie hash to db file.";
- }
+Returns html for a selection box allowing the user to choose one (or more)
+of the sequences in the course. The values of the sequences are the symbs.
+If the top sequence is selected, the value 'top' will result.
- if(!$isCached) {
- my $processTopResourceMapReturn=
- &Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c);
- if($processTopResourceMapReturn ne 'OK') {
- untie(%cache);
- return $processTopResourceMapReturn;
- }
- }
+=over 4
- if($c->aborted()) {
- untie(%cache);
- return 'aborted';
- }
+=item $elementname The name of the HTML form element
- my $classlist=&Apache::loncoursedata::DownloadClasslist($courseID,
- $cache{'ClasslistTimestamp'},
- $c);
- foreach (keys(%$classlist)) {
- if(/^(con_lost|error|no_such_host)/i) {
- untie(%cache);
- return "Error getting student data.";
- }
- }
+=item $status 'multiple' or 'single' selection box
- if($c->aborted()) {
- untie(%cache);
- return 'aborted';
- }
+=item $numvisible The number of options to be visible
- # Active is a temporary solution, remember to change
- Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c);
- if($c->aborted()) {
- untie(%cache);
- return 'aborted';
- }
+=item $restriction Code reference to subroutine which returns true or
+false. The code must expect a reference to a sequence data structure.
- &ProcessFormData(\%cache);
- my $students = &SortStudents(\%cache);
+=back
- if($cache{'download'} ne 'false') {
- my $who = $cache{'download'};
- my $courseData =
- &Apache::loncoursedata::DownloadStudentCourseInformation(
- $who, $courseID,
- $cache{$who.':lastDownloadTime'});
- &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, $who);
- $cache{'download'} = 'false';
- } elsif($cache{'DownloadAll'} ne 'false') {
- my @allStudents;
- if($cache{'DownloadAll'} eq 'sorted') {
- @allStudents = @$students;
- } else {
- @allStudents = split(':::', $cache{'NamesOfStudents'});
+=cut
+
+##############################################
+##############################################
+sub MapSelect {
+ my ($elementname,$status,$numvisible,$restriction)=@_;
+ if ($numvisible < 1) {
+ return;
+ }
+ #
+ # Set up array of selected items
+ &SetSelectedMaps($elementname);
+ #
+ # Set up the restriction call
+ if (! defined($restriction)) {
+ $restriction = sub { 1; };
+ }
+ #
+ # Build the form element
+ my $Str = "\n";
+ $Str .= '\n";
+ return $Str;
+}
- if($c->aborted()) {
- untie(%cache);
- return 'aborted';
- }
+##############################################
+##############################################
- untie(%cache);
+=pod
- return ('OK', $students);
-}
+=item &SectionSelect($elementname,$status,$numvisible)
-# Create progress
-sub Create_PrgWin {
- $r->print(<
- popwin=open('','popwin','width=400,height=100');
- popwin.document.writeln(''+
- 'LON-CAPA Statistics'+
- '
Computation Progress
'+
- ''+
- '');
- popwin.document.close();
-
-ENDPOP
+Returns html for a selection box allowing the user to choose one (or more)
+of the sections in the course.
- $r->rflush();
-}
+Uses the package variables @Sections and @SelectedSections
+=over 4
-# update progress
-sub Update_PrgWin {
- my ($totalStudents,$index,$name)=@_;
- $r->print('');
- $r->rflush();
-}
+=item $elementname The name of the HTML form element
-# close Progress Line
-sub Close_PrgWin {
- $r->print('');
- $r->rflush();
-}
-
-# For loading the colored table for display or un-colored for print
-sub setbgcolor {
- my $PrintTable=shift;
- undef %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";
- }
+=item $status 'multiple' or 'single' selection box
- return;
-}
+=item $numvisible The number of options to be visible
-sub initial {
- undef %hash;
- undef %CachData;
- undef %GraphDat;
- undef %ConceptData;
- undef $GData;
-}
-
-#---- END HELPER FUNCTIONS ---------------------------------------------------
-
-sub BuildProblemStatisticsPage {
- my ($cacheDB, $students, $courseID, $c)=@_;
-
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- $r->print('Unable to tie database.');
- return;
- }
+=back
- my $Ptr = '';
- $Ptr .= '
');
- return;
- }
-
- my $selected=0;
- foreach (@$students) {
- next if ($_ ne $selectedName &&
- $selectedName ne 'All Students');
- $selected = 1;
- my $courseData =
- &Apache::loncoursedata::DownloadStudentCourseInformation($_,
- $courseID);
- last if ($c->aborted());
- if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
- &Apache::loncoursedata::ProcessStudentData(\%cache,
- $courseData, $_);
- if(!$c->aborted()) { $r->print(&StudentReport(\%cache, $_)); }
- untie(%cache);
- }
- }
- if($selected == 0) {
- $r->print('
WARNING: ');
- $r->print('Please select a student
');
+ $Str.= ''.
+ 'Return to the chart.';
+ $r->print($Str);
+ $r->rflush();
return;
}
- return;
-}
-
-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='';
+ # "Click" is asinine but it is probably not my place to change the world.
+ $Str .= '
Click on a students name or username to view their chart
\n";
+ $Str .= ' '.(' 'x8).$reportdata->{'short_description'}.
+ "\n";
+ }
+ $Str .="\n";
+ #
return $Str;
}
-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";
-
- &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'};
-# }
-
- if(defined($cache{'OptionResponses'})) {
- $reports{'problem_analysis'} = 'Problem Analysis';
+##############################################
+##############################################
+sub handler {
+ my $r=shift;
+ 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
+ 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;
}
-
- $r->print(&Apache::lonhtmlcommon::Title('LON-CAPA Statistics'));
+ }
+ #
+ # 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']);
+ #
+ # Give the LON-CAPA page header
+ $r->print(''.
+ &mt('Course Statistics and Charts').
+ "\n".
+ &Apache::loncommon::bodytag('Course Statistics and Charts'));
+ $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 (! exists($ENV{'form.reportSelected'}) ||
+ $ENV{'form.reportSelected'} eq '') {
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,&mt('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 ').
+ ''.$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.').'