version 1.2, 2002/07/25 21:23:51
|
version 1.6, 2002/08/01 20:49:06
|
Line 42 use Apache::lonhtmlcommon;
|
Line 42 use Apache::lonhtmlcommon;
|
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use GDBM_File; |
use GDBM_File; |
|
|
|
#my $jr; |
|
|
sub BuildStudentAssessmentPage { |
sub BuildStudentAssessmentPage { |
my ($cacheDB,$students,$courseID,$formName,$headings,$spacing, |
my ($cacheDB,$students,$courseID,$formName,$headings,$spacing, |
$studentInformation,$r,$c)=@_; |
$studentInformation,$r,$c)=@_; |
|
# $jr = $r; |
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>'); |
$r->print('<html><body>Unable to tie database.</body></html>'); |
return; |
return; |
} |
} |
|
|
|
# Remove students who don't have the proper section. |
|
my @sectionsSelected = split(':',$cache{'sectionsSelected'}); |
|
for(my $studentIndex=((scalar @$students)-1); $studentIndex>=0; |
|
$studentIndex--) { |
|
my $value = $cache{$students->[$studentIndex].':section'}; |
|
my $found = 0; |
|
foreach (@sectionsSelected) { |
|
if($_ eq 'none') { |
|
if($value eq '' || !defined($value) || $value eq ' ') { |
|
$found = 1; |
|
last; |
|
} |
|
} else { |
|
if($value eq $_) { |
|
$found = 1; |
|
last; |
|
} |
|
} |
|
} |
|
if($found == 0) { |
|
splice(@$students, $studentIndex, 1); |
|
} |
|
} |
|
my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys, |
|
$doNotShow) = |
|
&ShouldShowColumns(\%cache, $headings, $studentInformation); |
|
|
my $selectedName = &FindSelectedStudent(\%cache, |
my $selectedName = &FindSelectedStudent(\%cache, |
$cache{'StudentAssessmentStudent'}, |
$cache{'StudentAssessmentStudent'}, |
$students); |
$students); |
$r->print(&CreateInterface(\%cache, $selectedName, $students, $formName)); |
$r->print(&CreateInterface(\%cache, $selectedName, $students, $formName, |
|
$doNotShow)); |
|
|
my $Ptr = ''; |
my $Str = ''; |
if($selectedName eq 'No Student Selected') { |
if($selectedName eq 'No Student Selected') { |
$Ptr .= '<h3><font color=blue>WARNING: '; |
$Str .= '<h3><font color=blue>WARNING: '; |
$Ptr .= 'Please select a student</font></h3>'; |
$Str .= 'Please select a student</font></h3>'; |
$r->print($Ptr); |
$r->print($Str); |
return; |
return; |
} |
} |
|
|
my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys) = |
|
&ShouldShowColumns(\%cache, $headings, $studentInformation); |
|
|
|
$r->print(&CreateTableHeadings(\%cache, $spacing, $infoKeys, $infoHeadings, |
$r->print(&CreateTableHeadings(\%cache, $spacing, $infoKeys, $infoHeadings, |
$sequenceKeys, $sequenceHeadings)); |
$sequenceKeys, $sequenceHeadings)); |
untie(%cache); |
untie(%cache); |
|
if($c->aborted()) { return $Str; } |
|
|
my $selected=0; |
my $selected=0; |
$r->print('<pre>'."\n"); |
$r->print('<pre>'."\n"); |
foreach (@$students) { |
foreach (@$students) { |
|
if($c->aborted()) { return $Str; } |
next if ($_ ne $selectedName && |
next if ($_ ne $selectedName && |
$selectedName ne 'All Students'); |
$selectedName ne 'All Students'); |
$selected = 1; |
$selected = 1; |
my $courseData; |
my $courseData; |
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
my $downloadTime=''; |
if($cache{$_.':lastDownloadTime'} eq 'Not downloaded') { |
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
untie(%cache); |
$downloadTime = $cache{$_.':lastDownloadTime'}; |
$courseData = |
untie(%cache); |
&Apache::loncoursedata::DownloadCourseInformation($_, |
} |
$courseID); |
if($downloadTime eq 'Not downloaded') { |
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { |
$courseData = |
&Apache::loncoursedata::ProcessStudentData(\%cache, |
&Apache::loncoursedata::DownloadCourseInformation($_, |
$courseData, $_); |
$courseID); |
untie(%cache); |
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) { |
} else { |
next; |
last if($c->aborted()); |
|
next; |
|
} |
|
} else { |
|
untie(%cache); |
|
} |
} |
} else { |
&Apache::loncoursedata::ProcessStudentData(\%cache, |
last if($c->aborted()); |
$courseData, $_); |
next; |
untie(%cache); |
} |
} |
|
|
last if ($c->aborted()); |
next if($c->aborted()); |
|
|
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { |
if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { |
my $displayString = 'DISPLAYDATA'.$spacing; |
my $displayString = 'DISPLAYDATA'.$spacing; |
$r->print(&Apache::lonhtmlcommon::FormatStudentInformation( |
$r->print(&Apache::lonhtmlcommon::FormatStudentInformation( |
\%cache, $_, |
\%cache, $_, |
Line 116 sub BuildStudentAssessmentPage {
|
Line 141 sub BuildStudentAssessmentPage {
|
} |
} |
$r->print('</pre>'."\n"); |
$r->print('</pre>'."\n"); |
if($selected == 0) { |
if($selected == 0) { |
$Ptr .= '<h3><font color=blue>WARNING: '; |
$Str .= '<h3><font color=blue>WARNING: '; |
$Ptr .= 'Please select a student</font></h3>'; |
$Str .= 'Please select a student</font></h3>'; |
$r->print($Ptr); |
$r->print($Str); |
} |
} |
|
|
return; |
return; |
Line 127 sub BuildStudentAssessmentPage {
|
Line 152 sub BuildStudentAssessmentPage {
|
#---- Student Assessment Web Page -------------------------------------------- |
#---- Student Assessment Web Page -------------------------------------------- |
|
|
sub CreateInterface { |
sub CreateInterface { |
my($cache,$selectedName,$students,$formName)=@_; |
my($cache,$selectedName,$students,$formName,$doNotShow)=@_; |
my $Ptr = ''; |
|
$Ptr .= &CreateLegend(); |
my $Str = ''; |
$Ptr .= '<table><tr><td>'."\n"; |
$Str .= &CreateLegend(); |
$Ptr .= '<input type="submit" name="PreviousStudent" '; |
$Str .= '<table><tr><td>'."\n"; |
$Ptr .= 'value="Previous Student" />'."\n"; |
$Str .= '<input type="submit" name="PreviousStudent" '; |
$Ptr .= '   '."\n"; |
$Str .= 'value="Previous Student" />'."\n"; |
$Ptr .= &Apache::lonhtmlcommon::StudentOptions($cache, $students, |
$Str .= '   '."\n"; |
|
$Str .= &Apache::lonhtmlcommon::StudentOptions($cache, $students, |
$selectedName, |
$selectedName, |
'StudentAssessment', |
'StudentAssessment', |
$formName); |
$formName); |
$Ptr .= "\n".'   '."\n"; |
$Str .= "\n".'   '."\n"; |
$Ptr .= '<input type="submit" name="NextStudent" '; |
$Str .= '<input type="submit" name="NextStudent" '; |
$Ptr .= 'value="Next Student" />'."\n"; |
$Str .= 'value="Next Student" />'."\n"; |
$Ptr .= '</td></tr></table>'."\n"; |
$Str .= '</td></tr></table>'."\n"; |
|
$Str .= '<table cellspacing="5"><tr>'."\n"; |
|
$Str .= '<td align="center"><b>Select Sections</b>'."\n"; |
|
$Str .= '</td>'."\n"; |
|
$Str .= '<td align="center"><b>Select column to view:</b></td>'."\n"; |
|
$Str .= '<td></td></tr>'."\n"; |
|
|
|
$Str .= '<tr><td align="center">'."\n"; |
|
my @sections = split(':',$cache->{'sectionList'}); |
|
my @selectedSections = split(':',$cache->{'sectionsSelected'}); |
|
$Str .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, |
|
\@selectedSections, |
|
'Statistics'); |
|
$Str .= '</td><td align="center">'; |
|
$Str .= &CreateColumnSelectionBox($doNotShow); |
|
$Str .= '</td><td>'."\n"; |
|
$Str .= '<input type="submit" name="DefaultColumns" '; |
|
$Str .= 'value="Default Column Display" />'."\n"; |
|
$Str .= '</td></tr></table>'."\n"; |
|
|
return $Ptr; |
return $Str; |
} |
} |
|
|
sub CreateTableHeadings { |
sub CreateTableHeadings { |
Line 151 sub CreateTableHeadings {
|
Line 195 sub CreateTableHeadings {
|
$sequenceHeadings)=@_; |
$sequenceHeadings)=@_; |
|
|
my $Str = ''; |
my $Str = ''; |
$Str .= '<br><table border="0" cellpadding="0" cellspacing="0"><tr>'."\n"; |
$Str .= '<table border="0" cellpadding="0" cellspacing="0">'."\n"; |
|
|
|
$Str .= '<tr>'."\n"; |
|
$Str .= &CreateColumnSelectors($infoHeadings, $sequenceHeadings, |
|
$sequenceKeys); |
|
$Str .= '<td></td></tr>'."\n"; |
|
|
|
$Str .= '<tr>'."\n"; |
my $displayString = '<td align="left"><pre><a href="/adm/statistics?'; |
my $displayString = '<td align="left"><pre><a href="/adm/statistics?'; |
$displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING'; |
$displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING'; |
$displayString .= $spacing.'</pre></td>'."\n"; |
$displayString .= $spacing.'</pre></td>'."\n"; |
Line 398 which has a size of four.
|
Line 448 which has a size of four.
|
=cut |
=cut |
|
|
sub CreateColumnSelectionBox { |
sub CreateColumnSelectionBox { |
my ($CacheData,$headings)=@_; |
my ($doNotShow)=@_; |
|
|
my $missing=0; |
|
my $notThere='<tr><td align="right"><b>Select column to view:</b>'; |
|
my $name; |
|
$notThere .= '<td align="left">'; |
|
$notThere .= '<select name="ChartReselect" size="4" multiple="true">'."\n"; |
|
|
|
for(my $index=0; $index<(scalar @$headings); $index++) { |
|
if(&ShouldShowColumn($CacheData, 'ChartHeading'.$index)) { |
|
next; |
|
} |
|
$name = $headings->[$index]; |
|
$notThere .= '<option value="ChartHeading'.$index.'">'; |
|
$notThere .= $name.'</option>'."\n"; |
|
$missing++; |
|
} |
|
|
|
foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) { |
my $notThere = ''; |
if(&ShouldShowColumn($CacheData, 'ChartSequence'.$sequence)) { |
$notThere .= '<select name="ReselectColumns" size="4" '; |
next; |
$notThere .= 'multiple="true">'."\n"; |
} |
|
$name = $CacheData->{$sequence.':title'}; |
for(my $index=0; $index<$doNotShow->{'count'}; $index++) { |
$notThere .= '<option value="ChartSequence'.$sequence.'">'; |
my $name = $doNotShow->{$index.':name'}; |
|
$notThere .= '<option value="'; |
|
$notThere .= $doNotShow->{$index.':id'}.'">'; |
$notThere .= $name.'</option>'."\n"; |
$notThere .= $name.'</option>'."\n"; |
$missing++; |
|
} |
} |
|
|
if($missing) { |
$notThere .= '</select>'; |
$notThere .= '</select>'; |
|
} else { |
|
$notThere='<tr><td>'; |
|
} |
|
|
|
return $notThere.'</td></tr>'; |
return $notThere; |
} |
} |
|
|
=pod |
=pod |
Line 462 for consistency of location over the col
|
Line 493 for consistency of location over the col
|
=cut |
=cut |
|
|
sub CreateColumnSelectors { |
sub CreateColumnSelectors { |
my ($headings)=@_; |
my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_; |
=pod |
|
my $found=0; |
|
my ($name, $length, $position); |
|
|
|
my $present = '<tr>'; |
my $present = ''; |
for(my $index=0; $index<(scalar @$headings); $index++) { |
for(my $index=0; $index<(scalar @$infoHeadings); $index++) { |
$present .= '<td align="left">'; |
$present .= '<td align="left">'; |
$present .= '<input type="checkbox" checked="on" '; |
$present .= '<input type="checkbox" checked="on" '; |
$present .= 'name="ChartHeading'.$index.'" />'; |
$present .= 'name="HeadingColumn'.$infoHeadings->[$index].'" />'; |
$present .= '</td>'; |
$present .= '</td>'."\n"; |
$found++; |
|
} |
} |
|
|
foreach my $sequence (split(/\:/,$CacheData->{'orderedSequences'})) { |
for(my $index=0; $index<(scalar @$sequenceHeadings); $index++) { |
if(!&ShouldShowColumn($CacheData, 'ChartSequence'.$sequence)) { |
|
next; |
|
} |
|
$present .= '<td align="left">'; |
$present .= '<td align="left">'; |
$present .= '<input type="checkbox" checked="on" '; |
$present .= '<input type="checkbox" checked="on" '; |
$present .= 'name="ChartSequence'.$sequence.'" />'; |
$present .= 'name="SequenceColumn'.$sequenceKeys->[$index].'" />'; |
$present .= '</td>'; |
$present .= '</td>'."\n"; |
$found++; |
|
} |
} |
|
|
if(!$found) { |
return $present; |
$present = ''; |
|
} |
|
|
|
return $present.'<td></td></tr></form>'."\n";; |
|
=cut |
|
} |
} |
|
|
#---- END Student Assessment Web Page ---------------------------------------- |
#---- END Student Assessment Web Page ---------------------------------------- |
Line 501 sub CreateColumnSelectors {
|
Line 519 sub CreateColumnSelectors {
|
|
|
sub FindSelectedStudent { |
sub FindSelectedStudent { |
my($cache, $selectedName, $students)=@_; |
my($cache, $selectedName, $students)=@_; |
for(my $index=0; |
|
($selectedName ne 'All Students') && ($index<(scalar @$students)); |
if($selectedName eq 'All Students' || |
$index++) { |
$selectedName eq 'No Student Selected') { |
|
return $selectedName; |
|
} |
|
|
|
for(my $index=0; $index<(scalar @$students); $index++) { |
my $fullname = $cache->{$students->[$index].':fullname'}; |
my $fullname = $cache->{$students->[$index].':fullname'}; |
if($fullname eq $selectedName) { |
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 = $students->[0]; |
$selectedName = $students->[0]; |
|
return $selectedName; |
} else { |
} else { |
$selectedName = $students->[$index+1]; |
$selectedName = $students->[$index+1]; |
|
return $selectedName; |
} |
} |
} elsif($cache->{'StudentAssessmentMove'} eq 'previous') { |
} elsif($cache->{'StudentAssessmentMove'} eq 'previous') { |
if($index == 0) { |
if($index == 0) { |
$selectedName = $students->[-1]; |
$selectedName = $students->[-1]; |
|
return $selectedName; |
} else { |
} else { |
$selectedName = $students->[$index-1]; |
$selectedName = $students->[$index-1]; |
|
return $selectedName; |
} |
} |
} else { |
} else { |
$selectedName = $students->[$index]; |
$selectedName = $students->[$index]; |
|
return $selectedName; |
} |
} |
last; |
last; |
} |
} |
} |
} |
|
|
return $selectedName; |
return 'No Student Selected'; |
} |
} |
|
|
=pod |
=pod |
Line 558 sub ShouldShowColumns {
|
Line 585 sub ShouldShowColumns {
|
my @sequenceKeys=(); |
my @sequenceKeys=(); |
my @sequenceHeadings=(); |
my @sequenceHeadings=(); |
|
|
|
my %doNotShow; |
|
|
my $index; |
my $index; |
|
my $count = 0; |
|
my $check = ''; |
for($index=0; $index < scalar @$headings; $index++) { |
for($index=0; $index < scalar @$headings; $index++) { |
push(@infoHeadings, $headings->[$index]); |
$check = 'HeadingColumn'.$headings->[$index]; |
push(@infoKeys, $cacheKey->[$index]); |
if($cache->{'HeadingsFound'} =~ /$check/) { |
|
push(@infoHeadings, $headings->[$index]); |
|
push(@infoKeys, $cacheKey->[$index]); |
|
} else { |
|
$doNotShow{$count.':name'} = $headings->[$index]; |
|
$doNotShow{$count.':id'} = 'HeadingColumn'.$headings->[$index]; |
|
$count++; |
|
} |
} |
} |
|
|
foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) { |
foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) { |
push(@sequenceHeadings, $cache->{$sequence.':title'}); |
$check = 'SequenceColumn'.$sequence; |
push(@sequenceKeys, $sequence); |
if($cache->{'SequencesFound'} eq 'All Sequences' || |
|
$cache->{'SequencesFound'} =~ /$check/) { |
|
push(@sequenceHeadings, $cache->{$sequence.':title'}); |
|
push(@sequenceKeys, $sequence); |
|
} else { |
|
$doNotShow{$count.':name'} = $cache->{$sequence.':title'}; |
|
$doNotShow{$count.':id'} = 'SequenceColumn'.$sequence; |
|
$count++; |
|
} |
} |
} |
|
|
# my $headings=$cache->{'form.ChartHeadings'}; |
$doNotShow{'count'} = $count; |
# my $sequences=$cache->{'form.ChartSequences'}; |
|
# if($headings eq 'ALLHEADINGS' || $sequences eq 'ALLSEQUENCES' || |
|
# $headings=~/$test/ || $sequences=~/$test/) { |
|
# return 1; |
|
# } |
|
|
|
return (\@infoHeadings, \@infoKeys, \@sequenceHeadings, |
return (\@infoHeadings, \@infoKeys, \@sequenceHeadings, |
\@sequenceKeys); |
\@sequenceKeys, \%doNotShow); |
} |
} |
|
|
#---- END Student Assessment Worker Functions -------------------------------- |
#---- END Student Assessment Worker Functions -------------------------------- |