File:
[LON-CAPA] /
loncom /
interface /
statistics /
lonstudentassessment.pm
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Wed Jul 24 14:52:32 2002 UTC (21 years, 11 months ago) by
stredwic
Branches:
MAIN
CVS tags:
HEAD
Broke lonstatistics up. Now the bulk of the code that generate the
html pages for the different forms have there own module. Some minor
modifications were necessary to accomplish this.
Also added default student selected on student assessment page is now
all students. The full name links on the classlist page now take
you to the student assessment page with that student selected. I
had forgotten to put the post data in the get_unprocessed_cgi
function call.
1: # The LearningOnline Network with CAPA
2: # (Publication Handler
3: #
4: # $Id: lonstudentassessment.pm,v 1.1 2002/07/24 14:52:32 stredwic Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: # (Navigate problems for statistical reports
29: # YEAR=2001
30: # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
31: # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
32: # YEAR=2002
33: # 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
34: # 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei
35: #
36: ###
37:
38: package Apache::lonstudentassessment;
39:
40: use strict;
41: use Apache::lonhtmlcommon;
42: use Apache::loncoursedata;
43: use GDBM_File;
44:
45: sub BuildStudentAssessmentPage {
46: my ($cacheDB, $students, $courseID, $c)=@_;
47:
48: my %cache;
49:
50: my $Ptr = '';
51: $Ptr .= '<table border="0"><tbody>';
52:
53: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
54: return '<html><body>Unable to tie database.</body></html>';
55: }
56:
57: my $selectedName = $cache{'StudentAssessmentStudent'};
58: for(my $index=0;
59: ($selectedName ne 'All Students') && ($index<(scalar @$students));
60: $index++) {
61: my $fullname = $cache{$students->[$index].':fullname'};
62: if($fullname eq $selectedName) {
63: if($cache{'StudentAssessmentMove'} eq 'next') {
64: if($index == ((scalar @$students) - 1)) {
65: $selectedName = $students->[0];
66: } else {
67: $selectedName = $students->[$index+1];
68: }
69: } elsif($cache{'StudentAssessmentMove'} eq 'previous') {
70: if($index == 0) {
71: $selectedName = $students->[-1];
72: } else {
73: $selectedName = $students->[$index-1];
74: }
75: } else {
76: $selectedName = $students->[$index];
77: }
78: last;
79: }
80: }
81:
82: $Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";
83: $Ptr .= '<td align="left">';
84: $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'StudentAssessment');
85: $Ptr .= '</td></tr>'."\n";
86: $Ptr .= '<tr><td align="right"><b>Select Student</b></td>'."\n";
87: $Ptr .= '<td align="left">'."\n";
88: $Ptr .= &Apache::lonhtmlcommon::StudentOptions(\%cache, $students,
89: $selectedName,
90: 'StudentAssessment');
91: $Ptr .= '</td></tr>'."\n";
92: untie(%cache);
93:
94: $Ptr .= '<tr><td></td><td align="left">';
95: $Ptr .= '<input type="submit" name="CreateStudentAssessment" ';
96: $Ptr .= 'value="Create Student Report" />';
97: $Ptr .= '   ';
98: $Ptr .= '<input type="submit" name="PreviousStudent" ';
99: $Ptr .= 'value="Previous Student" />';
100: $Ptr .= '   ';
101: $Ptr .= '<input type="submit" name="NextStudent" ';
102: $Ptr .= 'value="Next Student" />';
103: $Ptr .= '   ';
104: $Ptr .= '</td></tr></tbody></table>'."\n";
105:
106: if($selectedName eq 'No Student Selected') {
107: $Ptr .= '<h3><font color=blue>WARNING: ';
108: $Ptr .= 'Please select a student</font></h3>';
109: return $Ptr;
110: }
111:
112: my $selected=0;
113: foreach (@$students) {
114: next if ($_ ne $selectedName &&
115: $selectedName ne 'All Students');
116: $selected = 1;
117: my $courseData =
118: &Apache::loncoursedata::DownloadCourseInformation($_, $courseID);
119: last if ($c->aborted());
120: if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
121: &Apache::loncoursedata::ProcessStudentData(\%cache,
122: $courseData, $_);
123: if(!$c->aborted()) { $Ptr .= &StudentReport(\%cache, $_); }
124: untie(%cache);
125: }
126: }
127: if($selected == 0) {
128: $Ptr .= '<h3><font color=blue>WARNING: ';
129: $Ptr .= 'Please select a student</font></h3>';
130: }
131:
132: return $Ptr;
133: }
134:
135: #---- Student Assessment Web Page --------------------------------------------
136:
137: # ------ Create different Student Report
138: sub StudentReport {
139: my ($cache, $name)=@_;
140:
141: my $Str = '';
142: if($cache->{$name.':error'} =~ /course/) {
143: my ($username)=split(':',$name);
144: $Str .= '<b><font color="blue">No course data for student </font>';
145: $Str .= '<font color="red">'.$username.'.</font></b><br>';
146: return $Str;
147: }
148:
149: $Str .= "<table border=2><tr><th> \# </th><th> Set Title </th>";
150: $Str .= '<th> Results </th><th> Tries </th></tr>'."\n";
151:
152: my $codes;
153: my $attempts;
154: foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
155: if($cache->{'StudentAssessmentMap'} ne 'All Maps' &&
156: $cache->{'StudentAssessmentMap'} ne $cache->{$sequence.':title'}) {
157: next;
158: }
159:
160: $Str .= '<tr><td>'.$sequence.'</td>';
161: $Str .= '<td>'.$cache->{$sequence.':title'}.'</td>';
162:
163: $codes = '';
164: $attempts = '';
165: foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
166: my $problem = $cache->{$problemID.':problem'};
167: my $LatestVersion = $cache->{$name.':version:'.$problem};
168:
169: # Output dashes for all the parts of this problem if there
170: # is no version information about the current problem.
171: if(!$LatestVersion) {
172: foreach my $part (split(/\:/,$cache->{$sequence.':'.
173: $problemID.
174: ':parts'})) {
175: $codes .= "-,";
176: $attempts .= "0,";
177: }
178: next;
179: }
180:
181: my %partData=undef;
182: # Initialize part data, display skips correctly
183: # Skip refers to when a student made no submissions on that
184: # part/problem.
185: foreach my $part (split(/\:/,$cache->{$sequence.':'.
186: $problemID.
187: ':parts'})) {
188: $partData{$part.':tries'}=0;
189: $partData{$part.':code'}='-';
190: }
191:
192: # Looping through all the versions of each part, starting with the
193: # oldest version. Basically, it gets the most recent
194: # set of grade data for each part.
195: for(my $Version=1; $Version<=$LatestVersion; $Version++) {
196: foreach my $part (split(/\:/,$cache->{$sequence.':'.
197: $problemID.
198: ':parts'})) {
199:
200: if(!defined($cache->{$name.":$Version:$problem".
201: ":resource.$part.solved"})) {
202: # No grade for this submission, so skip
203: next;
204: }
205:
206: my $tries=0;
207: my $code='U';
208:
209: $tries = $cache->{$name.":$Version:$problem".
210: ":resource.$part.tries"};
211: $partData{$part.':tries'}=($tries) ? $tries : 0;
212:
213: my $val = $cache->{$name.":$Version:$problem".
214: ":resource.$part.solved"};
215: if ($val eq 'correct_by_student') {$code = 'Y';}
216: elsif ($val eq 'correct_by_override') {$code = 'y';}
217: elsif ($val eq 'incorrect_attempted') {$code = 'N';}
218: elsif ($val eq 'incorrect_by_override'){$code = 'N';}
219: elsif ($val eq 'excused') {$code = 'x';}
220: $partData{$part.':code'}=$code;
221: }
222: }
223:
224: # Loop through all the parts for the current problem in the
225: # correct order and prepare the output
226: foreach (split(/\:/,$cache->{$sequence.':'.$problemID.
227: ':parts'})) {
228: $codes .= $partData{$_.':code'}.',';
229: $attempts .= $partData{$_.':tries'}.',';
230: }
231: }
232: $codes =~ s/,$//;
233: $attempts =~ s/,$//;
234: $Str .= '<td>'.$codes.'</td>';
235: $Str .= '<td>'.$attempts.'</td>';
236: $Str .= '</tr>'."\n";
237: }
238:
239: $Str .= '</table>'."\n";
240:
241: return $Str;
242: }
243:
244: #---- END Student Assessment Web Page ----------------------------------------
245: 1;
246: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>