Annotation of loncom/interface/statistics/lonstudentassessment.pm, revision 1.17
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: # (Publication Handler
3: #
1.17 ! minaeibi 4: # $Id: lonstudentassessment.pm,v 1.16 2002/10/23 21:04:26 minaeibi Exp $
1.1 stredwic 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: # LON-CAPA is free software; you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation; either version 2 of the License, or
12: # (at your option) any later version.
13: #
14: # LON-CAPA is distributed in the hope that it will be useful,
15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: # GNU General Public License for more details.
18: #
19: # You should have received a copy of the GNU General Public License
20: # along with LON-CAPA; if not, write to the Free Software
21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: #
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: # (Navigate problems for statistical reports
28: # YEAR=2001
29: # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
30: # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
31: # YEAR=2002
32: # 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
33: # 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei
34: #
35: ###
36:
37: package Apache::lonstudentassessment;
38:
39: use strict;
40: use Apache::lonhtmlcommon;
41: use Apache::loncoursedata;
42: use GDBM_File;
43:
1.4 stredwic 44: #my $jr;
45:
1.1 stredwic 46: sub BuildStudentAssessmentPage {
1.2 stredwic 47: my ($cacheDB,$students,$courseID,$formName,$headings,$spacing,
48: $studentInformation,$r,$c)=@_;
1.4 stredwic 49: # $jr = $r;
1.1 stredwic 50: my %cache;
1.6 stredwic 51: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
1.11 stredwic 52: $r->print('<html><body>Unable to tie database.</body></html>');
1.2 stredwic 53: return;
1.1 stredwic 54: }
1.3 stredwic 55:
56: # Remove students who don't have the proper section.
57: my @sectionsSelected = split(':',$cache{'sectionsSelected'});
58: for(my $studentIndex=((scalar @$students)-1); $studentIndex>=0;
59: $studentIndex--) {
60: my $value = $cache{$students->[$studentIndex].':section'};
61: my $found = 0;
62: foreach (@sectionsSelected) {
63: if($_ eq 'none') {
64: if($value eq '' || !defined($value) || $value eq ' ') {
65: $found = 1;
66: last;
67: }
68: } else {
69: if($value eq $_) {
70: $found = 1;
71: last;
72: }
73: }
74: }
75: if($found == 0) {
76: splice(@$students, $studentIndex, 1);
77: }
78: }
1.4 stredwic 79: my ($infoHeadings, $infoKeys, $sequenceHeadings, $sequenceKeys,
80: $doNotShow) =
81: &ShouldShowColumns(\%cache, $headings, $studentInformation);
1.3 stredwic 82:
1.2 stredwic 83: my $selectedName = &FindSelectedStudent(\%cache,
84: $cache{'StudentAssessmentStudent'},
85: $students);
1.4 stredwic 86: $r->print(&CreateInterface(\%cache, $selectedName, $students, $formName,
87: $doNotShow));
1.7 stredwic 88: $r->rflush();
1.1 stredwic 89:
1.4 stredwic 90: my $Str = '';
1.1 stredwic 91: if($selectedName eq 'No Student Selected') {
1.4 stredwic 92: $Str .= '<h3><font color=blue>WARNING: ';
93: $Str .= 'Please select a student</font></h3>';
94: $r->print($Str);
1.2 stredwic 95: return;
1.1 stredwic 96: }
97:
1.2 stredwic 98: $r->print(&CreateTableHeadings(\%cache, $spacing, $infoKeys, $infoHeadings,
99: $sequenceKeys, $sequenceHeadings));
100: untie(%cache);
1.6 stredwic 101: if($c->aborted()) { return $Str; }
1.2 stredwic 102:
1.1 stredwic 103: my $selected=0;
1.2 stredwic 104: $r->print('<pre>'."\n");
1.1 stredwic 105: foreach (@$students) {
1.8 stredwic 106: if($c->aborted()) { return $Str; }
1.17 ! minaeibi 107: next if ($_ ne $selectedName &&
1.1 stredwic 108: $selectedName ne 'All Students');
109: $selected = 1;
1.2 stredwic 110:
1.8 stredwic 111: my @who = ($_);
1.17 ! minaeibi 112: next if(&Apache::loncoursedata::DownloadStudentCourseData(\@who, 'true',
! 113: $cacheDB, 'true',
1.8 stredwic 114: 'false', $courseID,
115: $r, $c) ne 'OK');
1.6 stredwic 116: next if($c->aborted());
1.2 stredwic 117:
1.6 stredwic 118: if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
1.8 stredwic 119: my @before=();
120: my @after=();
121: my @updateColumn=();
122: my $foundUpdate = 0;
123: foreach(@$infoKeys) {
124: if(/updateTime/) {
125: $foundUpdate=1;
126: push(@updateColumn, $_);
127: next;
128: }
129: if($foundUpdate) {
130: push(@after, $_);
131: } else {
132: push(@before, $_);
133: }
134: }
1.2 stredwic 135: my $displayString = 'DISPLAYDATA'.$spacing;
136: $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(
137: \%cache, $_,
1.8 stredwic 138: \@before,
139: $displayString,
140: 'preformatted'));
141:
142: if($foundUpdate) {
143: $displayString = '';
144: $displayString .= '<a href="/adm/statistics?reportSelected=';
145: $displayString .= &Apache::lonnet::escape('Student Assessment');
146: $displayString .= '&download='.$_.'">';
147: $displayString .= 'DISPLAYDATA</a>'.$spacing;
148: $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(
149: \%cache, $_,
150: \@updateColumn,
151: $displayString,
152: 'preformatted'));
153: }
154:
155: $displayString = 'DISPLAYDATA'.$spacing;
156: $r->print(&Apache::lonhtmlcommon::FormatStudentInformation(
157: \%cache, $_,
158: \@after,
1.2 stredwic 159: $displayString,
160: 'preformatted'));
161: $r->print(&StudentReport(\%cache, $_, $spacing, $sequenceKeys));
162: $r->print("\n");
1.7 stredwic 163: $r->rflush();
1.1 stredwic 164: untie(%cache);
165: }
166: }
1.16 minaeibi 167:
168:
1.17 ! minaeibi 169: # $r->print("AverageTtal");
! 170: $r->print(&StudentAverageTotal(\%cache, $spacing, $sequenceKeys));
1.16 minaeibi 171: $r->print("\n");
172: $r->rflush();
173: untie(%cache);
174:
175:
1.2 stredwic 176: $r->print('</pre>'."\n");
1.1 stredwic 177: if($selected == 0) {
1.4 stredwic 178: $Str .= '<h3><font color=blue>WARNING: ';
179: $Str .= 'Please select a student</font></h3>';
180: $r->print($Str);
1.1 stredwic 181: }
182:
1.2 stredwic 183: return;
184: }
185:
186: #---- Student Assessment Web Page --------------------------------------------
187:
188: sub CreateInterface {
1.4 stredwic 189: my($cache,$selectedName,$students,$formName,$doNotShow)=@_;
190:
191: my $Str = '';
192: $Str .= &CreateLegend();
193: $Str .= '<table><tr><td>'."\n";
194: $Str .= '<input type="submit" name="PreviousStudent" ';
195: $Str .= 'value="Previous Student" />'."\n";
196: $Str .= '   '."\n";
1.17 ! minaeibi 197: $Str .= &Apache::lonhtmlcommon::StudentOptions($cache, $students,
1.2 stredwic 198: $selectedName,
199: 'StudentAssessment',
200: $formName);
1.4 stredwic 201: $Str .= "\n".'   '."\n";
202: $Str .= '<input type="submit" name="NextStudent" ';
203: $Str .= 'value="Next Student" />'."\n";
204: $Str .= '</td></tr></table>'."\n";
205: $Str .= '<table cellspacing="5"><tr>'."\n";
206: $Str .= '<td align="center"><b>Select Sections</b>'."\n";
207: $Str .= '</td>'."\n";
208: $Str .= '<td align="center"><b>Select column to view:</b></td>'."\n";
209: $Str .= '<td></td></tr>'."\n";
1.3 stredwic 210:
1.4 stredwic 211: $Str .= '<tr><td align="center">'."\n";
1.3 stredwic 212: my @sections = split(':',$cache->{'sectionList'});
213: my @selectedSections = split(':',$cache->{'sectionsSelected'});
1.4 stredwic 214: $Str .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
1.3 stredwic 215: \@selectedSections,
216: 'Statistics');
1.4 stredwic 217: $Str .= '</td><td align="center">';
218: $Str .= &CreateColumnSelectionBox($doNotShow);
219: $Str .= '</td><td>'."\n";
220: $Str .= '<input type="submit" name="DefaultColumns" ';
221: $Str .= 'value="Default Column Display" />'."\n";
222: $Str .= '</td></tr></table>'."\n";
1.2 stredwic 223:
1.4 stredwic 224: return $Str;
1.1 stredwic 225: }
226:
1.2 stredwic 227: sub CreateTableHeadings {
228: my($cache,$spacing,$infoKeys,$infoHeadings,$sequenceKeys,
229: $sequenceHeadings)=@_;
230:
231: my $Str = '';
1.4 stredwic 232: $Str .= '<table border="0" cellpadding="0" cellspacing="0">'."\n";
233:
234: $Str .= '<tr>'."\n";
235: $Str .= &CreateColumnSelectors($infoHeadings, $sequenceHeadings,
236: $sequenceKeys);
237: $Str .= '<td></td></tr>'."\n";
1.2 stredwic 238:
1.4 stredwic 239: $Str .= '<tr>'."\n";
1.2 stredwic 240: my $displayString = '<td align="left"><pre><a href="/adm/statistics?';
241: $displayString .= 'sort=LINKDATA">DISPLAYDATA</a>FORMATTING';
242: $displayString .= $spacing.'</pre></td>'."\n";
1.17 ! minaeibi 243: $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
1.2 stredwic 244: $infoKeys,
245: $infoHeadings,
246: $displayString,
247: 'preformatted');
248:
1.8 stredwic 249: $displayString = '<td align="left"><pre>DISPLAYDATAFORMATTING'.$spacing;
1.2 stredwic 250: $displayString .= '</pre></td>'."\n";
251: $Str .= &Apache::lonhtmlcommon::CreateHeadings($cache,
252: $sequenceKeys,
253: $sequenceHeadings,
254: $displayString,
255: 'preformatted');
256:
257: $Str .= '<td><pre>Total Solved/Total Problems</pre></td>';
258: $Str .= '</tr></table>'."\n";
259:
260: return $Str;
261: }
262:
263: =pod
264:
265: =item &FormatStudentData()
266:
267: First, FormatStudentInformation is called and prefixes the course information.
268: This function produces a formatted string of the student's course information.
269: Each column of data represents all the problems for a given sequence. For
270: valid grade data, a link is created for that problem to a submission record
271: for that problem.
272:
273: =over 4
274:
275: Input: $name, $studentInformation, $ChartDB
276:
277: $name: The name and domain of the current student in name:domain format
278:
279: $studentInformation: A pointer to an array holding the names used to
280: remove data from the hash. They represent
281: the name of the data to be removed.
282:
283: $ChartDB: The name of the cached data database which will be tied to that
284: database.
285:
286: Output: $Str
287:
288: $Str: Formatted string that is an entire row of the chart. It is a
289: concatenation of student information and student course information.
290:
291: =back
292:
293: =cut
1.1 stredwic 294:
295: sub StudentReport {
1.2 stredwic 296: my ($cache,$name,$spacing,$showSequences)=@_;
297: my ($username,$domain)=split(':',$name);
1.1 stredwic 298:
299: my $Str = '';
1.8 stredwic 300: if(defined($cache->{$name.':error'})) {
1.10 stredwic 301: return $Str;
1.8 stredwic 302: }
1.1 stredwic 303: if($cache->{$name.':error'} =~ /course/) {
304: $Str .= '<b><font color="blue">No course data for student </font>';
305: $Str .= '<font color="red">'.$username.'.</font></b><br>';
306: return $Str;
307: }
308:
1.10 stredwic 309: my $hasVersion = 'false';
310: my $hasFinalData = 'false';
1.2 stredwic 311: foreach my $sequence (@$showSequences) {
1.10 stredwic 312: my $hasData = 'false';
1.2 stredwic 313: my $characterCount=0;
1.1 stredwic 314: foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
315: my $problem = $cache->{$problemID.':problem'};
1.2 stredwic 316: # All grades (except for versionless parts) are displayed as links
317: # to their submission record. Loop through all the parts for the
318: # current problem in the correct order and prepare the output links
319: foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
320: ':parts'})) {
1.9 stredwic 321: if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
1.10 stredwic 322: $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
323: $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
1.8 stredwic 324: $Str .= ' ';
1.10 stredwic 325: $characterCount++;
1.8 stredwic 326: next;
1.2 stredwic 327: }
1.10 stredwic 328: $hasVersion = 'true';
329: $hasData = 'true';
1.8 stredwic 330: $Str .= '<a href="/adm/grades?symb=';
331: $Str .= &Apache::lonnet::escape($problem);
332: $Str .= '&student='.$username.'&domain='.$domain;
333: $Str .= '&command=submission">';
334: my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
335: my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
336: if($code eq '*' && $tries < 10 && $tries ne '') {
337: $code = $tries;
1.2 stredwic 338: }
1.8 stredwic 339: $Str .= $code;
1.10 stredwic 340: $Str .= '</a>';
341: $characterCount++;
1.2 stredwic 342: }
343: }
344:
345: # Output the number of correct answers for the current sequence.
1.17 ! minaeibi 346: # This part takes up 6 character slots, but is formated right
! 347: # justified.
! 348: my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
! 349: $spacesNeeded -= 3;
! 350: $Str .= (' 'x$spacesNeeded);
! 351:
! 352: # my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
! 353: # ':problemsCorrect'});
! 354:
! 355: my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
! 356: ':problemsCorrect'},
! 357: $characterCount);
! 358: if($hasData eq 'true') {
! 359: $Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
! 360: $hasFinalData = 'true';
! 361: } else {
! 362: $Str .= '<font color="#007700"> </font>';
! 363: }
! 364: $Str .= $spacing;
! 365: }
! 366:
! 367: # Output the total correct problems over the total number of problems.
! 368: # I don't like this type of formatting, but it is a solution. Need
! 369: # a way to dynamically determine the space requirements.
! 370: my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
! 371: my $outputTotalProblems = sprintf("%4d", $cache->{$name.':totalProblems'});
! 372: if($hasFinalData eq 'true') {
! 373: $Str .= '<font color="#000088">'.$outputProblemsSolved.
! 374: ' / '.$outputTotalProblems.'</font>';
! 375: } else {
! 376: $Str .= '<font color="#000088"> </font>';
! 377: }
! 378:
! 379: if($hasVersion eq 'false') {
! 380: $Str = '<b><font color="blue">No course data.</font></b>';
! 381: }
! 382:
! 383: return $Str;
! 384: }
! 385:
! 386:
! 387: sub StudentAverageTotal {
! 388:
! 389: return "";
! 390:
! 391: my ($cache,$name,$spacing,$showSequences)=@_;
! 392: my $username = $name;
! 393: my $Str = '';
! 394: my $hasVersion = 'false';
! 395: my $hasFinalData = 'false';
! 396: foreach my $sequence (@$showSequences) {
! 397: my $hasData = 'false';
! 398: my $characterCount=0;
! 399: foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
! 400: my $problem = $cache->{$problemID.':problem'};
! 401: # All grades (except for versionless parts) are displayed as links
! 402: # to their submission record. Loop through all the parts for the
! 403: # current problem in the correct order and prepare the output links
! 404: foreach(split(/\:/,$cache->{$sequence.':'.$problemID.
! 405: ':parts'})) {
! 406: if($cache->{$name.':'.$problemID.':NoVersion'} eq 'true' ||
! 407: $cache->{$name.':'.$problemID.':'.$_.':code'} eq ' ' ||
! 408: $cache->{$name.':'.$problemID.':'.$_.':code'} eq '') {
! 409: $Str .= ' ';
! 410: $characterCount++;
! 411: next;
! 412: }
! 413: $hasVersion = 'true';
! 414: $hasData = 'true';
! 415: $Str .= '<a href="/adm/grades?symb=';
! 416: $Str .= &Apache::lonnet::escape($problem);
! 417: $Str .= '&student= Average &domain= Total';
! 418: $Str .= '&command=submission">';
! 419: my $code = $cache->{$name.':'.$problemID.':'.$_.':code'};
! 420: my $tries = $cache->{$name.':'.$problemID.':'.$_.':tries'};
! 421: if($code eq '*' && $tries < 10 && $tries ne '') {
! 422: $code = $tries;
! 423: }
! 424: $Str .= $code;
! 425: $Str .= '</a>';
! 426: $characterCount++;
! 427: }
! 428: }
! 429:
! 430: # Output the number of correct answers for the current sequence.
! 431: # This part takes up 6 character slots, but is formated right
1.2 stredwic 432: # justified.
433: my $spacesNeeded=$cache->{$sequence.':columnWidth'}-$characterCount;
434: $spacesNeeded -= 3;
435: $Str .= (' 'x$spacesNeeded);
436:
1.15 minaeibi 437: # my $outputProblemsCorrect = sprintf("%3d", $cache->{$name.':'.$sequence.
438: # ':problemsCorrect'});
1.14 minaeibi 439:
1.15 minaeibi 440: my $outputProblemsCorrect = sprintf("%2d/%2d", $cache->{$name.':'.$sequence.
1.17 ! minaeibi 441: ':problemsCorrect'},
1.15 minaeibi 442: $characterCount);
1.10 stredwic 443: if($hasData eq 'true') {
444: $Str .= '<font color="#007700">'.$outputProblemsCorrect.'</font>';
445: $hasFinalData = 'true';
446: } else {
1.15 minaeibi 447: $Str .= '<font color="#007700"> </font>';
1.10 stredwic 448: }
1.2 stredwic 449: $Str .= $spacing;
1.1 stredwic 450: }
451:
1.2 stredwic 452: # Output the total correct problems over the total number of problems.
453: # I don't like this type of formatting, but it is a solution. Need
454: # a way to dynamically determine the space requirements.
1.8 stredwic 455: my $outputProblemsSolved = sprintf("%4d", $cache->{$name.':problemsSolved'});
456: my $outputTotalProblems = sprintf("%4d", $cache->{$name.':totalProblems'});
1.10 stredwic 457: if($hasFinalData eq 'true') {
458: $Str .= '<font color="#000088">'.$outputProblemsSolved.
1.2 stredwic 459: ' / '.$outputTotalProblems.'</font>';
1.10 stredwic 460: } else {
461: $Str .= '<font color="#000088"> </font>';
462: }
463:
464: if($hasVersion eq 'false') {
465: $Str = '<b><font color="blue">No course data.</font></b>';
466: }
1.1 stredwic 467:
468: return $Str;
469: }
470:
1.17 ! minaeibi 471:
! 472:
1.2 stredwic 473: =pod
474:
475: =item &CreateLegend()
476:
477: This function returns a formatted string containing the legend for the
478: chart. The legend describes the symbols used to represent grades for
479: problems.
480:
481: =cut
482:
483: sub CreateLegend {
484: my $Str = "<p><pre>".
1.13 minaeibi 485: " 1 correct by student in 1 try\n".
486: " 7 correct by student in 7 tries\n".
1.12 minaeibi 487: " * correct by student in more than 9 tries\n".
488: " + correct by override\n".
489: " - incorrect by override\n".
490: " . incorrect attempted\n".
491: " # ungraded attempted\n".
1.13 minaeibi 492: " not attempted (blank field)\n".
1.12 minaeibi 493: " x excused".
1.17 ! minaeibi 494: "</pre><p>";
1.2 stredwic 495: return $Str;
496: }
497:
498: =pod
499:
500: =item &CreateColumnSelectionBox()
501:
502: If there are columns not being displayed then this selection box is created
1.17 ! minaeibi 503: with a list of those columns. When selections are made and the page
1.2 stredwic 504: refreshed, the columns will be removed from this box and the column is
505: put back in the chart. If there is no columns to select, no row is added
506: to the interface table.
507:
508: =over 4
509: Input: $CacheData, $headings
510:
511:
512: $CacheData: A pointer to a hash tied to the cached data
513:
1.17 ! minaeibi 514: $headings: An array of the names of the columns for the student information.
1.2 stredwic 515: They are used for displaying which columns are missing.
516:
517: Output: $notThere
518:
1.17 ! minaeibi 519: $notThere: The string contains one row of a table. The first column has the
! 520: name of the selection box. The second contains the selection box
1.2 stredwic 521: which has a size of four.
522:
523: =back
524:
525: =cut
526:
527: sub CreateColumnSelectionBox {
1.4 stredwic 528: my ($doNotShow)=@_;
1.2 stredwic 529:
1.4 stredwic 530: my $notThere = '';
531: $notThere .= '<select name="ReselectColumns" size="4" ';
532: $notThere .= 'multiple="true">'."\n";
533:
534: for(my $index=0; $index<$doNotShow->{'count'}; $index++) {
535: my $name = $doNotShow->{$index.':name'};
536: $notThere .= '<option value="';
537: $notThere .= $doNotShow->{$index.':id'}.'">';
1.2 stredwic 538: $notThere .= $name.'</option>'."\n";
539: }
540:
1.4 stredwic 541: $notThere .= '</select>';
1.2 stredwic 542:
1.4 stredwic 543: return $notThere;
1.2 stredwic 544: }
545:
546: =pod
547:
548: =item &CreateColumnSelectors()
549:
1.17 ! minaeibi 550: This function generates the checkboxes above the column headings. The
1.2 stredwic 551: column will be removed if the checkbox is unchecked.
552:
553: =over 4
554:
555: Input: $CacheData, $headings
556:
557: $CacheData: A pointer to a hash tied to the cached data
558:
559: $headings: An array of the names of the columns for the student
560: information. They are used to know what are the student information columns
561:
562: Output: $present
563:
564: $present: The string contains the first row of a table. Each column contains
565: a checkbox which is left justified. Currently left justification is used
566: for consistency of location over the column in which it presides.
567:
568: =back
569:
570: =cut
571:
572: sub CreateColumnSelectors {
1.4 stredwic 573: my ($infoHeadings, $sequenceHeadings, $sequenceKeys)=@_;
1.2 stredwic 574:
1.4 stredwic 575: my $present = '';
576: for(my $index=0; $index<(scalar @$infoHeadings); $index++) {
1.2 stredwic 577: $present .= '<td align="left">';
578: $present .= '<input type="checkbox" checked="on" ';
1.4 stredwic 579: $present .= 'name="HeadingColumn'.$infoHeadings->[$index].'" />';
580: $present .= '</td>'."\n";
1.2 stredwic 581: }
582:
1.4 stredwic 583: for(my $index=0; $index<(scalar @$sequenceHeadings); $index++) {
1.2 stredwic 584: $present .= '<td align="left">';
585: $present .= '<input type="checkbox" checked="on" ';
1.4 stredwic 586: $present .= 'name="SequenceColumn'.$sequenceKeys->[$index].'" />';
587: $present .= '</td>'."\n";
1.2 stredwic 588: }
589:
1.4 stredwic 590: return $present;
1.2 stredwic 591: }
592:
1.1 stredwic 593: #---- END Student Assessment Web Page ----------------------------------------
1.2 stredwic 594:
595: #---- Student Assessment Worker Functions ------------------------------------
596:
597: sub FindSelectedStudent {
598: my($cache, $selectedName, $students)=@_;
1.3 stredwic 599:
1.17 ! minaeibi 600: if($selectedName eq 'All Students' ||
1.3 stredwic 601: $selectedName eq 'No Student Selected') {
602: return $selectedName;
603: }
604:
605: for(my $index=0; $index<(scalar @$students); $index++) {
1.2 stredwic 606: my $fullname = $cache->{$students->[$index].':fullname'};
607: if($fullname eq $selectedName) {
608: if($cache->{'StudentAssessmentMove'} eq 'next') {
609: if($index == ((scalar @$students) - 1)) {
610: $selectedName = $students->[0];
1.3 stredwic 611: return $selectedName;
1.2 stredwic 612: } else {
613: $selectedName = $students->[$index+1];
1.3 stredwic 614: return $selectedName;
1.2 stredwic 615: }
616: } elsif($cache->{'StudentAssessmentMove'} eq 'previous') {
617: if($index == 0) {
618: $selectedName = $students->[-1];
1.3 stredwic 619: return $selectedName;
1.2 stredwic 620: } else {
621: $selectedName = $students->[$index-1];
1.3 stredwic 622: return $selectedName;
1.2 stredwic 623: }
624: } else {
625: $selectedName = $students->[$index];
1.3 stredwic 626: return $selectedName;
1.2 stredwic 627: }
628: last;
629: }
630: }
631:
1.3 stredwic 632: return 'No Student Selected';
1.2 stredwic 633: }
634:
635: =pod
636:
637: =item &ShouldShowColumn()
638:
639: Determine if a specified column should be shown on the chart.
640:
641: =over 4
642:
643: Input: $cache, $test
644:
645: $cache: A pointer to the hash tied to the cached data
646:
647: $test: The form name of the column (heading.$headingIndex) or
648: (sequence.$sequenceIndex)
649:
650: Output: 0 (false), 1 (true)
651:
652: =back
653:
654: =cut
655:
656: sub ShouldShowColumns {
657: my ($cache,$headings,$cacheKey)=@_;
658:
659: my @infoKeys=();
660: my @infoHeadings=();
661:
662: my @sequenceKeys=();
663: my @sequenceHeadings=();
664:
1.4 stredwic 665: my %doNotShow;
666:
1.2 stredwic 667: my $index;
1.4 stredwic 668: my $count = 0;
669: my $check = '';
1.2 stredwic 670: for($index=0; $index < scalar @$headings; $index++) {
1.4 stredwic 671: $check = 'HeadingColumn'.$headings->[$index];
672: if($cache->{'HeadingsFound'} =~ /$check/) {
673: push(@infoHeadings, $headings->[$index]);
674: push(@infoKeys, $cacheKey->[$index]);
675: } else {
676: $doNotShow{$count.':name'} = $headings->[$index];
677: $doNotShow{$count.':id'} = 'HeadingColumn'.$headings->[$index];
678: $count++;
679: }
1.2 stredwic 680: }
681:
682: foreach my $sequence (split(/\:/,$cache->{'orderedSequences'})) {
1.4 stredwic 683: $check = 'SequenceColumn'.$sequence;
684: if($cache->{'SequencesFound'} eq 'All Sequences' ||
685: $cache->{'SequencesFound'} =~ /$check/) {
686: push(@sequenceHeadings, $cache->{$sequence.':title'});
687: push(@sequenceKeys, $sequence);
688: } else {
689: $doNotShow{$count.':name'} = $cache->{$sequence.':title'};
690: $doNotShow{$count.':id'} = 'SequenceColumn'.$sequence;
691: $count++;
692: }
1.2 stredwic 693: }
694:
1.4 stredwic 695: $doNotShow{'count'} = $count;
1.2 stredwic 696:
697: return (\@infoHeadings, \@infoKeys, \@sequenceHeadings,
1.4 stredwic 698: \@sequenceKeys, \%doNotShow);
1.2 stredwic 699: }
700:
701: #---- END Student Assessment Worker Functions --------------------------------
702:
1.1 stredwic 703: 1;
704: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>