version 1.28, 2002/07/19 18:17:34
|
version 1.29, 2002/07/22 20:35:05
|
Line 42 use Apache::Constants qw(:common :http);
|
Line 42 use Apache::Constants qw(:common :http);
|
use Apache::lonnet(); |
use Apache::lonnet(); |
use Apache::lonhomework; |
use Apache::lonhomework; |
use Apache::loncommon; |
use Apache::loncommon; |
|
use Apache::loncoursedata; |
|
use Apache::lonhtmlcommon; |
|
use Apache::lonchart; |
use HTML::TokeParser; |
use HTML::TokeParser; |
use GDBM_File; |
use GDBM_File; |
|
|
Line 1114 sub TableRow {
|
Line 1117 sub TableRow {
|
} |
} |
$GraphDat{$RealIdx}=$DoD.':'.$Wrng; |
$GraphDat{$RealIdx}=$DoD.':'.$Wrng; |
} |
} |
|
|
sub StatusOptions { |
sub StatusOptions { |
my ($cache)=@_; |
my ($cache)=@_; |
|
|
Line 1236 sub ProblemStatisticsLegend {
|
Line 1240 sub ProblemStatisticsLegend {
|
$Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>'; |
$Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>'; |
$Ptr .= '<b>2nd Criterion</b> for Sorting the Students: '; |
$Ptr .= '<b>2nd Criterion</b> for Sorting the Students: '; |
$Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>'; |
$Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>'; |
$Ptr .= '</td>'; |
$Ptr .= '</td></tr>'; |
$Ptr .= '<td><b>Disc.</b></td>'; |
$Ptr .= '<tr><td><b>Disc.</b></td>'; |
$Ptr .= '<td>Number of Students had at least one discussion.'; |
$Ptr .= '<td>Number of Students had at least one discussion.'; |
$Ptr .= '</td></tr></table>'; |
$Ptr .= '</td></tr></table>'; |
|
|
Line 1348 sub OptionResponseTable {
|
Line 1352 sub OptionResponseTable {
|
|
|
#---- Student Assessment Web Page -------------------------------------------- |
#---- Student Assessment Web Page -------------------------------------------- |
|
|
sub MapOptions { |
|
my ($cache, $page)=@_; |
|
my $Ptr = '<tr>'; |
|
$Ptr .= '<td align="right"><b>Select Map</b></td>'."\n"; |
|
$Ptr .= '<td align="left"><select name="Maps">'."\n"; |
|
|
|
my $selected = 0; |
|
foreach my $sequence (split(':',$cache->{'orderedSequences'})) { |
|
$Ptr .= '<option'; |
|
if($cache->{$page.'Map'} eq $cache->{$sequence.':title'}) { |
|
$Ptr .= ' selected'; |
|
$selected = 1; |
|
} |
|
$Ptr .= '>'.$cache->{$sequence.':title'}.'</option>'."\n"; |
|
} |
|
$Ptr .= '<option'; |
|
if(!$selected) { |
|
$Ptr .= ' selected'; |
|
} |
|
$Ptr .= '>All Maps</option>'."\n"; |
|
|
|
$Ptr .= '</select></td></tr>'."\n"; |
|
|
|
return $Ptr; |
|
} |
|
|
|
sub StudentOptions { |
|
my ($students, $selectedName)=@_; |
|
|
|
my $Ptr ='<tr>'; |
|
$Ptr .= '<td align="right"><b>Select Student</b></td>'."\n"; |
|
$Ptr .= '<td align="left"><select name="Students">'."\n"; |
|
|
|
my $selected=0; |
|
foreach (@$students) { |
|
my ($name) = split(':',$_); |
|
$Ptr .= '<option'; |
|
if($selectedName eq $name) { |
|
$Ptr .= ' selected'; |
|
$selected = 1; |
|
} |
|
$Ptr .= '>'.$name.'</option>'."\n"; |
|
} |
|
|
|
$Ptr .= '<option'; |
|
if(!$selected) { |
|
$Ptr .= ' selected'; |
|
} |
|
$Ptr .= '>No Student Selected</option>'."\n"; |
|
|
|
$Ptr .= '</select></td></tr>'."\n"; |
|
|
|
return $Ptr; |
|
} |
|
|
|
# ------ Create different Student Report |
# ------ Create different Student Report |
sub StudentReport { |
sub StudentReport { |
my ($cache, $name)=@_; |
my ($cache, $name)=@_; |
Line 1514 sub StudentReport {
|
Line 1463 sub StudentReport {
|
|
|
#---- Menu Web Page ---------------------------------------------------------- |
#---- Menu Web Page ---------------------------------------------------------- |
|
|
sub Title { |
|
my ($downloadTime)=@_; |
|
|
|
my $Ptr = ''; |
|
|
|
$Ptr .= '<html><head><title>LON-CAPA Statistics</title></head>'."\n"; |
|
$Ptr .= '<body bgcolor="#FFFFFF">'."\n"; |
|
$Ptr .= '<script>window.focus(); window.width=500;window.height=500;'; |
|
$Ptr .= '</script>'."\n"; |
|
$Ptr .= '<img align=right src=/adm/lonIcons/lonlogos.gif>'."\n"; |
|
$Ptr .= '<h1> Course : "'; |
|
$Ptr .= $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; |
|
$Ptr .= '"</h1>'."\n"; |
|
$Ptr .= '<h3>'.$downloadTime.'</h3>'; |
|
|
|
return $Ptr; |
|
} |
|
|
|
sub CreateMenuForm { |
|
my ($cache)=@_; |
|
my $Ptr = '<table border="0">'; |
|
$Ptr .= '<tr><td><input type="submit" name="ProblemStatistics" '; |
|
$Ptr .= 'value="Problem Stats"/>'; |
|
$Ptr .= '</td></tr>'."\n"; |
|
|
|
if(defined($cache->{'OptionResponses'})) { |
|
$Ptr .= '<tr><td><input type="submit" name="ProblemAnalysis" '; |
|
$Ptr .= 'value="Problem Analysis"/>'; |
|
$Ptr .= '</td></tr>'."\n"; |
|
} |
|
|
|
$Ptr .= '<tr><td><input type="submit" name="StudentAssessment" '; |
|
$Ptr .= 'value="Student Assessment"/>'; |
|
$Ptr .= '</td></tr>'."\n"; |
|
#$Ptr .= '<input type="submit" name="ActivityLog" value="Activity Log"/>'; |
|
|
|
$Ptr .= '</table>'."\n"; |
|
|
|
return $Ptr; |
|
} |
|
|
|
#---- END Menu Web Page ------------------------------------------------------ |
#---- END Menu Web Page ------------------------------------------------------ |
|
|
#---- HELPER FUNCTIONS ------------------------------------------------------- |
#---- HELPER FUNCTIONS ------------------------------------------------------- |
Line 1572 sub CheckFormElement {
|
Line 1480 sub CheckFormElement {
|
} |
} |
|
|
sub ProcessFormData{ |
sub ProcessFormData{ |
my ($cacheDB, $isCached)=@_; |
my ($cache)=@_; |
my %cache; |
|
|
|
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { |
$cache->{'reportKey'} = 'false'; |
# 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'); |
|
|
|
&CheckFormElement(\%cache, 'Students', 'StudentAssessmentStudent', |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
'No Student Selected'); |
['sort','download']); |
} elsif(defined($ENV{'form.DoDiffGraph'})) { |
&CheckFormElement($cache, 'Status', 'Status', 'Active'); |
$cache{'GoToPage'} = 'DoDiffGraph'; |
&CheckFormElement($cache, 'postdata', 'reportSelected', 'Class list'); |
} elsif(defined($ENV{'form.PercentWrongGraph'})) { |
&CheckFormElement($cache, 'reportSelected', 'reportSelected', |
$cache{'GoToPage'} = 'PercentWrongGraph'; |
'Class list'); |
} elsif(defined($ENV{'form.ActivityLog'})) { |
&CheckFormElement($cache, 'DownloadAll', 'DownloadAll', 'false'); |
$cache{'GoToPage'} = 'ActivityLog'; |
&CheckFormElement($cache, 'sort', 'sort', 'fullname'); |
} else { |
&CheckFormElement($cache, 'download', 'download', 'false'); |
$cache{'GoToPage'} = 'Menu'; |
|
|
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, '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'); |
} |
} |
|
} |
|
|
&CheckFormElement(\%cache, 'Status', 'Status', 'Active'); |
return; |
|
|
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'); |
# 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'; |
} |
} |
|
|
|
&CheckFormElement($cache, 'Status', 'Status', 'Active'); |
|
|
return; |
return; |
} |
} |
|
|
Line 1663 Output: \@order
|
Line 1583 Output: \@order
|
=cut |
=cut |
|
|
sub SortStudents { |
sub SortStudents { |
my ($students,$cache)=@_; |
my ($cache)=@_; |
|
|
|
my @students = split(':::',$cache->{'NamesOfStudents'}); |
my @sorted1Students=(); |
my @sorted1Students=(); |
foreach (@$students) { |
foreach (@students) { |
push(@sorted1Students, $_); |
if($cache->{'Status'} eq 'Any' || |
} |
$cache->{$_.':Status'} eq $cache->{'Status'}) { |
# my ($end,$start)=split(/\:/,$cache->{$_.':date'}); |
push(@sorted1Students, $_); |
# 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<scalar @sorted1Students; $index++) { |
|
$sortData{$cache->{$sorted1Students[$index].':fullname'}}= |
|
$sorted1Students[$index]; |
|
} |
|
} elsif($Pos eq 'Section') { |
|
for(my $index=0; $index<scalar @sorted1Students; $index++) { |
|
$sortData{$cache->{$sorted1Students[$index].':section'}. |
|
$sorted1Students[$index]}=$sorted1Students[$index]; |
|
} |
|
} else { |
|
# Sort by user name |
|
for(my $index=0; $index<scalar @sorted1Students; $index++) { |
|
$sortData{$sorted1Students[$index]}=$sorted1Students[$index]; |
|
} |
|
} |
} |
|
|
my @order = (); |
my $sortBy = ''; |
foreach my $key (sort(keys(%sortData))) { |
if(defined($cache->{'sort'})) { |
push (@order,$sortData{$key}); |
$sortBy = ':'.$cache->{'sort'}; |
} |
} |
|
my @order = sort { $cache->{$a.$sortBy} cmp $cache->{$b.$sortBy} || |
|
$cache->{$a.':fullname'} cmp $cache->{$b.':fullname'} } |
|
@sorted1Students; |
|
|
return \@order; |
return \@order; |
} |
} |
Line 1716 sub PrepareData {
|
Line 1609 sub PrepareData {
|
my ($c, $cacheDB)=@_; |
my ($c, $cacheDB)=@_; |
|
|
# Test for access to the cache data |
# Test for access to the cache data |
my $isCached=0; |
|
my $courseID=$ENV{'request.course.id'}; |
my $courseID=$ENV{'request.course.id'}; |
my $isRecalculate=0; |
my $isRecalculate=0; |
if(defined($ENV{'form.ProblemStatisticsRecalculate'}) || |
if(defined($ENV{'form.Recalculate'})) { |
defined($ENV{'form.ChartRecalculate'})) { |
|
$isRecalculate=1; |
$isRecalculate=1; |
} |
} |
|
|
$isRecalculate=1; |
my $isCached = &Apache::loncoursedata::TestCacheData($cacheDB, |
|
$isRecalculate); |
$isCached=&Apache::loncoursedata::TestCacheData($cacheDB, $isRecalculate); |
|
if($isCached < 0) { |
if($isCached < 0) { |
return "Unable to tie hash to db file."; |
return "Unable to tie hash to db file."; |
} |
} |
&ProcessFormData($cacheDB, $isCached); |
|
|
|
# Download class list information if not using cached data |
# Download class list information if not using cached data |
my %cache; |
my %cache; |
my @students=(); |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { |
if(!$isCached) { |
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= |
my $processTopResourceMapReturn= |
&Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c); |
&Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c); |
if($processTopResourceMapReturn ne 'OK') { |
if($processTopResourceMapReturn ne 'OK') { |
untie(%cache); |
untie(%cache); |
return $processTopResourceMapReturn; |
return $processTopResourceMapReturn; |
} |
} |
|
} |
|
|
if($c->aborted()) { |
if($c->aborted()) { |
untie(%cache); |
untie(%cache); |
return 'aborted'; |
return 'aborted'; |
} |
} |
|
|
my $classlist=&Apache::loncoursedata::DownloadStudentNamePIDSection( |
my $classlist=&Apache::loncoursedata::DownloadClasslist($courseID, |
$courseID, |
$cache{'ClasslistTimestamp'}, |
$c); |
$c); |
my ($checkForError)=keys(%$classlist); |
foreach (keys(%$classlist)) { |
if($checkForError =~ /^(con_lost|error|no_such_host)/i || |
if(/^(con_lost|error|no_such_host)/i) { |
defined($classlist->{'error'})) { |
|
untie(%cache); |
untie(%cache); |
return "Error getting student data."; |
return "Error getting student data."; |
} |
} |
|
} |
|
|
if($c->aborted()) { |
if($c->aborted()) { |
untie(%cache); |
untie(%cache); |
return 'aborted'; |
return 'aborted'; |
} |
} |
|
|
# Active is a temporary solution, remember to change |
# Active is a temporary solution, remember to change |
@students=&Apache::loncoursedata::ProcessClassList(\%cache, |
Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c); |
$classlist, |
if($c->aborted()) { |
$courseID, |
untie(%cache); |
'Active', $c); |
return 'aborted'; |
|
} |
|
|
if($c->aborted()) { |
&ProcessFormData(\%cache); |
untie(%cache); |
my $students = &SortStudents(\%cache); |
return 'aborted'; |
|
} |
|
|
|
untie(%cache); |
if($cache{'download'} ne 'false') { |
} else { |
my $who = $cache{'download'}; |
if(!$c->aborted() && tie(%cache,'GDBM_File',$cacheDB, |
my $courseData = |
&GDBM_READER,0640)) { |
&Apache::loncoursedata::DownloadStudentCourseInformation( |
@students=split(/:::/,$cache{'NamesOfStudents'}); |
$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 { |
} else { |
return 'aborted'; |
@allStudents = split(':::', $cache{'NamesOfStudents'}); |
} |
} |
|
foreach (@allStudents) { |
|
my $courseData = |
|
&Apache::loncoursedata::DownloadStudentCourseInformation( |
|
$_, $courseID, |
|
$cache{$_.':lastDownloadTime'}); |
|
&Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, |
|
$_); |
|
if($c->aborted()) { |
|
untie(%cache); |
|
return 'aborted'; |
|
} |
|
} |
|
$cache{'DownloadAll'} = 'false'; |
} |
} |
|
|
return ('OK', $isCached, \@students); |
if($c->aborted()) { |
|
untie(%cache); |
|
return 'aborted'; |
|
} |
|
|
|
if($c->aborted()) { |
|
untie(%cache); |
|
return 'aborted'; |
|
} |
|
|
|
untie(%cache); |
|
|
|
return ('OK', $students); |
} |
} |
|
|
# Create progress |
# Create progress |
Line 1856 sub initial {
|
Line 1776 sub initial {
|
#---- END HELPER FUNCTIONS --------------------------------------------------- |
#---- END HELPER FUNCTIONS --------------------------------------------------- |
|
|
sub BuildProblemStatisticsPage { |
sub BuildProblemStatisticsPage { |
my ($cacheDB, $students)=@_; |
my ($cacheDB, $students, $courseID, $c)=@_; |
|
|
my %cache; |
my %cache; |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
Line 1865 sub BuildProblemStatisticsPage {
|
Line 1785 sub BuildProblemStatisticsPage {
|
} |
} |
|
|
my $Ptr = ''; |
my $Ptr = ''; |
$Ptr .= '<form name="ProblemStatisticsPage" method="post" '; |
|
$Ptr .= 'action="/adm/statistics">'."\n"; |
|
$Ptr .= '<table border="0"><tbody>'; |
$Ptr .= '<table border="0"><tbody>'; |
$Ptr .= '<tr><td></td><td align="left"><input type="submit" name="Menu" '; |
$Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n"; |
$Ptr .= 'value="Return to Menu" /></td></tr>'."\n"; |
$Ptr .= '<td align="left">'; |
|
$Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics'); |
|
$Ptr .= '</td></tr>'."\n"; |
$r->print($Ptr); |
$r->print($Ptr); |
|
|
$r->print(&MapOptions(\%cache, 'ProblemStatistics')); |
|
$r->print(&StatusOptions()); |
|
$r->print(&AscendOrderOptions()); |
$r->print(&AscendOrderOptions()); |
$r->print(&ProblemStatisticsButtons(\%cache)); |
$r->print(&ProblemStatisticsButtons(\%cache)); |
$r->print('</table>'); |
$r->print('</table>'); |
|
|
$r->print(&ProblemStatisticsLegend()); |
$r->print(&ProblemStatisticsLegend()); |
|
|
# my $discriminantFactor; |
untie(%cache); |
# my @list=(); |
foreach (@$students) { |
# foreach (@$students) { |
my $courseData = |
# ($discriminantFactor, $list) = &ExtractStudentData(\%cache, $_, |
&Apache::loncoursedata::DownloadStudentCourseInformation($_, |
# \@list); |
$courseID); |
# } |
last if ($c->aborted()); |
|
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { |
|
&Apache::loncoursedata::ProcessStudentData(\%cache, |
|
$courseData, $_); |
|
untie(%cache); |
|
} |
|
} |
|
if($c->aborted()) { return; } |
|
|
# my ($upper, $lower) = &Discriminant($discriminantFactor); |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
# my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod", |
$r->print('<html><body>Unable to tie database.</body></html>'); |
# 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", |
return; |
# 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc."); |
} |
# &BuildStatisticsTable(\%cache, $discriminantFactor, \@list, \%Header, |
my $discriminantFactor; |
# $students); |
my @list=(); |
|
foreach (@$students) { |
|
$discriminantFactor = &ExtractStudentData(\%cache, $_, \@list); |
|
} |
|
|
$r->print('</form>'); |
my ($upper, $lower) = &Discriminant($discriminantFactor); |
|
my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod", |
|
4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", |
|
9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc."); |
|
&BuildStatisticsTable(\%cache, $discriminantFactor, \@list, \%Header, |
|
$students); |
|
|
untie(%cache); |
untie(%cache); |
|
|
Line 1944 sub BuildProblemAnalysisPage {
|
Line 1876 sub BuildProblemAnalysisPage {
|
return; |
return; |
} |
} |
|
|
$r->print('<form name="ProblemAnalysisPage" method="post" '); |
|
$r->print('action="/adm/statistics">'."\n"); |
|
$r->print('<tr><td></td><td align="left"><input type="submit" '); |
|
$r->print('name="Menu" value="Return to Menu" /></td></tr>'."\n"); |
|
$r->print(&IntervalOptions()); |
$r->print(&IntervalOptions()); |
$r->print(&OptionResponseTable(\%cache)); |
$r->print(&OptionResponseTable(\%cache)); |
$r->print('</form>'."\n"); |
|
|
|
untie(%cache); |
untie(%cache); |
|
|
Line 1958 sub BuildProblemAnalysisPage {
|
Line 1885 sub BuildProblemAnalysisPage {
|
} |
} |
|
|
sub BuildStudentAssessmentPage { |
sub BuildStudentAssessmentPage { |
my ($cacheDB, $students, $courseID)=@_; |
my ($cacheDB, $students, $courseID, $c)=@_; |
|
|
my %cache; |
my %cache; |
|
|
my $Ptr = ''; |
my $Ptr = ''; |
$Ptr .= '<form name="StudentAssessmentPage" method="post" '; |
|
$Ptr .= 'action="/adm/statistics">'."\n"; |
|
$Ptr .= '<table border="0"><tbody>'; |
$Ptr .= '<table border="0"><tbody>'; |
$Ptr .= '<tr><td></td><td align="left"><input type="submit" name="Menu" '; |
|
$Ptr .= 'value="Return to Menu" /></td></tr>'."\n"; |
|
$r->print($Ptr); |
$r->print($Ptr); |
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
Line 1976 sub BuildStudentAssessmentPage {
|
Line 1899 sub BuildStudentAssessmentPage {
|
} |
} |
|
|
my $selectedName = $cache{'StudentAssessmentStudent'}; |
my $selectedName = $cache{'StudentAssessmentStudent'}; |
for(my $index=0; $index<(scalar @$students); $index++) { |
for(my $index=0; |
my ($username) = split(':', $students->[$index]); |
($selectedName ne 'All Students') && ($index<(scalar @$students)); |
if($username eq $selectedName) { |
$index++) { |
|
my $fullname = $cache{$students->[$index].':fullname'}; |
|
if($fullname eq $selectedName) { |
if($cache{'StudentAssessmentMove'} eq 'next') { |
if($cache{'StudentAssessmentMove'} eq 'next') { |
if($index == ((scalar @$students) - 1)) { |
if($index == ((scalar @$students) - 1)) { |
($selectedName) = split(':',$students->[0]); |
$selectedName = $students->[0]; |
} else { |
} else { |
($selectedName) = split(':',$students->[$index+1]); |
$selectedName = $students->[$index+1]; |
} |
} |
} elsif($cache{'StudentAssessmentMove'} eq 'previous') { |
} elsif($cache{'StudentAssessmentMove'} eq 'previous') { |
if($index == 0) { |
if($index == 0) { |
($selectedName) = split(':', |
$selectedName = $students->[-1]; |
$students->[(scalar @$students)-1]); |
|
} else { |
} else { |
($selectedName)=split(':',$students->[$index-1]); |
$selectedName = $students->[$index-1]; |
} |
} |
|
} else { |
|
$selectedName = $students->[$index]; |
} |
} |
last; |
last; |
} |
} |
} |
} |
|
|
$r->print(&MapOptions(\%cache, 'StudentAssessment')); |
$Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n"; |
$r->print(&StudentOptions($students, $selectedName)); |
$Ptr .= '<td align="left">'; |
|
$Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'StudentAssessment'); |
|
$Ptr .= '</td></tr>'."\n"; |
|
$Ptr .= '<tr><td align="right"><b>Select Student</b></td>'."\n"; |
|
$Ptr .= '<td align="left">'."\n"; |
|
$Ptr .= &Apache::lonhtmlcommon::StudentOptions(\%cache, $students, |
|
$selectedName, |
|
'StudentAssessment'); |
|
$Ptr .= '</td></tr>'."\n"; |
|
untie(%cache); |
|
|
$Ptr = '<tr><td></td><td align="left">'; |
$Ptr .= '<tr><td></td><td align="left">'; |
$Ptr .= '<input type="submit" name="CreateStudentAssessment" '; |
$Ptr .= '<input type="submit" name="CreateStudentAssessment" '; |
$Ptr .= 'value="Create Student Report" />'; |
$Ptr .= 'value="Create Student Report" />'; |
$Ptr .= '   '; |
$Ptr .= '   '; |
Line 2010 sub BuildStudentAssessmentPage {
|
Line 1945 sub BuildStudentAssessmentPage {
|
$Ptr .= '<input type="submit" name="NextStudent" '; |
$Ptr .= '<input type="submit" name="NextStudent" '; |
$Ptr .= 'value="Next Student" />'; |
$Ptr .= 'value="Next Student" />'; |
$Ptr .= '   '; |
$Ptr .= '   '; |
$Ptr .= '</td></tr></tbody></table></form>'."\n"; |
$Ptr .= '</td></tr></tbody></table>'."\n"; |
$r->print($Ptr); |
$r->print($Ptr); |
|
|
untie(%cache); |
|
|
|
if($selectedName eq 'No Student Selected') { |
if($selectedName eq 'No Student Selected') { |
$r->print('<h3><font color=blue>WARNING: '); |
$r->print('<h3><font color=blue>WARNING: '); |
$r->print('Please select a student</font></h3>'); |
$r->print('Please select a student</font></h3>'); |
return; |
return; |
} |
} |
|
|
my $name = ''; |
my $selected=0; |
foreach (@$students) { |
foreach (@$students) { |
my ($currentName) = split(':',$_); |
next if ($_ ne $selectedName && |
if($currentName eq $selectedName) { |
$selectedName ne 'All Students'); |
$name = $_; |
$selected = 1; |
last; |
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($name eq '') { |
if($selected == 0) { |
$r->print('<h3><font color=blue>ERROR: Unknown student selected.'); |
$r->print('<h3><font color=blue>WARNING: '); |
$r->print('</font></h3>'); |
$r->print('Please select a student</font></h3>'); |
return; |
return; |
} |
} |
|
|
my $courseData = |
|
&Apache::loncoursedata::DownloadStudentCourseInformation($name, |
|
$courseID); |
|
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { |
|
&Apache::loncoursedata::ProcessStudentData(\%cache, |
|
$courseData, $name); |
|
untie(%cache); |
|
} |
|
|
|
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
|
$Ptr .= 'Could not tie database.'; |
|
return $Ptr; |
|
} |
|
$r->print(&StudentReport(\%cache, $name)); |
|
untie(%cache); |
|
|
|
return; |
return; |
} |
} |
|
|
sub BuildMenu { |
sub BuildClasslist { |
my ($cacheDB)=@_; |
my ($cacheDB,$students,$studentInformation,$headings,$spacePadding)=@_; |
|
|
my %cache; |
my %cache; |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
$r->print('<html><body>Unable to tie database.</body></html>'); |
return '<html><body>Unable to tie database.</body></html>'; |
return; |
|
} |
} |
|
|
$r->print('<form name="Menu" method="post" action="/adm/statistics" >'); |
my $Str=''; |
$r->print(&CreateMenuForm(\%cache)); |
$Str .= '<table border="0"><tr><td bgcolor="#777777">'."\n"; |
$r->print('</form>'."\n"); |
$Str .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n"; |
|
|
|
my $displayString = '<td align="left"><a href="/adm/statistics?'; |
|
$displayString .= 'sort=LINKDATA">DISPLAYDATA </a></td>'."\n"; |
|
$Str .= &Apache::lonhtmlcommon::CreateStudentInformationHeadings(\%cache, |
|
$studentInformation, |
|
$headings, |
|
$displayString); |
|
$Str .= '<td align="left">'; |
|
$Str .= '<a href="/adm/statistics?sort=lastDownloadTime">'; |
|
$Str .= 'Last Updated  </a></td>'."\n"; |
|
$Str .= '</tr>'."\n"; |
|
my $alternate=0; |
|
foreach (@$students) { |
|
my ($username, $domain) = split(':', $_); |
|
if($alternate) { |
|
$Str .= '<tr bgcolor="#ffffe6"><td>'; |
|
} else { |
|
$Str .= '<tr bgcolor="#ffffc6"><td>'; |
|
} |
|
$alternate = ($alternate + 1) % 2; |
|
foreach my $data (@$studentInformation) { |
|
if($data eq 'fullname') { |
|
$Str .= '<a href="/adm/statistics?reportSelected='; |
|
$Str .= &Apache::lonnet::escape('Student Assessment').'">'; |
|
} |
|
|
untie(%cache); |
$Str .= $cache{$_.':'.$data}.' '; |
|
|
return; |
if($data eq 'fullname') { |
} |
$Str .= '</a>'; |
|
} |
|
|
# ================================================================ Main Handler |
$Str .= '</td><td>'; |
|
} |
|
|
sub handler { |
$Str .= '<a href="/adm/statistics?download='.$_.'">'; |
$r=shift; |
my $downloadTime = $cache{$_.':lastDownloadTime'}; |
&initial(); |
if($downloadTime ne 'Not downloaded') { |
|
$downloadTime = localtime($downloadTime); |
|
} |
|
$Str .= $downloadTime; |
|
|
unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { |
$Str .= ' </a></td></tr>'."\n"; |
$ENV{'user.error.msg'}= |
|
$r->uri.":vgr:0:0:Cannot view grades for complete course"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
} |
|
|
# Set document type for header only |
$Str .= '</table></td></tr></table>'."\n"; |
if($r->header_only) { |
|
if ($ENV{'browser.mathml'}) { |
|
$r->content_type('text/xml'); |
|
} else { |
|
$r->content_type('text/html'); |
|
} |
|
&Apache::loncommon::no_cache($r); |
|
$r->send_http_header; |
|
return OK; |
|
} |
|
|
|
unless($ENV{'request.course.fn'}) { |
untie(%cache); |
my $requrl=$r->uri; |
|
$ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
$r->content_type('text/html'); |
return $Str; |
$r->send_http_header; |
} |
|
|
|
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 %cache; |
my $courseID=$ENV{'request.course.id'}; |
my $courseID=$ENV{'request.course.id'}; |
my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}". |
my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}". |
"_$ENV{'user.domain'}_$courseID\_statistics.db"; |
"_$ENV{'user.domain'}_$courseID\_statistics.db"; |
my $c = $r->connection; |
|
|
|
my ($returnValue, $isCached, $students) = &PrepareData($c, $cacheDB); |
&setbgcolor(0); |
|
my ($returnValue, $students) = &PrepareData($c, $cacheDB); |
if($returnValue ne 'OK') { |
if($returnValue ne 'OK') { |
$r->print('<html><body>'.$returnValue."\n".'</body></html>'); |
$r->print('<html><body>'.$returnValue."\n".'</body></html>'); |
return OK; |
return OK; |
} |
} |
|
|
my $downloadTime=0; |
|
my $GoToPage; |
my $GoToPage; |
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
$students = &SortStudents($students, \%cache); |
$GoToPage = $cache{'reportSelected'}; |
if(defined($cache{'time'})) { |
$reports{'reportSelected'} = $cache{'reportSelected'}; |
$downloadTime=$cache{'time'}; |
# if(defined($cache{'reportKey'}) && $cache{'reportKey'} ne 'false') { |
} else { |
# $reports{$cache{'reportKey'}} = $cache{'reportSelected'}; |
$downloadTime=localtime(); |
# } |
} |
|
if(!defined($cache{'GoToPage'})) { |
if(defined($cache{'OptionResponses'})) { |
$GoToPage = 'Menu'; |
$reports{'problem_analysis'} = 'Problem Analysis'; |
} else { |
|
$GoToPage = $cache{'GoToPage'}; |
|
} |
} |
|
|
|
$r->print(&Apache::lonhtmlcommon::Title('LON-CAPA Statistics')); |
|
$r->print('<form name="Statistics" '); |
|
$r->print('method="post" action="/adm/statistics">'); |
|
$r->print(&Apache::lonhtmlcommon::CreateStatisticsMainMenu( |
|
$cache{'Status'}, |
|
\%reports)); |
untie(%cache); |
untie(%cache); |
} else { |
} else { |
$r->print('<html><body>Unable to tie database.</body></html>'); |
$r->print('<html><body>Unable to tie database.</body></html>'); |
return OK; |
return OK; |
} |
} |
|
|
&setbgcolor(0); |
if($GoToPage eq 'Activity Log') { |
$r->print(&Title()); |
|
|
|
if($GoToPage eq 'ActivityLog') { |
|
&Activity(); |
&Activity(); |
} elsif($GoToPage eq 'ProblemStatistics') { |
} elsif($GoToPage eq 'Problem Statistics') { |
&BuildProblemStatisticsPage($cacheDB, $students); |
&BuildProblemStatisticsPage($cacheDB, $students, $courseID, $c); |
} elsif($GoToPage eq 'ProblemAnalysis') { |
} elsif($GoToPage eq 'Problem Analysis') { |
&BuildProblemAnalysisPage($cacheDB); |
&BuildProblemAnalysisPage($cacheDB); |
} elsif($GoToPage eq 'StudentAssessment') { |
} elsif($GoToPage eq 'Student Assessment') { |
&BuildStudentAssessmentPage($cacheDB, $students, $courseID); |
&BuildStudentAssessmentPage($cacheDB, $students, $courseID, $c); |
} elsif($GoToPage eq 'Analyze') { |
} elsif($GoToPage eq 'Analyze') { |
&BuildAnalyzePage($cacheDB, $students, $courseID); |
&BuildAnalyzePage($cacheDB, $students, $courseID); |
} elsif($GoToPage eq 'DoDiffGraph') { |
} elsif($GoToPage eq 'DoDiffGraph') { |
&BuildDiffGraph($courseID); |
&BuildDiffGraph($courseID); |
} elsif($GoToPage eq 'PercentWrongGraph') { |
} elsif($GoToPage eq 'PercentWrongGraph') { |
&BuildWrongGraph($courseID); |
&BuildWrongGraph($courseID); |
} else { |
} elsif($GoToPage eq 'Class list') { |
&BuildMenu($cacheDB); |
$r->print(&BuildClasslist($cacheDB, $students, \@studentInformation, |
|
\@headings, $spacePadding)); |
} |
} |
|
|
|
$r->print('</form>'."\n"); |
$r->print("\n".'</body>'."\n".'</html>'); |
$r->print("\n".'</body>'."\n".'</html>'); |
$r->rflush(); |
$r->rflush(); |
|
|
return OK; |
return OK; |
} |
} |
|
|
|
# ================================================================ Main Handler |
|
|
|
sub handler { |
|
$r=shift; |
|
&initial(); |
|
|
|
unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { |
|
$ENV{'user.error.msg'}= |
|
$r->uri.":vgr:0:0:Cannot view grades for complete course"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
# Set document type for header only |
|
if($r->header_only) { |
|
if ($ENV{'browser.mathml'}) { |
|
$r->content_type('text/xml'); |
|
} else { |
|
$r->content_type('text/html'); |
|
} |
|
&Apache::loncommon::no_cache($r); |
|
$r->send_http_header; |
|
return OK; |
|
} |
|
|
|
unless($ENV{'request.course.fn'}) { |
|
my $requrl=$r->uri; |
|
$ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized"; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
$r->content_type('text/html'); |
|
$r->send_http_header; |
|
|
|
&BuildStatistics($r); |
|
|
|
return OK; |
|
} |
1; |
1; |
__END__ |
__END__ |