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 .= '
';
+=cut
- return $Ptr;
+ return;
}
-#---- END Problem Statistics Web Page ----------------------------------------
-
-#---- Problem Statistics Graph Web Page --------------------------------------
+##############################################
+##############################################
-# ------------------------------------------- Prepare data for Graphical chart
+=pod
-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 ----------------------------------------------
+=item &MapSelect($elementname,$status,$numvisible,$selected,$restriction)
-sub IntervalOptions {
- my ($cache)=@_;
+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.
- my $interval = 1;
- for(my $n=1; $n<=7; $n++) {
- if($cache->{'Interval'} == $n) {
- $interval = $n;
- }
- }
+=over 4
- my $Ptr = ' Select number of intervals'."\n".
- ''."\n";
+=item $elementname The name of the HTML form element
- return $Ptr;
-}
+=item $status 'multiple' or 'single' selection box
-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 $numvisible The number of options to be visible
- return $Str;
-}
+=item $selected Array ref to the names of the already selected maps.
+If undef, $ENV{'form.'.$elementname} is used.
+If $ENV{'form.'.$elementname} is also empty, none will be selected.
-#---- END Problem Analysis Web Page ------------------------------------------
+=item $restriction Code reference to subroutine which returns true or
+false. The code must expect a reference to a sequence data structure.
-#---- Student Assessment Web Page --------------------------------------------
+=back
-sub MapOptions {
- my ($cache, $page)=@_;
- my $Ptr = '
'."\n";
-
- my $codes;
- my $attempts;
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- if($cache->{'StudentAssessmentMap'} ne 'All Maps' &&
- $cache->{'StudentAssessmentMap'} ne $cache->{$sequence.':title'}) {
- next;
- }
-
- $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'}='-';
- }
-
- # 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;
- }
-
- my $tries=0;
- my $code='U';
-
- $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;
- }
- }
+=pod
- # 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'}.',';
- }
- }
- $codes =~ s/,$//;
- $attempts =~ s/,$//;
- $Str .= '
'."\n";
+Returns html for a selection box allowing the user to choose one (or more)
+of the sections in the course.
- return $Str;
-}
+=over 4
-#---- END Student Assessment Web Page ----------------------------------------
+=item $elementname The name of the HTML form element
-#---- Menu Web Page ----------------------------------------------------------
+=item $status 'multiple' or 'single' selection box
-sub Title {
- my ($downloadTime)=@_;
+=item $numvisible The number of options to be visible
- my $Ptr = '';
+=item $selected Array ref to the names of the already selected sections.
+If undef, $ENV{'form.'.$elementname} is used.
+If $ENV{'form.'.$elementname} is also empty, none will be selected.
- $Ptr .= 'LON-CAPA Statistics'."\n";
- $Ptr .= ''."\n";
- $Ptr .= ''."\n";
- $Ptr .= ''."\n";
- $Ptr .= '
';
+=item $restriction Code reference to subroutine which returns true or
+false. The code must expect a reference to a sequence data structure.
- return $Ptr;
-}
+=back
-sub CreateMenuForm {
- my ($cache)=@_;
- my $Ptr = '
';
- $Ptr .= '
{'OptionResponses'})) {
- $Ptr .= '
'."\n";
+ #
+ # Loop through the sequences
+ foreach my $s (@Sections) {
+ $Str .= '
\n";
+ }
+ $Str .= "\n";
+ return $Str;
}
-#---- END Menu Web Page ------------------------------------------------------
-
-#---- HELPER FUNCTIONS -------------------------------------------------------
+##############################################
+##############################################
sub CheckFormElement {
my ($cache, $ENVName, $cacheName, $default)=@_;
@@ -1566,74 +507,162 @@ sub CheckFormElement {
$cache->{$cacheName} = $ENV{'form.'.$ENVName};
} elsif(!defined($cache->{$cacheName})) {
$cache->{$cacheName} = $default;
+ } else {
+ $ENV{'form.'.$ENVName} = $cache->{$cacheName};
}
-
return;
}
sub ProcessFormData{
- my ($cacheDB, $isCached)=@_;
- my %cache;
+ my ($cache)=@_;
- if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
- # 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.StudentAssessment'}) ||
- defined($ENV{'form.CreateStudentAssessment'}) ||
- defined($ENV{'form.NextStudent'}) ||
- defined($ENV{'form.PreviousStudent'})) {
- $cache{'GoToPage'} = 'StudentAssessment';
- if(defined($ENV{'form.NextStudent'})) {
- $cache{'StudentAssessmentMove'} = 'next';
- } elsif(defined($ENV{'form.PreviousStudent'})) {
- $cache{'StudentAssessmentMove'} = 'previous';
- } else {
- $cache{'StudentAssessmentMove'} = 'selected';
- }
- &CheckFormElement(\%cache, 'Maps', 'StudentAssessmentMap',
- 'All Maps');
+ $cache->{'reportKey'} = 'false';
- &CheckFormElement(\%cache, 'Students', 'StudentAssessmentStudent',
- 'No Student Selected');
- } 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';
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['download',
+ 'reportSelected',
+ 'StudentAssessmentStudent',
+ 'ProblemStatisticsSort']);
+ &CheckFormElement($cache, 'DownloadAll', 'DownloadAll', 'false');
+ if ($cache->{'DownloadAll'} ne 'false') {
+ # Clean the hell out of that cache!
+ # We cannot untie the hash at this scope (stupid libgd :( )
+ # So, remove every single key. What a waste of time....
+ # Of course, if you are doing this you are probably resigned
+ # to waiting a while.
+ &Apache::lonnet::logthis("Cleaning out the cache file");
+ while (my ($key,undef)=each(%$cache)) {
+ next if ($key eq 'DownloadAll');
+ delete($cache->{$key});
+ }
+ }
+ &CheckFormElement($cache, 'Status', 'Status', 'Active');
+ &CheckFormElement($cache, 'postdata', 'reportSelected', 'Class list');
+ &CheckFormElement($cache, 'reportSelected', 'reportSelected',
+ 'Class list');
+ $cache->{'reportSelected'} =
+ &Apache::lonnet::unescape($cache->{'reportSelected'});
+ &CheckFormElement($cache, 'sort', 'sort', 'fullname');
+ &CheckFormElement($cache, 'download', 'download', 'false');
+ &CheckFormElement($cache, 'StatisticsMaps',
+ 'StatisticsMaps', 'All Maps');
+ &CheckFormElement($cache, 'StatisticsProblemSelect',
+ 'StatisticsProblemSelect', 'All Problems');
+ &CheckFormElement($cache, 'StatisticsPartSelect',
+ 'StatisticsPartSelect', 'All Parts');
+ if(defined($ENV{'form.Section'})) {
+ my @sectionsSelected = (ref($ENV{'form.Section'}) ?
+ @{$ENV{'form.Section'}} :
+ ($ENV{'form.Section'}));
+ $cache->{'sectionsSelected'} = join(':', @sectionsSelected);
+ } elsif(!defined($cache->{'sectionsSelected'})) {
+ $cache->{'sectionsSelected'} = $cache->{'sectionList'};
+ }
+
+ # student assessment
+ 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';
+ }
+ &CheckFormElement($cache, 'StudentAssessmentStudent',
+ 'StudentAssessmentStudent', 'All Students');
+ $cache->{'StudentAssessmentStudent'} =
+ &Apache::lonnet::unescape($cache->{'StudentAssessmentStudent'});
+ &CheckFormElement($cache, 'DefaultColumns', 'DefaultColumns', 'false');
+
+ # Problem analysis
+ &CheckFormElement($cache, 'Interval', 'Interval', '1');
+
+ # ProblemStatistcs
+ &CheckFormElement($cache, 'DisplayCSVFormat',
+ 'DisplayFormat', 'Display Table Format');
+ &CheckFormElement($cache, 'ProblemStatisticsAscend',
+ 'ProblemStatisticsAscend', 'Ascending');
+ &CheckFormElement($cache, 'ProblemStatisticsSort',
+ 'ProblemStatisticsSort', 'Homework Sets Order');
+ &CheckFormElement($cache, 'DisplayLegend', 'DisplayLegend',
+ 'Hide Legend');
+ &CheckFormElement($cache, 'SortProblems', 'SortProblems',
+ 'Sort Within Sequence');
+
+ # Search only form elements
+ my @headingColumns=();
+ my @sequenceColumns=();
+ my $foundColumn = 0;
+ if(defined($ENV{'form.ReselectColumns'})) {
+ my @reselected = (ref($ENV{'form.ReselectColumns'}) ?
+ @{$ENV{'form.ReselectColumns'}}
+ : ($ENV{'form.ReselectColumns'}));
+ foreach (@reselected) {
+ if(/HeadingColumn/) {
+ push(@headingColumns, $_);
+ $foundColumn = 1;
+ } elsif(/SequenceColumn/) {
+ push(@sequenceColumns, $_);
+ $foundColumn = 1;
+ }
}
+ }
- &CheckFormElement(\%cache, 'Status', 'Status', 'Active');
-
- foreach (keys(%ENV)) {
- if(/form\.Analyze:::/) {
- $cache{'GoToPage'} = 'Analyze';
- 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');
- }
+ $cache->{'reportKey'} = 'false';
+ if($cache->{'reportSelected'} eq 'Analyze') {
+ $cache->{'reportKey'} = 'Analyze';
+ } elsif($cache->{'reportSelected'} eq 'DoDiffGraph') {
+ $cache->{'reportKey'} = 'DoDiffGraph';
+ } elsif($cache->{'reportSelected'} eq 'PercentWrongGraph') {
+ $cache->{'reportKey'} = 'PercentWrongGraph';
+ }
+
+ if(defined($ENV{'form.DoDiffGraph'})) {
+ $cache->{'reportSelected'} = 'DoDiffGraph';
+ $cache->{'reportKey'} = 'DoDiffGraph';
+ } elsif(defined($ENV{'form.PercentWrongGraph'})) {
+ $cache->{'reportSelected'} = 'PercentWrongGraph';
+ $cache->{'reportKey'} = 'PercentWrongGraph';
+ }
+
+ foreach (keys(%ENV)) {
+ if(/form\.Analyze/) {
+ $cache->{'reportSelected'} = 'Analyze';
+ $cache->{'reportKey'} = 'Analyze';
+ my $data;
+ (undef, $data)=split(':::', $_);
+ $cache->{'AnalyzeInfo'}=$data;
+ } elsif(/form\.HeadingColumn/) {
+ my $value = $_;
+ $value =~ s/form\.//;
+ push(@headingColumns, $value);
+ $foundColumn=1;
+ } elsif(/form\.SequenceColumn/) {
+ my $value = $_;
+ $value =~ s/form\.//;
+ push(@sequenceColumns, $value);
+ $foundColumn=1;
}
}
+ if($foundColumn) {
+ $cache->{'HeadingsFound'} = join(':', @headingColumns);
+ $cache->{'SequencesFound'} = join(':', @sequenceColumns);;
+ }
+ if(!defined($cache->{'HeadingsFound'}) ||
+ $cache->{'DefaultColumns'} ne 'false') {
+ $cache->{'HeadingsFound'}='HeadingColumnFull Name';
+ }
+ if(!defined($cache->{'SequencesFound'}) ||
+ $cache->{'DefaultColumns'} ne 'false') {
+ $cache->{'SequencesFound'}='All Sequences';
+ }
+ $cache->{'DefaultColumns'} = 'false';
+
return;
}
@@ -1663,425 +692,468 @@ Output: \@order
=cut
sub SortStudents {
- my ($students,$cache)=@_;
+ my ($cache)=@_;
+ my @students = split(':::',$cache->{'NamesOfStudents'});
my @sorted1Students=();
- foreach (@$students) {
- push(@sorted1Students, $_);
+ foreach (@students) {
+ if($cache->{'Status'} eq 'Any' ||
+ $cache->{$_.':Status'} eq $cache->{'Status'}) {
+ push(@sorted1Students, $_);
+ }
}
-# my ($end,$start)=split(/\:/,$cache->{$_.':date'});
-# my $active=1;
-# my $now=time;
-# my $Status=$cache->{'form.Status'};
-# $Status = ($Status) ? $Status : 'Active';
-# if((($end) && $now > $end) && (($Status eq 'Active'))) {
-# $active=0;
-# }
-# if(($Status eq 'Expired') && ($end == 0 || $now < $end)) {
-# $active=0;
-# }
-# if($active) {
-# push(@sorted1Students, $_);
-# }
-# }
-
- my $Pos = $cache->{'form.ChartSort'};
- my %sortData;
- if($Pos eq 'Last Name') {
- for(my $index=0; $index{$sorted1Students[$index].':fullname'}}=
- $sorted1Students[$index];
- }
- } elsif($Pos eq 'Section') {
- for(my $index=0; $index{$sorted1Students[$index].':section'}.
- $sorted1Students[$index]}=$sorted1Students[$index];
- }
+
+ my $sortBy = '';
+ if(defined($cache->{'sort'})) {
+ $sortBy = ':'.$cache->{'sort'};
} else {
- # Sort by user name
- for(my $index=0; $index{$a.$sortBy}) cmp lc($cache->{$b.$sortBy}) ||
+ lc($cache->{$a.':fullname'}) cmp lc($cache->{$b.':fullname'}) }
+ @sorted1Students;
+
+ return \@order;
+}
+
+=pod
+
+=item &SpaceColumns()
- my @order = ();
- foreach my $key (sort(keys(%sortData))) {
- push (@order,$sortData{$key});
+Determines the width of all the columns in the chart. It is based on
+the max of the data for that column and its header.
+
+=over 4
+
+Input: $students, $studentInformation, $headings, $ChartDB
+
+$students: An array pointer to a list of students (username:domain)
+
+$studentInformatin: The type of data for the student information. It is
+used as part of the key in $CacheData.
+
+$headings: The name of the student information columns.
+
+$ChartDB: The name of the cache database which is opened for read/write.
+
+Output: None - All data stored in cache.
+
+=back
+
+=cut
+
+sub SpaceColumns {
+ my ($students,$studentInformation,$headings,$cache)=@_;
+
+ # Initialize Lengths
+ for(my $index=0; $index<(scalar @$headings); $index++) {
+ my @titleLength=split(//,$headings->[$index]);
+ $cache->{$studentInformation->[$index].':columnWidth'}=
+ scalar @titleLength;
+ }
+
+ foreach my $name (@$students) {
+ foreach (@$studentInformation) {
+ my @dataLength=split(//,$cache->{$name.':'.$_});
+ my $length=(scalar @dataLength);
+ if($length > $cache->{$_.':columnWidth'}) {
+ $cache->{$_.':columnWidth'}=$length;
+ }
+ }
}
- return \@order;
+ return;
}
sub PrepareData {
- my ($c, $cacheDB)=@_;
+ my ($c, $cacheDB, $studentInformation, $headings,$r)=@_;
# Test for access to the cache data
- my $isCached=0;
my $courseID=$ENV{'request.course.id'};
my $isRecalculate=0;
- if(defined($ENV{'form.ProblemStatisticsRecalculate'}) ||
- defined($ENV{'form.ChartRecalculate'})) {
+ if(defined($ENV{'form.Recalculate'})) {
$isRecalculate=1;
}
- $isRecalculate=1;
-
- $isCached=&Apache::loncoursedata::TestCacheData($cacheDB, $isRecalculate);
+ my $isCached = &Apache::loncoursedata::TestCacheData($cacheDB,
+ $isRecalculate);
if($isCached < 0) {
return "Unable to tie hash to db file.";
}
- &ProcessFormData($cacheDB, $isCached);
# Download class list information if not using cached data
my %cache;
- my @students=();
- if(!$isCached) {
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
- return "Unable to tie hash to db file.";
- }
+ unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
+ return "Unable to tie hash to db file.";
+ }
+# if(!$isCached) {
my $processTopResourceMapReturn=
&Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c);
if($processTopResourceMapReturn ne 'OK') {
untie(%cache);
return $processTopResourceMapReturn;
}
+ # }
- if($c->aborted()) {
- untie(%cache);
- return 'aborted';
- }
+ if($c->aborted()) {
+ untie(%cache);
+ return 'aborted';
+ }
- my $classlist=&Apache::loncoursedata::DownloadStudentNamePIDSection(
- $courseID,
- $c);
- my ($checkForError)=keys(%$classlist);
- if($checkForError =~ /^(con_lost|error|no_such_host)/i ||
- defined($classlist->{'error'})) {
+ 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.";
}
+ }
- if($c->aborted()) {
- untie(%cache);
- return 'aborted';
- }
-
- # Active is a temporary solution, remember to change
- @students=&Apache::loncoursedata::ProcessClassList(\%cache,
- $classlist,
- $courseID,
- 'Active', $c);
-
- if($c->aborted()) {
- untie(%cache);
- return 'aborted';
- }
-
+ if($c->aborted()) {
untie(%cache);
- } else {
- if(!$c->aborted() && tie(%cache,'GDBM_File',$cacheDB,
- &GDBM_READER,0640)) {
- @students=split(/:::/,$cache{'NamesOfStudents'});
- } else {
- return 'aborted';
- }
+ return 'aborted';
}
- return ('OK', $isCached, \@students);
-}
-
-# 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
-
- $r->rflush();
-}
-
-# update progress
-sub Update_PrgWin {
- my ($totalStudents,$index,$name)=@_;
- $r->print('');
- $r->rflush();
-}
-
-# 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";
+ # Active is a temporary solution, remember to change
+ Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c);
+ if($c->aborted()) {
+ untie(%cache);
+ return 'aborted';
}
- return;
-}
-
-sub initial {
- undef %hash;
- undef %CachData;
- undef %GraphDat;
- undef %ConceptData;
- undef $GData;
-}
-
-#---- END HELPER FUNCTIONS ---------------------------------------------------
-
-sub BuildProblemStatisticsPage {
- my ($cacheDB, $students)=@_;
-
- my %cache;
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- $r->print('Unable to tie database.');
- return;
+ &ProcessFormData(\%cache);
+ my $students = &SortStudents(\%cache);
+ &SpaceColumns($students, $studentInformation, $headings, \%cache);
+ $cache{'updateTime:columnWidth'}=24;
+
+ my $download = $cache{'download'};
+ my $downloadAll = $cache{'DownloadAll'};
+ my @allStudents=();
+ if($download ne 'false') {
+ $cache{'download'} = 'false';
+ } elsif($downloadAll ne 'false') {
+ $cache{'DownloadAll'} = 'false';
+ if($downloadAll eq 'sorted') {
+ @allStudents = @$students;
+ } else {
+ @allStudents = split(':::', $cache{'NamesOfStudents'});
+ }
}
- my $Ptr = '';
- $Ptr .= '