[system] / trunk / webwork / system / cgi / cgi-scripts / classlist.pl Repository:
ViewVC logotype

Annotation of /trunk/webwork/system/cgi/cgi-scripts/classlist.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download) (as text)

1 : sam 2 #!/usr/bin/perl
2 :    
3 :     ## $Id$
4 :    
5 :     use lib '/ww/webwork/development/'; # mainWeBWorKDirectory;
6 :    
7 :     use Global;
8 :     use CGI qw(:standard);
9 :     use Auth;
10 :     use strict;
11 :    
12 :     # begin Timing code
13 :     use Benchmark;
14 :     my $beginTime = new Benchmark;
15 :     # end Timing code
16 :    
17 :     # local($cgi) = new CGI_Lite();
18 :     # local(%inputs) = $cgi->parse_form_data();
19 :     &CGI::ReadParse;
20 :     my %inputs=%main::in;
21 :    
22 :    
23 :     &Global::getCourseEnvironment($inputs{'course'});
24 :    
25 :     my $scriptDirectory = $Global::scriptDirectory;
26 :     my $databaseDirectory = $Global::databaseDirectory;
27 :     my $htmlURL = $Global::htmlURL;
28 :     my $cgiURL = getWebworkCgiURL;
29 :    
30 :     require "${scriptDirectory}$Global::DBglue_pl";
31 :     require "${scriptDirectory}HTMLglue.pl";
32 :     require "${scriptDirectory}$Global::FILE_pl";
33 :    
34 :     # log access
35 :     &Global::log_info('', query_string);
36 :    
37 :    
38 :     my $keyFile = &Global::getCourseKeyFile($inputs{'course'});
39 :     &verify_key($inputs{'user'}, $inputs{'key'}, "$keyFile", $inputs{'course'});
40 :    
41 :     my $permissionsFile = &Global::getCoursePermissionsFile($inputs{'course'});
42 :     my $permissions = &get_permissions($inputs{'user'}, $permissionsFile);
43 :    
44 :     if (($permissions != $Global::instructor_permissions) and ($permissions != $Global::TA_permissions) ) {
45 :     print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n";
46 :     print &html_NO_PERMISSION;
47 :     exit(0);
48 :     }
49 :    
50 :     ###############################################################################
51 :     #unless ($inputs{'pCL'}) {
52 :     #
53 :     # print &htmlTOP("Classlist: Set Selection for course $inputs{'course'}");
54 :     # print <<EOF;
55 :     #<H3 align="center">Welcome to the View Classlist Page</H3>
56 :     #On this page, you may choose a problem set whose classlist you would like to view.
57 :     #<p><HR>
58 :     #Choose a problem set:
59 :     #EOF
60 :     #
61 :     # print "<form action=\"${cgiURL}classlist.pl\" METHOD = \"POST\">\n";
62 :     # my %setNumberHash=&getAllProbSetNumbersHash(
63 :     # $inputs {'user'});
64 :     # &printProbSetsJR("setNo",\%setNumberHash);
65 :     #
66 :     # print "<input type=\"hidden\" name=\"pCL\" value=1>\n";
67 :     # print &sessionKeyInputs(\%inputs);
68 :     # print "<br><input type=\"submit\" value=\"Get Classlist\"></form>";
69 :     # print &htmlBOTTOM("classlist.pl", \%inputs);
70 :     # # begin Timing code
71 :     # my $endTime = new Benchmark;
72 :     # &Global::logTimingInfo($beginTime,$endTime,"classlist.pl",$inputs{'course'},$inputs{'user'});
73 :     # # end Timing code
74 :     # exit;
75 :     #}
76 :     ###############################################################################
77 :    
78 :     print &htmlTOP("Roster for the course $inputs{'course'}, set number $inputs{'setNo'}");
79 :     print <<END_OF_HTML;
80 :    
81 :     <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}">
82 :     <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p>
83 :     <H3 ALIGN ="CENTER"> Roster and scores for $inputs{'course'}, set $inputs{'setNo'}</H3>
84 :     Click on student's name to see the student's version of the problem set. A period (.) indicates a problem
85 :     has not been attempted, a "C" indicates a problem has been answered 100% correctly, and a number from 0 to 99
86 :     indicates the percentage of partial credit earned. The number on the second line gives the number of incorrect attempts.
87 :     <HR SIZE =2>
88 :     END_OF_HTML
89 :    
90 :     # Dump the contents of the DBM files:
91 :    
92 :     my ($setNum,$psvn,$percentRight,@keyList);
93 :    
94 :     $setNum=$inputs{'setNo'};
95 :     my $sortOrder =$inputs{'sortOrder'};
96 :    
97 :     if ($sortOrder eq 'byCourse') {
98 :     @keyList = &getAllProbSetKeysForSetSortedByName($setNum);
99 :     }
100 :     elsif ($sortOrder eq 'byRecitation') {
101 :     @keyList = &getAllProbSetKeysForSetSortedByRecitationThenByName($setNum);
102 :     }
103 :     else {
104 :     @keyList = &getAllProbSetKeysForSetSortedBySectionThenByName($setNum);
105 :     }
106 :     my ($key,$id,$lname,$fname,$login_name,@problems,$string,$twoString,@tempSort,
107 :     $total,$totalRight,$status,$longStatus,$valid_status, $attempted,$probValue,$num,$classSection,$classRecitation,$incorrect,$i);
108 :    
109 :    
110 :     print <<EOF;
111 :     <TABLE border>
112 :     <TR>
113 :     <TD ALIGN=center COLSPAN=2>Name</TD>
114 :     <TD ALIGN=center>psvn</TD>
115 :     <TD ALIGN=center>Score</TD>
116 :     <TD ALIGN=center>Out<BR>of</TD>
117 :     EOF
118 :    
119 :     ##get number of problems
120 :     &attachProbSetRecord($keyList[0]);
121 :     @problems = &getAllProblemsForProbSetRecord($key);
122 :     my $noOfProbs = @problems;
123 :     $string = '<TD ALIGN=center> Problems <BR>';
124 :     $twoString = '';
125 :     for ($i=1; $i <= $noOfProbs;$i++) {
126 :     $twoString .= &threeSpaceFill($i);
127 :     }
128 :     $string .= "<pre>$twoString</pre></TD>";
129 :     print "$string";
130 :    
131 :     print <<EOF;
132 :     <TD ALIGN=center>section</TD>
133 :     <TD ALIGN=center>recitation</TD>
134 :     <TD ALIGN=center>login_name</TD>
135 :     <TD ALIGN=center>studentId</TD>
136 :     </TR>
137 :     EOF
138 :    
139 :    
140 :     foreach $key (@keyList) {
141 :     &attachProbSetRecord($key)|| print "no Record $key\n";
142 :     $id = &getStudentID($key);
143 :     $lname = &getStudentLastName($key);
144 :     $fname = &getStudentFirstName($key);
145 :     $login_name = &getStudentLogin($key);
146 :     $classSection = &getClassSection($key);
147 :     $classRecitation = &getClassRecitation($key);
148 :    
149 :     # replace empty strings by a non breaking space
150 :     $classSection = '&nbsp;' unless ($classSection =~ /\S/);
151 :     $classRecitation = '&nbsp;' unless ($classRecitation =~ /\S/);
152 :    
153 :     # $psvn = $key;
154 :     @problems = &getAllProblemsForProbSetRecord($key);
155 :     $string = '';
156 :     $twoString ='';
157 :     @tempSort = sort( { $a <=> $b } @problems);
158 :     $total=0; $totalRight = 0;
159 :     disable diagnostics; ## surpress warning caused by ($problemStatus == 0 and $problemStatus ne '0')
160 :     foreach $num (@tempSort) {
161 :     $valid_status = 0;
162 :     $status = &getProblemStatus($num,$key);
163 :     $attempted = getProblemAttempted($num,$key);
164 :    
165 :     if (!$attempted){
166 :     $longStatus = '. ';
167 :     }
168 :     elsif ($status >= 0 and $status <=1 ) {
169 :     $valid_status = 1;
170 :     $longStatus = int(100*$status+.5);
171 :     if ($longStatus == 100) {
172 :     $longStatus = 'C ';
173 :     }
174 :     else {
175 :     $longStatus = &threeSpaceFill($longStatus);
176 :     }
177 :     }
178 :     else {
179 :     $longStatus = 'X ';
180 :     }
181 :    
182 :     $incorrect = getProblemNumOfIncorrectAns($num,$key);
183 :     $incorrect = min($incorrect,99);
184 :     $string .= $longStatus;
185 :     $twoString .= &threeSpaceFill($incorrect);
186 :     $probValue = &getProblemValue($num,$key);
187 :     $total += $probValue;
188 :     $totalRight += round_score($status*$probValue) if $valid_status;
189 :     }
190 :     # save original from 3 lines down
191 :     # <TD ALIGN=left><A HREF="$Global::welcomeAction_CGI?action=Do_problem_set&user=$inputs{'user'}&course=$inputs{'course'}&key=$inputs{'key'}&probSetKey=$key">$lname</A></TD>
192 :    
193 :     print <<EOF;
194 :     <TR>
195 :     <TD ALIGN=left><A HREF="$Global::welcomeAction_CGI?action=Do_problem_set&user=$inputs{'user'}&course=$inputs{'course'}&key=$inputs{'key'}&local_psvns=$key">$lname</A></TD>
196 :     <TD ALIGN=left>$fname</TD>
197 :     <TD ALIGN=left>$key</TD>
198 :     <TD ALIGN=left>$totalRight</TD>
199 :     <TD ALIGN=left>$total</TD>
200 :     <TD ALIGN=left><pre>$string
201 :     $twoString</pre></TD>
202 :     <TD ALIGN=left>$classSection</TD>
203 :     <TD ALIGN=left>$classRecitation</TD>
204 :     <TD ALIGN=left>$login_name</TD>
205 :     <TD ALIGN=left>$id</TD>
206 :     </TR>
207 :     EOF
208 :    
209 :     }
210 :    
211 :     print "</TABLE><BR>";
212 :    
213 :     print &htmlBOTTOM("classlist.pl", \%inputs, 'classlistHelp.html');
214 :    
215 :     exit(0);
216 :    
217 :     ## subroutines
218 :     sub threeSpaceFill {
219 :     my $num = shift @_;
220 :     if ($num < 10) {return "$num".' ';}
221 :     elsif ($num < 100) {return "$num".' ';}
222 :     else {return "$num";}
223 :     }
224 :    
225 :    

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9