Annotation of loncom/homework/grades.pm, revision 1.45
1.17 albertel 1: # The LearningOnline Network with CAPA
1.13 albertel 2: # The LON-CAPA Grading handler
1.17 albertel 3: #
1.45 ! ng 4: # $Id: grades.pm,v 1.44 2002/08/02 21:10:03 ng Exp $
1.17 albertel 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: #
1.13 albertel 28: # 2/9,2/13 Guy Albertelli
1.8 www 29: # 6/8 Gerd Kortemeyer
1.13 albertel 30: # 7/26 H.K. Ng
1.14 www 31: # 8/20 Gerd Kortemeyer
1.30 ng 32: # Year 2002
1.44 ng 33: # June-August H.K. Ng
1.30 ng 34: #
1.1 albertel 35:
36: package Apache::grades;
37: use strict;
38: use Apache::style;
39: use Apache::lonxml;
40: use Apache::lonnet;
1.3 albertel 41: use Apache::loncommon;
1.1 albertel 42: use Apache::lonhomework;
1.38 ng 43: use Apache::lonmsg qw(:user_normal_msg);
1.1 albertel 44: use Apache::Constants qw(:common);
45:
1.44 ng 46: # ----- These first few routines are general use routines.-----
47: #
1.45 ! ng 48:
! 49: sub print_hash {
! 50: my ($request, $hash) = @_;
! 51: $request->print('<table border=1><tr><td>Key</td><td>Value</td></tr>');
! 52: for (sort keys (%$hash)) {
! 53: $request->print('<tr><td>'.$_.'</td><td>'.$$hash{$_}.' </td></tr>');
! 54: }
! 55: $request->print('</table>');
! 56: return '';
! 57: }
! 58:
1.44 ng 59: # --- Retrieve the parts that matches stores_\d+ from the metadata file.---
60: sub getpartlist {
61: my ($url) = @_;
62: my @parts =();
63: my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys'));
64: foreach my $key (@metakeys) {
65: if ( $key =~ m/stores_([0-9]+)_.*/) {
66: push(@parts,$key);
1.41 ng 67: }
1.16 albertel 68: }
1.44 ng 69: return @parts;
1.2 albertel 70: }
71:
1.44 ng 72: # --- Get the symbolic name of a problem and the url
73: sub get_symb_and_url {
74: my ($request) = @_;
75: (my $url=$ENV{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.41 ng 76: my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
1.44 ng 77: if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
78: return ($symb,$url);
1.32 ng 79: }
80:
1.44 ng 81: # --- Retrieve the fullname for a user. Return lastname, first middle ---
82: # --- Generation is attached next to the lastname if it exists. ---
1.34 ng 83: sub get_fullname {
1.39 ng 84: my ($uname,$udom) = @_;
1.34 ng 85: my %name=&Apache::lonnet::get('environment', ['lastname','generation',
1.41 ng 86: 'firstname','middlename'],$udom,$uname);
1.34 ng 87: my $fullname;
88: my ($tmp) = keys(%name);
89: if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
90: $fullname=$name{'lastname'}.$name{'generation'};
91: if ($fullname =~ /[^\s]+/) { $fullname.=', '; }
92: $fullname.=$name{'firstname'}.' '.$name{'middlename'};
93: }
94: return $fullname;
95: }
96:
1.44 ng 97: #--- Get the partlist and the response type for a given problem. ---
98: #--- Indicate if a response type is coded handgraded or not. ---
1.39 ng 99: sub response_type {
1.41 ng 100: my ($url) = shift;
101: my $allkeys = &Apache::lonnet::metadata($url,'keys');
102: my %seen = ();
103: my (@partlist,%handgrade);
104: foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
1.43 ng 105: if (/^\w+response_\d+.*/) {
1.41 ng 106: my ($responsetype,$part) = split(/_/,$_,2);
107: my ($partid,$respid) = split(/_/,$part);
108: $handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no');
109: next if ($seen{$partid} > 0);
110: $seen{$partid}++;
111: push @partlist,$partid;
112: }
113: }
114: return \@partlist,\%handgrade;
1.39 ng 115: }
116:
1.44 ng 117: #--- Prints a message on screen if a user did something wrong
118: #--- Operator error ---
119: sub userError {
120: my ($request, $reason, $step) = @_;
121: $request->print('<h3><font color="red">LON-CAPA User Error</font></h3><br />'."\n");
122: $request->print('<b>Reason: </b>'.$reason.'<br /><br />'."\n");
123: $request->print('<b>Step: </b>'.($step ne '' ? $step : 'Use your browser back button to correct')
124: .'<br /><br />'."\n");
125: return '';
126: }
127:
128: #--- Dumps the class list with usernames,list of sections,
129: #--- section, ids and fullnames for each user.
130: sub getclasslist {
131: my ($getsec,$hideexpired) = @_;
132: my $now = time;
133: my %classlist=&Apache::lonnet::dump('classlist',
134: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
135: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
136: # codes to check for fields in the classlist
137: # should contain end:start:id:section:fullname
138: for (keys %classlist) {
139: my (@fields) = split(/:/,$classlist{$_});
140: %classlist = &reformat_classlist(\%classlist) if (scalar(@fields) <= 2);
141: last;
142: }
143:
144: my (@holdsec,@sections,%allids,%stusec,%fullname);
145: foreach (keys(%classlist)) {
146: my ($end,$start,$id,$section,$fullname)=split(/:/,$classlist{$_});
147: # still a student?
148: if (($hideexpired) && ($end) && ($end < $now)) {
149: next;
150: }
151: $section = ($section ne '' ? $section : 'no');
152: push @holdsec,$section;
153: if ($getsec eq 'all' || $getsec eq $section) {
154: push (@{ $classlist{$getsec} }, $_);
155: $allids{$_} =$id;
156: $stusec{$_} =$section;
157: $fullname{$_}=$fullname;
158: }
159: }
160: my %seen = ();
161: foreach my $item (@holdsec) {
162: push (@sections, $item) unless $seen{$item}++;
163: }
164: return (\%classlist,\@sections,\%allids,\%stusec,\%fullname);
165: }
166:
167: # add id, section and fullname to the classlist.db
168: # done to maintain backward compatibility with older versions
169: sub reformat_classlist {
170: my ($classlist) = shift;
171: foreach (sort keys(%$classlist)) {
172: my ($unam,$udom) = split(/:/);
173: my $section = &Apache::lonnet::usection($udom,$unam,$ENV{'request.course.id'});
174: my $fullname = &get_fullname ($unam,$udom);
175: my %userid = &Apache::lonnet::idrget($udom,($unam));
176: $$classlist{$_} = $$classlist{$_}.':'.$userid{$unam}.':'.$section.':'.$fullname;
177: }
178: my $putresult = &Apache::lonnet::put
179: ('classlist',\%$classlist,
180: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
181: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
182:
183: return %$classlist;
184: }
185:
186: #find user domain
187: sub finduser {
188: my ($name) = @_;
189: my $domain = '';
190: if ( $Apache::grades::viewgrades eq 'F' ) {
191: my %classlist=&Apache::lonnet::dump('classlist',
192: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
193: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
194: my (@fields) = grep /^$name:/, keys %classlist;
195: ($name, $domain) = split(/:/,$fields[0]);
196: return ($name,$domain);
197: } else {
198: return ($ENV{'user.name'},$ENV{'user.domain'});
199: }
200: }
201:
202: #--- Prompts a user to enter a username.
203: sub moreinfo {
204: my ($request,$reason) = @_;
205: $request->print("Unable to process request: $reason");
206: if ( $Apache::grades::viewgrades eq 'F' ) {
207: $request->print('<form action="/adm/grades" method="post">'."\n");
208: if ($ENV{'form.url'}) {
209: $request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />'."\n");
210: }
211: if ($ENV{'form.symb'}) {
212: $request->print('<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'."\n");
213: }
214: $request->print('<input type="hidden" name="command" value="'.$ENV{'form.command'}.'" />'."\n");
215: $request->print("Student:".'<input type="text" name="student" value="'.$ENV{'form.student'}.'" />'."<br />\n");
216: $request->print("Domain:".'<input type="text" name="domain" value="'.$ENV{'user.domain'}.'" />'."<br />\n");
217: $request->print('<input type="submit" name="submit" value="ReSubmit" />'."<br />\n");
218: $request->print('</form>');
219: }
220: return '';
221: }
222:
223: #--- Retrieve the grade status of a student for all the parts
224: sub student_gradeStatus {
225: my ($url,$symb,$udom,$uname,$partlist) = @_;
226: my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
227: my %partstatus = ();
228: foreach (@$partlist) {
229: my ($status,$foo) = split(/_/,$record{"resource.$_.solved"},2);
230: $status = 'nothing' if ($status eq '');
231: $partstatus{$_} = $status;
232: my $subkey = "resource.$_.submitted_by";
233: $partstatus{$subkey} = $record{$subkey} if ($record{$subkey} ne '');
234: }
235: return %partstatus;
236: }
237:
1.45 ! ng 238: # hidden form and javascript that calls the form
! 239: # Use by verifyscript and viewgrades
! 240: # Shows a student's view of problem and submission
! 241: sub jscriptNform {
! 242: my ($url,$symb) = @_;
! 243: my $jscript='<script type="text/javascript" language="javascript">'."\n".
! 244: ' function viewOneStudent(user,domain) {'."\n".
! 245: ' document.onestudent.student.value = user;'."\n".
! 246: ' document.onestudent.userdom.value = domain;'."\n".
! 247: ' document.onestudent.submit();'."\n".
! 248: ' }'."\n".
! 249: '</script>'."\n";
! 250: $jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n".
! 251: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
! 252: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
! 253: '<input type="hidden" name="command" value="submission" />'."\n".
! 254: '<input type="hidden" name="student" value="" />'."\n".
! 255: '<input type="hidden" name="userdom" value="" />'."\n".
! 256: '</form>'."\n";
! 257: return $jscript;
! 258: }
1.39 ng 259:
1.44 ng 260: #------------------ End of general use routines --------------------
261: #-------------------------------------------------------------------
262:
263: #------------------------------------ Receipt Verification Routines
1.45 ! ng 264: #
1.44 ng 265: #--- Check whether a receipt number is valid.---
266: sub verifyreceipt {
267: my $request = shift;
268:
269: my $courseid = $ENV{'request.course.id'};
270: my $receipt = unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).'-'.
271: $ENV{'form.receipt'};
272: $receipt =~ s/[^\-\d]//g;
273: my $url = $ENV{'form.url'};
274: my $symb = $ENV{'form.symb'};
275: unless ($symb) {
276: $symb = &Apache::lonnet::symbread($url);
277: }
278:
1.45 ! ng 279: my $title.='<h3><font color="#339933">Verifying Submission Receipt '.
! 280: $receipt.'</h3></font>'."\n".
1.44 ng 281: '<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br><br>'."\n";
282:
283: my ($string,$contents,$matches) = ('','',0);
284: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0');
285:
286: foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
287: my ($uname,$udom)=split(/\:/);
288: if ($receipt eq
289: &Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb)) {
290: $contents.='<tr bgcolor="#ffffe6"><td> '."\n".
291: '<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom.
292: '\')"; TARGET=_self>'.$$fullname{$_}.'</a> </td>'."\n".
293: '<td> '.$uname.' </td>'.
294: '<td> '.$udom.' </td></tr>'."\n";
295:
296: $matches++;
297: }
298: }
299: if ($matches == 0) {
300: $string = $title.'No match found for the above receipt.';
301: } else {
1.45 ! ng 302: $string = &jscriptNform($url,$symb).$title.
1.44 ng 303: 'The above receipt matches the following student'.
304: ($matches <= 1 ? '.' : 's.')."\n".
305: '<table border="0"><tr><td bgcolor="#777777">'."\n".
306: '<table border="0"><tr bgcolor="#e6ffff">'."\n".
307: '<td><b> Fullname </b></td>'."\n".
308: '<td><b> Username </b></td>'."\n".
309: '<td><b> Domain </b></td></tr>'."\n".
310: $contents.
311: '</table></td></tr></table>'."\n";
312: }
313: return $string.&show_grading_menu_form ($symb,$url);
314: }
315:
316: #--- This is called by a number of programs.
317: #--- Called from the Grading Menu - View/Grade an individual student
318: #--- Also called directly when one clicks on the subm button
319: # on the problem page.
1.30 ng 320: sub listStudents {
1.41 ng 321: my ($request) = shift;
1.45 ! ng 322: $request->print(<<LISTJAVASCRIPT);
! 323: <script type="text/javascript" language="javascript">
! 324: function checkSelect(checkBox) {
! 325: var ctr=0;
! 326: if (checkBox.length > 1) {
! 327: for (var i=0; i<checkBox.length; i++) {
! 328: if (checkBox[i].checked) {
! 329: ctr++;
! 330: }
! 331: }
! 332: } else {
! 333: if (checkBox.checked) {
! 334: ctr = 1;
! 335: }
! 336: }
! 337: if (ctr == 0) {
! 338: alert("You did not select any student.");
! 339: return false;
! 340: }
! 341: document.gradesub.submit();
! 342: }
! 343: </script>
! 344: LISTJAVASCRIPT
! 345:
1.44 ng 346: my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"};
347: my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"};
348: my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
349: my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};
1.41 ng 350:
1.45 ! ng 351: my $result='<h3><font color="#339933"> '.
! 352: 'View/Grade Submissions for a Student or a Group of Students</font></h3>';
1.41 ng 353: $result.='<table border="0">';
1.44 ng 354: $result.='<tr><td colspan=3><font size=+1>'.
355: '<b>Resource: </b>'.$ENV{'form.url'}.'</font></td></tr>';
1.41 ng 356: my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
357: for (sort keys(%$handgrade)) {
358: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
359: $ENV{'form.handgrade'} = 'yes' if ($handgrade eq 'yes');
1.44 ng 360: $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
1.41 ng 361: '<td><b>Type: </b>'.$responsetype.'</td>'.
362: '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
363: }
364: $result.='</table>';
365: $request->print($result);
1.39 ng 366:
1.45 ! ng 367: my $checkhdgrade = $ENV{'form.handgrade'} eq 'yes' ? 'checked' : '';
! 368: my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
1.44 ng 369:
1.45 ! ng 370: my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n".
! 371: ' <b>View Problem: </b><input type="radio" name="vProb" value="no" checked> no '."\n".
! 372: '<input type="radio" name="vProb" value="yes"> yes <br />'."\n".
! 373: ' <b>Submissions: </b>'."\n".
! 374: '<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n".
! 375: '<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last sub only'."\n".
! 376: '<input type="radio" name="lastSub" value="last" /> last sub & parts info'."\n".
! 377: '<input type="radio" name="lastSub" value="all" /> all details'."\n".
! 378: '<input type="hidden" name="section" value="'.$getsec.'" />'."\n".
! 379: '<input type="hidden" name="submitonly" value="'.$submitonly.'" />'."\n".
! 380: '<input type="hidden" name="response" value="'.$ENV{'form.response'}.'" />'."\n".
! 381: '<input type="hidden" name="handgrade" value="'.$ENV{'form.handgrade'}.'" /><br />'."\n".
! 382: '<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" /><br />'."\n".
! 383: '<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />'."\n".
! 384: '<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'."\n".
! 385: 'To view/grade a submission, click on the check box next to the student\'s name. Then '."\n".
! 386: 'click on the View/Grade button. To view the submissions for a group of students, click'."\n".
! 387: ' on the check boxes for the group of students.<br />'."\n".
! 388: '<input type="hidden" name="command" value="processGroup" />'."\n".
! 389: '<input type="button" '."\n".
! 390: 'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n".
! 391: 'value="View/Grade" />'."\n";
! 392:
1.41 ng 393: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');
394:
1.45 ! ng 395: $gradeTable.='<table border="0"><tr><td bgcolor="#777777">'.
1.41 ng 396: '<table border="0"><tr bgcolor="#e6ffff">'.
1.44 ng 397: '<td><b> Select </b></td><td><b> Fullname </b></td>'.
398: '<td><b> Username </b></td><td><b> Domain </b></td>';
1.41 ng 399: foreach (sort(@$partlist)) {
1.45 ! ng 400: $gradeTable.='<td><b> Part '.(split(/_/))[0].' Status </b></td>';
1.41 ng 401: }
1.45 ! ng 402: $gradeTable.='</tr>'."\n";
1.41 ng 403:
1.45 ! ng 404: my $ctr = 0;
1.44 ng 405: foreach my $student (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
1.41 ng 406: my ($uname,$udom) = split(/:/,$student);
1.44 ng 407: my (%status) = &student_gradeStatus($ENV{'form.url'},
408: $ENV{'form.symb'},$udom,$uname,$partlist);
1.41 ng 409: my $statusflg = '';
410: foreach (keys(%status)) {
411: $statusflg = 1 if ($status{$_} ne 'nothing');
1.43 ng 412: my ($foo,$partid,$foo1) = split(/\./,$_);
1.41 ng 413: if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
414: $statusflg = '';
1.45 ! ng 415: $gradeTable.='<input type="hidden" name="'.
! 416: $student.':submitted_by" value="'.
! 417: $status{'resource.'.$partid.'.submitted_by'}.'" />';
1.41 ng 418: }
419: }
420: next if ($statusflg eq '' && $submitonly eq 'yes');
1.34 ng 421:
1.45 ! ng 422: $ctr++;
1.41 ng 423: if ( $Apache::grades::viewgrades eq 'F' ) {
1.45 ! ng 424: $gradeTable.='<tr bgcolor="#ffffe6">'.
1.41 ng 425: '<td align="center"><input type=checkbox name="stuinfo" value="'.
426: $student.':'.$$fullname{$student}.'"></td>'."\n".
1.44 ng 427: '<td> '.$$fullname{$student}.' </td>'."\n".
1.41 ng 428: '<td> '.$uname.' </td>'."\n".
429: '<td align="middle"> '.$udom.' </td>'."\n";
430:
431: foreach (sort keys(%status)) {
432: next if (/^resource.*?submitted_by$/);
1.45 ! ng 433: $gradeTable.='<td align="middle"> '.$status{$_}.' </td>'."\n";
1.41 ng 434: }
1.45 ! ng 435: $gradeTable.='</tr>'."\n";
1.41 ng 436: }
437: }
1.45 ! ng 438: $gradeTable.='</table></td></tr></table>'.
! 439: '<input type="button" '.
! 440: 'onClick="javascript:checkSelect(this.form.stuinfo);" '.
! 441: 'value="View/Grade" /><form />'."\n";
! 442: if ($ctr == 0) {
! 443: $gradeTable='<br /> <font color="red">'.
! 444: 'No submission found for this resource.</font><br />';
! 445: $gradeTable.=&show_grading_menu_form ($ENV{'form.symb'},$ENV{'form.url'});
! 446: }
! 447: $request->print($gradeTable);
1.44 ng 448: return '';
1.10 ng 449: }
450:
1.44 ng 451: #---- Called from the listStudents routine
452: # Displays the submissions for one student or a group of students
1.34 ng 453: sub processGroup {
1.41 ng 454: my ($request) = shift;
455: my $ctr = 0;
456: my @stuchecked = (ref($ENV{'form.stuinfo'}) ? @{$ENV{'form.stuinfo'}}
457: : ($ENV{'form.stuinfo'}));
458: my $total = scalar(@stuchecked)-1;
1.45 ! ng 459:
1.41 ng 460: foreach (@stuchecked) {
461: my ($uname,$udom,$fullname) = split(/:/);
1.44 ng 462: $ENV{'form.student'} = $uname;
463: $ENV{'form.userdom'} = $udom;
464: $ENV{'form.fullname'} = $fullname;
1.41 ng 465: &submission($request,$ctr,$total);
466: $ctr++;
467: }
468: return '';
1.35 ng 469: }
1.34 ng 470:
1.44 ng 471: #------------------------------------------------------------------------------------
472: #
473: #-------------------------- Next few routines handles grading by student, essentially
474: # handles essay response type problem/part
475: #
476: #--- Javascript to handle the submission page functionality ---
477: sub sub_page_js {
478: my $request = shift;
479: $request->print(<<SUBJAVASCRIPT);
480: <script type="text/javascript" language="javascript">
481: function updateRadio(radioButton,formtextbox,formsel,scores,weight) {
482: var pts = formtextbox.value;
483: var resetbox =false;
484: if (isNaN(pts) || pts < 0) {
485: alert("A number equal or greater than 0 is expected. Entered value = "+pts);
486: for (var i=0; i<radioButton.length; i++) {
487: if (radioButton[i].checked) {
488: formtextbox.value = i;
489: resetbox = true;
490: }
491: }
492: if (!resetbox) {
493: formtextbox.value = "";
494: }
495: return;
496: }
1.13 albertel 497:
1.44 ng 498: if (pts > weight) {
499: var resp = confirm("You entered a value ("+pts+
500: ") greater than the weight for the part. Accept?");
501: if (resp == false) {
502: formtextbox.value = "";
503: return;
504: }
1.41 ng 505: }
1.5 albertel 506:
1.44 ng 507: for (var i=0; i<radioButton.length; i++) {
508: radioButton[i].checked=false;
509: if (pts == i) {
510: radioButton[i].checked=true;
1.41 ng 511: }
512: }
1.44 ng 513: updateSelect(formsel);
514: scores.value = "0";
515: }
516:
517: function writeBox(formrad,formsel,pts,scores) {
518: formrad.value = pts;
519: scores.value = "0";
520: updateSelect(formsel,pts);
521: return;
522: }
1.5 albertel 523:
1.44 ng 524: function clearRadBox(radioButton,formbox,formsel,scores) {
525: for (var i=0; i<formsel.length; i++) {
526: if (formsel[i].selected) {
527: var selectx=i;
1.41 ng 528: }
1.13 albertel 529: }
1.44 ng 530: if (selectx == scores.value) { return };
531: formbox.value = "";
532: for (var i=0; i<radioButton.length; i++) {
533: radioButton[i].checked=false;
1.41 ng 534: }
1.44 ng 535: scores.value = selectx;
536: }
1.33 ng 537:
1.44 ng 538: function updateSelect(formsel) {
539: formsel[0].selected = true;
540: return;
541: }
542:
1.45 ! ng 543: //=================== Check that a point is assigned for all the parts ==============
! 544: function checksubmit(val,total,parttot) {
! 545: document.SCORE.gradeOpt.value = val;
! 546: if (val == "Save & Next") {
! 547: for (i=0;i<=total;i++) {
! 548: for (j=0;j<parttot;j++) {
! 549: var partid = eval("document.SCORE.partid"+i+"_"+j+".value");
! 550: var selopt = eval("document.SCORE.GD_SEL"+i+"_"+partid);
! 551: if (selopt[0].selected) {
! 552: var points = eval("document.SCORE.GD_BOX"+i+"_"+partid+".value");
! 553: if (points == "") {
! 554: var name = eval("document.SCORE.name"+i+".value");
! 555: alert("You did not assign any point for "+name+", part "+partid+".");
! 556: return false;
! 557: }
! 558: }
! 559:
! 560: }
! 561: }
! 562:
! 563: }
! 564: document.SCORE.submit();
! 565: }
! 566:
1.44 ng 567: //===================== Show list of keywords ====================
568: function keywords(keyform) {
569: var keywds = keyform.value;
570: var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keywds);
571: if (nret==null) return;
572: keyform.value = nret;
573:
574: document.SCORE.refresh.value = "on";
575: if (document.SCORE.keywords.value != "") {
576: document.SCORE.submit();
577: }
578: return;
579: }
580:
581: //===================== Script to view submitted by ==================
582: function viewSubmitter(submitter) {
583: document.SCORE.refresh.value = "on";
584: document.SCORE.NCT.value = "1";
585: document.SCORE.unamedom0.value = submitter;
586: document.SCORE.submit();
587: return;
588: }
589:
590: //===================== Script to add keyword(s) ==================
591: function getSel() {
592: if (document.getSelection) txt = document.getSelection();
593: else if (document.selection) txt = document.selection.createRange().text;
594: else return;
595: var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");
596: if (cleantxt=="") {
597: alert("Select a word or group of words from document and then click this link.");
598: return;
599: }
600: var nret = prompt("Add selection to keyword list? Edit if desired.",cleantxt);
601: if (nret==null) return;
602: var curlist = document.SCORE.keywords.value;
603: document.SCORE.keywords.value = curlist+" "+nret;
604: document.SCORE.refresh.value = "on";
605: if (document.SCORE.keywords.value != "") {
606: document.SCORE.submit();
607: }
608: return;
609: }
610:
611: //====================== Script for composing message ==============
612: function msgCenter(msgform,usrctr,fullname) {
613: var Nmsg = msgform.savemsgN.value;
614: savedMsgHeader(Nmsg,usrctr,fullname);
615: var subject = msgform.msgsub.value;
616: var rtrchk = eval("document.SCORE.includemsg"+usrctr);
617: var msgchk = rtrchk.value;
618: re = /msgsub/;
619: var shwsel = "";
620: if (re.test(msgchk)) { shwsel = "checked" }
621: displaySubject(subject,shwsel);
622: for (var i=1; i<=Nmsg; i++) {
623: var testpt = "savemsg"+i+",";
624: re = /testpt/;
625: shwsel = "";
626: if (re.test(msgchk)) { shwsel = "checked" }
627: var message = eval("document.SCORE.savemsg"+i+".value");
628: displaySavedMsg(i,message,shwsel);
629: }
630: newmsg = eval("document.SCORE.newmsg"+usrctr+".value");
631: shwsel = "";
632: re = /newmsg/;
633: if (re.test(msgchk)) { shwsel = "checked" }
634: newMsg(newmsg,shwsel);
635: msgTail();
636: return;
637: }
638:
639: function savedMsgHeader(Nmsg,usrctr,fullname) {
640: var height = 30*Nmsg+250;
641: var scrollbar = "no";
642: if (height > 600) {
643: height = 600;
644: scrollbar = "yes";
645: }
646: /* if (window.pWin)
647: window.pWin.close(); */
648: pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx=70,screeny=75,width=600,height='+height);
649: pWin.document.write("<html><head>");
650: pWin.document.write("<title>Message Central</title>");
651:
652: pWin.document.write("<script language=javascript>");
653: pWin.document.write("function checkInput() {");
654: pWin.document.write(" opener.document.SCORE.msgsub.value = document.msgcenter.msgsub.value;");
655: pWin.document.write(" var nmsg = opener.document.SCORE.savemsgN.value;");
656: pWin.document.write(" var usrctr = document.msgcenter.usrctr.value;");
657: pWin.document.write(" var newval = eval(\\"opener.document.SCORE.newmsg\\"+usrctr);");
658: pWin.document.write(" newval.value = document.msgcenter.newmsg.value;");
659:
660: pWin.document.write(" var msgchk = \\"\\";");
661: pWin.document.write(" if (document.msgcenter.subchk.checked) {");
662: pWin.document.write(" msgchk = \\"msgsub,\\";");
663: pWin.document.write(" }");
664: pWin.document.write( "for (var i=1; i<=nmsg; i++) {");
665: pWin.document.write(" var opnmsg = eval(\\"opener.document.SCORE.savemsg\\"+i);");
666: pWin.document.write(" var frmmsg = eval(\\"document.msgcenter.msg\\"+i);");
667: pWin.document.write(" opnmsg.value = frmmsg.value;");
668: pWin.document.write(" var chkbox = eval(\\"document.msgcenter.msgn\\"+i);");
669: pWin.document.write(" if (chkbox.checked) {");
670: pWin.document.write(" msgchk += \\"savemsg\\"+i+\\",\\";");
671: pWin.document.write(" }");
672: pWin.document.write(" }");
673: pWin.document.write(" if (document.msgcenter.newmsgchk.checked) {");
674: pWin.document.write(" msgchk += \\"newmsg\\"+usrctr;");
675: pWin.document.write(" }");
676: pWin.document.write(" var includemsg = eval(\\"opener.document.SCORE.includemsg\\"+usrctr);");
677: pWin.document.write(" includemsg.value = msgchk;");
678:
679: pWin.document.write(" self.close()");
680:
681: pWin.document.write("}");
682:
683: pWin.document.write("<");
684: pWin.document.write("/script>");
685:
686: pWin.document.write("</head><body bgcolor=white>");
687:
688: pWin.document.write("<form action=\\"inactive\\" name=\\"msgcenter\\">");
689: pWin.document.write("<input value=\\""+usrctr+"\\" name=\\"usrctr\\" type=\\"hidden\\">");
690: pWin.document.write("<font color=\\"green\\" size=+1> Compose Message for \"+fullname+\"</font><br><br>");
691:
692: pWin.document.write("<table border=0 width=100%><tr><td bgcolor=\\"#777777\\">");
693: pWin.document.write("<table border=0 width=100%><tr bgcolor=\\"#ddffff\\">");
694: pWin.document.write("<td><b>Type</b></td><td><b>Include</b></td><td><b>Message</td></tr>");
695: }
696: function displaySubject(msg,shwsel) {
697: pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
698: pWin.document.write("<td>Subject</td>");
699: pWin.document.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"></td>");
700: pWin.document.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+" \\"size=\\"60\\" maxlength=\\"80\\"></td></tr>");
701: }
702:
703: function displaySavedMsg(ctr,msg,shwsel) {
704: pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
705: pWin.document.write("<td align=\\"center\\">"+ctr+"</td>");
706: pWin.document.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"></td>");
707: pWin.document.write("<td><input name=\\"msg"+ctr+"\\" type=\\"text\\" value=\\""+msg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");
708: }
709:
710: function newMsg(newmsg,shwsel) {
711: pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
712: pWin.document.write("<td align=\\"center\\">New</td>");
713: pWin.document.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"></td>");
714: pWin.document.write("<td><input name=\\"newmsg\\" type=\\"text\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" value=\\""+newmsg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");
715: }
716:
717: function msgTail() {
718: pWin.document.write("</table>");
719: pWin.document.write("</td></tr></table> ");
720: pWin.document.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:checkInput()\\"> ");
721: pWin.document.write("<input type=\\"button\\" value=\\"Cancel\\" onClick=\\"self.close()\\"><br><br>");
722: pWin.document.write("</form>");
723: pWin.document.write("</body></html>");
724: }
725:
726: //====================== Script for keyword highlight options ==============
727: function kwhighlight() {
728: var kwclr = document.SCORE.kwclr.value;
729: var kwsize = document.SCORE.kwsize.value;
730: var kwstyle = document.SCORE.kwstyle.value;
731: var redsel = "";
732: var grnsel = "";
733: var blusel = "";
734: if (kwclr=="red") {var redsel="checked"};
735: if (kwclr=="green") {var grnsel="checked"};
736: if (kwclr=="blue") {var blusel="checked"};
737: var sznsel = "";
738: var sz1sel = "";
739: var sz2sel = "";
740: if (kwsize=="0") {var sznsel="checked"};
741: if (kwsize=="+1") {var sz1sel="checked"};
742: if (kwsize=="+2") {var sz2sel="checked"};
743: var synsel = "";
744: var syisel = "";
745: var sybsel = "";
746: if (kwstyle=="") {var synsel="checked"};
747: if (kwstyle=="<i>") {var syisel="checked"};
748: if (kwstyle=="<b>") {var sybsel="checked"};
749: highlightCentral();
750: highlightbody('red','red',redsel,'0','normal',sznsel,'','normal',synsel);
751: highlightbody('green','green',grnsel,'+1','+1',sz1sel,'<i>','italic',syisel);
752: highlightbody('blue','blue',blusel,'+2','+2',sz2sel,'<b>','bold',sybsel);
753: highlightend();
754: return;
755: }
756:
757:
758: function highlightCentral() {
759: hwdWin = window.open('', 'KeywordHighlightCentral', 'toolbar=no,location=no,scrollbars=no,width=400,height=300,screenx=100,screeny=75');
760: hwdWin.document.write("<html><head>");
761: hwdWin.document.write("<title>Highlight Central</title>");
762:
763: hwdWin.document.write("<script language=javascript>");
764: hwdWin.document.write("function updateChoice(flag) {");
765: hwdWin.document.write(" opener.document.SCORE.kwclr.value = radioSelection(document.hlCenter.kwdclr);");
766: hwdWin.document.write(" opener.document.SCORE.kwsize.value = radioSelection(document.hlCenter.kwdsize);");
767: hwdWin.document.write(" opener.document.SCORE.kwstyle.value = radioSelection(document.hlCenter.kwdstyle);");
768: hwdWin.document.write(" opener.document.SCORE.refresh.value = \\"on\\";");
769: hwdWin.document.write(" if (opener.document.SCORE.keywords.value!=\\"\\"){");
770: hwdWin.document.write(" opener.document.SCORE.submit();");
771: hwdWin.document.write(" }");
772: hwdWin.document.write(" self.close()");
773: hwdWin.document.write("}");
774:
775: hwdWin.document.write("function radioSelection(radioButton) {");
776: hwdWin.document.write(" var selection=null;");
777: hwdWin.document.write(" for (var i=0; i<radioButton.length; i++) {");
778: hwdWin.document.write(" if (radioButton[i].checked) {");
779: hwdWin.document.write(" selection=radioButton[i].value;");
780: hwdWin.document.write(" return selection;");
781: hwdWin.document.write(" }");
782: hwdWin.document.write(" }");
783: hwdWin.document.write("}");
784:
785: hwdWin.document.write("<");
786: hwdWin.document.write("/script>");
787:
788: hwdWin.document.write("</head><body bgcolor=white>");
789:
790: hwdWin.document.write("<form action=\\"inactive\\" name=\\"hlCenter\\">");
791: hwdWin.document.write("<font color=\\"green\\" size=+1> Keyword Highlight Options</font><br><br>");
792:
793: hwdWin.document.write("<table border=0 width=100%><tr><td bgcolor=\\"#777777\\">");
794: hwdWin.document.write("<table border=0 width=100%><tr bgcolor=\\"#ddffff\\">");
795: hwdWin.document.write("<td><b>Text Color</b></td><td><b>Font Size</b></td><td><b>Font Style</td></tr>");
796: }
797:
798: function highlightbody(clrval,clrtxt,clrsel,szval,sztxt,szsel,syval,sytxt,sysel) {
799: hwdWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
800: hwdWin.document.write("<td align=\\"left\\">");
801: hwdWin.document.write("<input name=\\"kwdclr\\" type=\\"radio\\" value=\\""+clrval+"\\" "+clrsel+"> "+clrtxt+"</td>");
802: hwdWin.document.write("<td align=\\"left\\">");
803: hwdWin.document.write("<input name=\\"kwdsize\\" type=\\"radio\\" value=\\""+szval+"\\" "+szsel+"> "+sztxt+"</td>");
804: hwdWin.document.write("<td align=\\"left\\">");
805: hwdWin.document.write("<input name=\\"kwdstyle\\" type=\\"radio\\" value=\\""+syval+"\\" "+sysel+"> "+sytxt+"</td>");
806: hwdWin.document.write("</tr>");
807: }
808:
809: function highlightend() {
810: hwdWin.document.write("</table>");
811: hwdWin.document.write("</td></tr></table> ");
812: // hwdWin.document.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:updateChoice(0)\\"> ");
813: hwdWin.document.write("<input type=\\"button\\" value=\\"Save\\" onClick=\\"javascript:updateChoice(1)\\"> ");
814: hwdWin.document.write("<input type=\\"button\\" value=\\"Cancel\\" onClick=\\"self.close()\\"><br><br>");
815: hwdWin.document.write("</form>");
816: hwdWin.document.write("</body></html>");
817: }
818:
819: </script>
820: SUBJAVASCRIPT
821: }
822:
823:
824: # --------------------------- show submissions of a student, option to grade
825: sub submission {
826: my ($request,$counter,$total) = @_;
827:
828: (my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
829: # if ($ENV{'form.student'} eq '') { &moreinfo($request,'Need student login id'); return ''; }
830: my ($uname,$udom) = ($ENV{'form.student'},$ENV{'form.userdom'});
831: ($uname,$udom) = &finduser($uname) if $udom eq '';
832: $ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq '';
833: # if ($uname eq '') { &moreinfo($request,'Unable to find student'); return ''; }
1.41 ng 834:
835: my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
836: if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
837: my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
838: $ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes';
839: my ($classlist,$seclist,$ids,$stusec,$fullname);
840:
841: # header info
842: if ($counter == 0) {
843: &sub_page_js($request);
1.45 ! ng 844: $request->print('<h3> <font color="#339933">Submission Record</font></h3>'."\n".
! 845: '<font size=+1> <b>Resource: </b>'.$url.'</font>'."\n");
1.41 ng 846:
1.44 ng 847: # option to display problem, only once else it cause problems
848: # with the form later since the problem has a form.
1.41 ng 849: if ($ENV{'form.vProb'} eq 'yes') {
850: my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
851: $ENV{'request.course.id'});
852: my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
853: $ENV{'request.course.id'});
854: my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">';
855: $result.='<table border="0" width="100%"><tr><td bgcolor="#e6ffff">';
1.45 ! ng 856: $result.='<b> View of the problem - '.$ENV{'form.fullname'}.
1.44 ng 857: '</b></td></tr><tr><td bgcolor="#ffffff">'.$rendered.'<br />';
1.41 ng 858: $result.='<b>Correct answer:</b><br />'.$companswer;
859: $result.='</td></tr></table>';
860: $result.='</td></tr></table><br />';
861: $request->print($result);
862: }
863:
1.44 ng 864: # kwclr is the only variable that is guaranteed to be non blank
865: # if this subroutine has been called once.
1.41 ng 866: my %keyhash = ();
867: if ($ENV{'form.kwclr'} eq '') {
868: %keyhash = &Apache::lonnet::dump('nohist_handgrade',
869: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
870: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
871:
872: my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
873: $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
874: $ENV{'form.kwclr'} = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
875: $ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
876: $ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
877: $ENV{'form.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
878: $keyhash{$symb.'_subject'} : &Apache::lonnet::metadata($url,'title');
879: $ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
1.38 ng 880:
1.41 ng 881: }
1.44 ng 882:
1.41 ng 883: $request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n".
884: '<input type="hidden" name="command" value="handgrade" />'."\n".
885: '<input type="hidden" name="refresh" value="off" />'."\n".
886: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
887: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
888: '<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" />'."\n".
889: '<input type="hidden" name="vProb" value="'.$ENV{'form.vProb'}.'" />'."\n".
890: '<input type="hidden" name="lastSub" value="'.$ENV{'form.lastSub'}.'" />'."\n".
891: '<input type="hidden" name="section" value="'.$ENV{'form.section'}.'">'."\n".
892: '<input type="hidden" name="submitonly" value="'.$ENV{'form.submitonly'}.'">'."\n".
893: '<input type="hidden" name="response" value="'.$ENV{'form.response'}.'">'."\n".
894: '<input type="hidden" name="handgrade" value="'.$ENV{'form.handgrade'}.'">'."\n".
895: '<input type="hidden" name="keywords" value="'.$ENV{'form.keywords'}.'" />'."\n".
896: '<input type="hidden" name="kwclr" value="'.$ENV{'form.kwclr'}.'" />'."\n".
897: '<input type="hidden" name="kwsize" value="'.$ENV{'form.kwsize'}.'" />'."\n".
898: '<input type="hidden" name="kwstyle" value="'.$ENV{'form.kwstyle'}.'" />'."\n".
899: '<input type="hidden" name="msgsub" value="'.$ENV{'form.msgsub'}.'" />'."\n".
900: '<input type="hidden" name="savemsgN" value="'.$ENV{'form.savemsgN'}.'" />'."\n".
901: '<input type="hidden" name="NCT"'.
902: ' value="'.($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : $total+1).'" />'."\n");
903:
904: my ($cts,$prnmsg) = (1,'');
905: while ($cts <= $ENV{'form.savemsgN'}) {
906: $prnmsg.='<input type="hidden" name="savemsg'.$cts.'" value="'.
907: ($keyhash{$symb.'_savemsg'.$cts} eq '' ? $ENV{'form.savemsg'.$cts} : $keyhash{$symb.'_savemsg'.$cts}).
908: '" />'."\n";
909: $cts++;
910: }
911: $request->print($prnmsg);
1.32 ng 912:
1.41 ng 913: if ($ENV{'form.handgrade'} eq 'yes' && $ENV{'form.showgrading'} eq 'yes') {
914: $request->print(<<KEYWORDS);
1.38 ng 915: <b>Keyword Options:</b>
916: <a href="javascript:keywords(document.SCORE.keywords)"; TARGET=_self>List</a>
917: <a href="#" onMouseDown="javascript:getSel(); return false"
918: CLASS="page">Paste Selection to List</a>
919: <a href="javascript:kwhighlight()"; TARGET=_self>Highlight Attribute</a><br /><br />
920: KEYWORDS
1.41 ng 921: }
922: }
1.44 ng 923:
1.41 ng 924: my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
925: my ($partlist,$handgrade) = &response_type($url);
926:
1.44 ng 927: # Display student info
1.41 ng 928: $request->print(($counter == 0 ? '' : '<br />'));
1.45 ! ng 929: my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n".
! 930: '<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n";
1.44 ng 931:
932: # $result.='<table border="0"><tr bgcolor="#ffffff"><td><b>Fullname: </b>'.$ENV{'form.fullname'}.
933: $result.='<b>Fullname: </b>'.$ENV{'form.fullname'}.
934: '<font color="#999999"> Username: '.$uname.'</font>'.
1.45 ! ng 935: '<font color="#999999"> Domain: '.$udom.'</font><br />'."\n";
! 936: $result.='<input type="hidden" name="name'.$counter.
! 937: '" value="'.$ENV{'form.fullname'}.'" />'."\n";
1.41 ng 938:
1.44 ng 939: # If this is handgraded, then check for collaborators
1.45 ! ng 940: my @col_fullnames;
1.41 ng 941: if ($ENV{'form.handgrade'} eq 'yes') {
942: my @col_list;
943: ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0');
944: for (keys (%$handgrade)) {
1.44 ng 945: my $ncol = &Apache::lonnet::EXT('resource.'.$_.
946: '.maxcollaborators',$symb,$udom,$uname);
1.41 ng 947: if ($ncol > 0) {
948: s/\_/\./g;
949: if ($record{'resource.'.$_.'.collaborators'} ne '') {
1.44 ng 950: my (@collaborators) = split(/,?\s+/,
951: $record{'resource.'.$_.'.collaborators'});
1.41 ng 952: my (@badcollaborators);
953: if (scalar(@collaborators) != 0) {
1.44 ng 954: $result.='<b>Collaborators: </b>';
1.41 ng 955: foreach my $collaborator (@collaborators) {
956: $collaborator = $collaborator =~ /\@|:/ ?
957: (split(/@|:/,$collaborator))[0] : $collaborator;
958: next if ($collaborator eq $uname);
959: if (!grep /^$collaborator:/i,keys %$classlist) {
960: push @badcollaborators,$collaborator;
961: next;
962: }
963: push @col_list, $collaborator;
1.45 ! ng 964: my ($lastname,$givenn) = split(/,/,$$fullname{$collaborator.':'.$udom});
! 965: push @col_fullnames, $givenn.' '.$lastname;
1.44 ng 966: $result.=$$fullname{$collaborator.':'.$udom}.' ';
1.41 ng 967: }
1.44 ng 968: $result.='<br />'."\n";
969: $result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'.
970: 'This student has submitted '.
971: (scalar (@badcollaborators) > 1 ? '' : 'an').
1.41 ng 972: ' invalid collaborator'.(scalar (@badcollaborators) > 1 ? 's. ' : '. ').
1.44 ng 973: (join ', ',@badcollaborators).'</td></tr></table>'
1.41 ng 974: if (scalar(@badcollaborators) > 0);
975:
1.44 ng 976: $result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'.
1.41 ng 977: 'This student has submitted too many collaborators. Maximum is '.
1.44 ng 978: $ncol.'.</td></tr></table>' if (scalar(@collaborators) > $ncol);
1.41 ng 979: $result.='<input type="hidden" name="collaborator'.$counter.
980: '" value="'.(join ':',@col_list).'" />'."\n";
981: }
982: }
983: }
984: }
985: }
1.44 ng 986: $request->print($result."\n");
1.33 ng 987:
1.44 ng 988: # print student answer/submission
989: # Options are (1) Handgaded submission only
990: # (2) Last submission, includes submission that is not handgraded
991: # (for multi-response type part)
992: # (3) Last submission plus the parts info
993: # (4) The whole record for this student
1.41 ng 994: if ($ENV{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) {
995: if ($ENV{'form.'.$uname.':'.$udom.':submitted_by'}) {
1.44 ng 996: my $submitby=''.
1.41 ng 997: '<b>Collaborative submission by: </b>'.
1.44 ng 998: '<a href="javascript:viewSubmitter(\''.
999: $ENV{'form.'.$uname.':'.$udom.':submitted_by'}.
1.41 ng 1000: '\')"; TARGET=_self>'.
1001: $$fullname{$ENV{'form.'.$uname.':'.$udom.':submitted_by'}}.'</a>';
1002: $request->print($submitby);
1003: } else {
1.44 ng 1004: my ($string,$timestamp)=
1005: &get_last_submission ($symb,$uname,$udom,$ENV{'request.course.id'});
1006: my $lastsubonly.=''.
1007: ($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '.
1008: $$timestamp).'';
1.41 ng 1009: if ($$timestamp eq '') {
1.45 ! ng 1010: $lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0].'</td></tr>'."\n";
1.41 ng 1011: } else {
1012: for my $part (sort keys(%$handgrade)) {
1013: foreach (@$string) {
1014: my ($partid,$respid) = /^resource\.(\d+)\.(\d+)\.submission/;
1015: if ($part eq ($partid.'_'.$respid)) {
1016: my ($ressub,$subval) = split(/:/,$_,2);
1.44 ng 1017: $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
1018: $partid.'</b> <font color="#999999">( ID '.$respid.
1019: ' )</font> <b>Answer: </b>'.
1.45 ! ng 1020: &keywords_highlight($subval).'</td></tr>'."\n"
1.41 ng 1021: if ($ENV{'form.lastSub'} eq 'lastonly' ||
1.44 ng 1022: ($ENV{'form.lastSub'} eq 'hdgrade' &&
1023: $$handgrade{$part} =~ /:yes$/));
1.41 ng 1024: }
1025: }
1026: }
1027: }
1.45 ! ng 1028: $lastsubonly.='</td></tr>'."\n";
1.41 ng 1029: $request->print($lastsubonly);
1030: }
1031: } else {
1032: $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
1.44 ng 1033: $ENV{'request.course.id'},
1034: $last,'.submission',
1035: 'Apache::grades::keywords_highlight'));
1.41 ng 1036: }
1037:
1.44 ng 1038: # return if view submission with no grading option
1.41 ng 1039: if ($ENV{'form.showgrading'} eq '') {
1.45 ! ng 1040: $request->print('</td></tr></table></td></tr></table></form>'."\n");
1.41 ng 1041: return;
1042: }
1.33 ng 1043:
1.44 ng 1044: # Grading options
1.41 ng 1045: $result='<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n".
1046: '<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".
1.45 ! ng 1047: '<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'
! 1048: .$udom.'" />'."\n";
! 1049: my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
! 1050: my $msgfor = $givenn.' '.$lastname;
! 1051: if (scalar(@col_fullnames) > 0) {
! 1052: my $lastone = pop @col_fullnames;
! 1053: $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
! 1054: }
! 1055: $result.='<tr><td bgcolor="#ffffff">'."\n".
! 1056: ' <a href="javascript:msgCenter(document.SCORE,'.$counter.
! 1057: ',\''.$msgfor.'\')"; TARGET=_self>'.
! 1058: 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a>'.
1.44 ng 1059: '<br /> (Message will be sent when you click on Save & Next below.)'."\n"
1060: if ($ENV{'form.handgrade'} eq 'yes');
1.41 ng 1061: $request->print($result);
1062:
1063: my %seen = ();
1064: my @partlist;
1065: for (sort keys(%$handgrade)) {
1066: my ($partid,$respid) = split(/_/);
1067: next if ($seen{$partid} > 0);
1068: $seen{$partid}++;
1069: next if ($$handgrade{$_} =~ /:no$/);
1070: push @partlist,$partid;
1071: my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
1.44 ng 1072: my $wgtmsg = ($wgt > 0 ? '(problem weight)' :
1073: '<font color="red">problem weight assigned by computer</font>');
1.41 ng 1074: $wgt = ($wgt > 0 ? $wgt : '1');
1075: my $score = ($record{'resource.'.$partid.'.awarded'} eq '' ?
1076: '' : $record{'resource.'.$partid.'.awarded'}*$wgt);
1077: $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />';
1.44 ng 1078: $result.='<table border="0"><tr><td><b>Part </b>'.$partid.' <b>Points: </b></td><td>';
1.41 ng 1079:
1080: my $ctr = 0;
1081: $result.='<table border="0"><tr>'; # display radio buttons in a nice table 10 across
1082: while ($ctr<=$wgt) {
1083: $result.= '<td><input type="radio" name="RADVAL'.$counter.'_'.$partid.'" '.
1.43 ng 1084: 'onclick="javascript:writeBox(this.form.GD_BOX'.$counter.'_'.$partid.
1085: ',this.form.GD_SEL'.$counter.'_'.$partid.','.$ctr.
1.41 ng 1086: ',this.form.stores'.$counter.'_'.$partid.')" '.
1087: ($score eq $ctr ? 'checked':'').' /> '.$ctr."</td>\n";
1088: $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : '');
1089: $ctr++;
1090: }
1091: $result.='</tr></table>';
1.39 ng 1092:
1.41 ng 1093: $result.='</td><td> <b>or</b> </td>';
1.43 ng 1094: $result.='<td><input type="text" name="GD_BOX'.$counter.'_'.$partid.'"'.
1.41 ng 1095: ($score ne ''? ' value = "'.$score.'"':'').' size="4" '.
1096: 'onChange="javascript:updateRadio(this.form.RADVAL'.$counter.'_'.$partid.
1.43 ng 1097: ',this.form.GD_BOX'.$counter.'_'.$partid.
1098: ',this.form.GD_SEL'.$counter.'_'.$partid.
1.44 ng 1099: ',this.form.stores'.$counter.'_'.$partid.
1100: ','.$wgt.')" /></td>'."\n";
1.41 ng 1101: $result.='<td>/'.$wgt.' '.$wgtmsg.' </td><td>';
1102:
1.43 ng 1103: $result.='<select name="GD_SEL'.$counter.'_'.$partid.'" '.
1.41 ng 1104: 'onChange="javascript:clearRadBox(this.form.RADVAL'.$counter.'_'.$partid.
1.43 ng 1105: ',this.form.GD_BOX'.$counter.'_'.$partid.
1106: ',this.form.GD_SEL'.$counter.'_'.$partid.
1.41 ng 1107: ',this.form.stores'.$counter.'_'.$partid.')" />'."\n".
1108: '<option selected="on"> </option>'.
1109: '<option>excused</option></select>'."  \n";
1110: $result.='<input type="hidden" name="stores'.$counter.'_'.$partid.'" value="0" />';
1.45 ! ng 1111: $result.='</td></tr></table>'."\n";
1.41 ng 1112: $request->print($result);
1113: }
1.45 ! ng 1114: $result='<input type="hidden" name="partlist'.$counter.
! 1115: '" value="'.(join ":",@partlist).'" />'."\n";
! 1116: my $ctr = 0;
! 1117: while ($ctr < scalar(@partlist)) {
! 1118: $result.='<input type="hidden" name="partid'.$counter.'_'.$ctr.'" value="'.
! 1119: $partlist[$ctr].'" />'."\n";
! 1120: $ctr++;
! 1121: }
! 1122: $request->print($result.'</td></tr></table></td></tr></table>'."\n");
1.41 ng 1123:
1124: # print end of form
1125: if ($counter == $total) {
1.45 ! ng 1126: my $endform='<table border="0"><tr><td>'.
! 1127: '<input type="hidden" name="gradeOpt" value="" />'."\n";
! 1128: if ($ENV{'form.handgrade'} eq 'yes') {
! 1129: $endform.='<input type="button" value="Save & Next" '.
! 1130: 'onClick="javascript:checksubmit(\'Save & Next\','.
! 1131: $total.','.scalar(@partlist).');" TARGET=_self> '."\n";
! 1132: my $ntstu ='<select name="NTSTU">'.
! 1133: '<option>1</option><option>2</option>'.
! 1134: '<option>3</option><option>5</option>'.
! 1135: '<option>7</option><option>10</option></select>'."\n";
! 1136: my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');
! 1137: $ntstu =~ s/<option>$nsel</<option selected="on">$nsel</;
! 1138: $endform.=$ntstu.'student(s) ';
! 1139: } else {
! 1140: $endform.='<input type="hidden" name="NTSTU" value="1" />'."\n";
! 1141: }
! 1142: $endform.='<input type="button" value="Next" '.
! 1143: 'onClick="javascript:checksubmit(\'Next\');" TARGET=_self> '."\n".
! 1144: '<input type="button" value="Previous" '.
! 1145: 'onClick="javascript:checksubmit(\'Previous\');" TARGET=_self> ';
! 1146: $endform.='(Next and Previous do not save the scores.)'."\n"
! 1147: if ($ENV{'form.handgrade'} eq 'yes');
! 1148: $endform.='</td><tr></table></form>';
1.41 ng 1149: $request->print($endform);
1150: }
1151: return '';
1.38 ng 1152: }
1153:
1.44 ng 1154: #--- Retrieve the last submission for all the parts
1.38 ng 1155: sub get_last_submission {
1.41 ng 1156: my ($symb,$username,$domain,$course)=@_;
1157: if ($symb) {
1158: my (@string,$timestamp);
1159: my (%returnhash)=&Apache::lonnet::restore($symb,$course,$domain,$username);
1160: if ($returnhash{'version'}) {
1161: my %lasthash=();
1162: my ($version);
1163: for ($version=1;$version<=$returnhash{'version'};$version++) {
1164: foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
1165: $lasthash{$_}=$returnhash{$version.':'.$_};
1166: }
1167: }
1168: foreach ((keys %lasthash)) {
1.44 ng 1169: if ($_ =~ /\.submission$/) {
1170: my ($partid,$foo) = split(/submission$/,$_);
1171: my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
1172: '<font color="red">Draft Copy</font> ' : '';
1173: push @string, (join(':',$_,$draft.$lasthash{$_}));
1174: }
1.41 ng 1175: if ($_ =~ /timestamp/) {$timestamp = scalar(localtime($lasthash{$_}))};
1176: }
1177: }
1178: @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
1179: return \@string,\$timestamp;
1180: }
1.38 ng 1181: }
1.35 ng 1182:
1.44 ng 1183: #--- High light keywords, with style choosen by user.
1.38 ng 1184: sub keywords_highlight {
1.44 ng 1185: my $string = shift;
1186: my $size = $ENV{'form.kwsize'} eq '0' ? '' : 'size='.$ENV{'form.kwsize'};
1187: my $styleon = $ENV{'form.kwstyle'} eq '' ? '' : $ENV{'form.kwstyle'};
1.41 ng 1188: (my $styleoff = $styleon) =~ s/\</\<\//;
1.44 ng 1189: my @keylist = split(/[,\s+]/,$ENV{'form.keywords'});
1.41 ng 1190: foreach (@keylist) {
1191: $string =~ s/\b$_(\b|\.)/\<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff\<\/font\>/gi;
1192: }
1193: return $string;
1.38 ng 1194: }
1.36 ng 1195:
1.44 ng 1196: #--- Called from submission routine
1.38 ng 1197: sub processHandGrade {
1.41 ng 1198: my ($request) = shift;
1199: my $url = $ENV{'form.url'};
1200: my $symb = $ENV{'form.symb'};
1201: my $button = $ENV{'form.gradeOpt'};
1202: my $ngrade = $ENV{'form.NCT'};
1203: my $ntstu = $ENV{'form.NTSTU'};
1204:
1.44 ng 1205: if ($button eq 'Save & Next') {
1206: my $ctr = 0;
1207: while ($ctr < $ngrade) {
1208: my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
1.45 ! ng 1209: my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
1.44 ng 1210:
1211: my $includemsg = $ENV{'form.includemsg'.$ctr};
1212: my ($subject,$message,$msgstatus) = ('','','');
1213: if ($includemsg =~ /savemsg|new$ctr/) {
1214: $subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/);
1215: my (@msgnum) = split(/,/,$includemsg);
1216: foreach (@msgnum) {
1217: $message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
1218: }
1219: $message =~ s/\s+/ /g;
1220: $msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom,
1221: $ENV{'form.msgsub'},$message);
1222: }
1223: if ($ENV{'form.collaborator'.$ctr}) {
1224: my (@collaborators) = split(/:/,$ENV{'form.collaborator'.$ctr});
1225: foreach (@collaborators) {
1226: &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,
1227: $ENV{'form.unamedom'.$ctr});
1228: if ($message ne '') {
1229: $msgstatus = &Apache::lonmsg::user_normal_msg ($_,$udom,
1230: $ENV{'form.msgsub'},
1231: $message);
1232: }
1233: }
1234: }
1235: $ctr++;
1236: }
1237: }
1238:
1239: # Keywords sorted in alphabatical order
1.41 ng 1240: my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
1241: my %keyhash = ();
1242: $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
1243: $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
1.44 ng 1244: my (@keywords) = sort(split(/\s+/,$ENV{'form.keywords'}));
1245: $ENV{'form.keywords'} = join(' ',@keywords);
1.41 ng 1246: $keyhash{$symb.'_keywords'} = $ENV{'form.keywords'};
1247: $keyhash{$symb.'_subject'} = $ENV{'form.msgsub'};
1248: $keyhash{$loginuser.'_kwclr'} = $ENV{'form.kwclr'};
1249: $keyhash{$loginuser.'_kwsize'} = $ENV{'form.kwsize'};
1250: $keyhash{$loginuser.'_kwstyle'} = $ENV{'form.kwstyle'};
1251:
1.44 ng 1252: # message center - Order of message gets changed. Blank line is eliminated.
1253: # New messages are saved in ENV for the next student.
1254: # All messages are saved in nohist_handgrade.db
1.41 ng 1255: my ($ctr,$idx) = (1,1);
1256: while ($ctr <= $ENV{'form.savemsgN'}) {
1257: if ($ENV{'form.savemsg'.$ctr} ne '') {
1258: $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.savemsg'.$ctr};
1259: $idx++;
1260: }
1261: $ctr++;
1262: }
1263: $ctr = 0;
1264: while ($ctr < $ngrade) {
1265: if ($ENV{'form.newmsg'.$ctr} ne '') {
1266: $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
1267: $ENV{'form.savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
1268: $idx++;
1269: }
1270: $ctr++;
1271: }
1272: $ENV{'form.savemsgN'} = --$idx;
1273: $keyhash{$symb.'_savemsgN'} = $ENV{'form.savemsgN'};
1274: my $putresult = &Apache::lonnet::put
1275: ('nohist_handgrade',\%keyhash,
1276: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1277: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1278:
1.44 ng 1279: # Called by Save & Refresh from Highlight Attribute Window
1.41 ng 1280: if ($ENV{'form.refresh'} eq 'on') {
1281: my $ctr = 0;
1282: $ENV{'form.NTSTU'}=$ngrade;
1283: while ($ctr < $ngrade) {
1.44 ng 1284: ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$ENV{'form.unamedom'.$ctr});
1.41 ng 1285: &submission($request,$ctr,$ngrade-1);
1286: $ctr++;
1287: }
1288: return '';
1289: }
1.36 ng 1290:
1.44 ng 1291: # Get the next/previous one or group of students
1.41 ng 1292: my $firststu = $ENV{'form.unamedom0'};
1293: my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
1294: $ctr = 2;
1295: while ($laststu eq '') {
1296: $laststu = $ENV{'form.unamedom'.($ngrade-$ctr)};
1297: $ctr++;
1298: $laststu = $firststu if ($ctr > $ngrade);
1299: }
1.44 ng 1300:
1.41 ng 1301: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
1302: my (@parsedlist,@nextlist);
1303: my ($nextflg) = 0;
1.44 ng 1304: foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
1.41 ng 1305: if ($nextflg == 1 && $button =~ /Next$/) {
1306: push @parsedlist,$_;
1307: }
1308: $nextflg = 1 if ($_ eq $laststu);
1309: if ($button eq 'Previous') {
1310: last if ($_ eq $firststu);
1311: push @parsedlist,$_;
1312: }
1313: }
1314: $ctr = 0;
1315: my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
1316: @parsedlist = reverse @parsedlist if ($button eq 'Previous');
1317: foreach my $student (@parsedlist) {
1318: my ($uname,$udom) = split(/:/,$student);
1319: if ($ENV{'form.submitonly'} eq 'yes') {
1.44 ng 1320: my (%status) = &student_gradeStatus($ENV{'form.url'},$symb,$udom,$uname,$partlist) ;
1.41 ng 1321: my $statusflg = '';
1322: foreach (keys(%status)) {
1323: $statusflg = 1 if ($status{$_} ne 'nothing');
1.44 ng 1324: my ($foo,$partid,$foo1) = split(/\./);
1.41 ng 1325: $statusflg = '' if ($status{'resource.'.$partid.'.submitted_by'} ne '');
1326: }
1327: next if ($statusflg eq '');
1328: }
1329: push @nextlist,$student if ($ctr < $ntstu);
1330: $ctr++;
1331: }
1.36 ng 1332:
1.41 ng 1333: $ctr = 0;
1334: my $total = scalar(@nextlist)-1;
1.39 ng 1335:
1.41 ng 1336: foreach (sort @nextlist) {
1337: my ($uname,$udom,$submitter) = split(/:/);
1.44 ng 1338: $ENV{'form.student'} = $uname;
1339: $ENV{'form.userdom'} = $udom;
1.41 ng 1340: $ENV{'form.fullname'} = $$fullname{$_};
1341: # $ENV{'form.'.$_.':submitted_by'} = $submitter;
1342: # print "submitter=$ENV{'form.'.$_.':submitted_by'}= $submitter:<br>";
1343: &submission($request,$ctr,$total);
1344: $ctr++;
1345: }
1346: if ($total < 0) {
1347: my $the_end = '<h3><font color="red">LON-CAPA User Message</font></h3><br />'."\n";
1348: $the_end.='<b>Message: </b> No more students for this section or class.<br /><br />'."\n";
1349: $the_end.='Click on the button below to return to the grading menu.<br /><br />'."\n";
1350: $the_end.=&show_grading_menu_form ($symb,$url);
1351: $request->print($the_end);
1352: }
1353: return '';
1.38 ng 1354: }
1.36 ng 1355:
1.44 ng 1356: #---- Save the score and award for each student, if changed
1.38 ng 1357: sub saveHandGrade {
1.41 ng 1358: my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter) = @_;
1.44 ng 1359: my %record=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
1.41 ng 1360: my %newrecord;
1361: foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
1.43 ng 1362: if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {
1.44 ng 1363: $newrecord{'resource.'.$_.'.solved'} = 'excused'
1364: if ($record{'resource.'.$_.'.solved'} ne 'excused');
1.41 ng 1365: } else {
1.44 ng 1366: my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?
1367: $ENV{'form.GD_BOX'.$newflg.'_'.$_} :
1368: $ENV{'form.RADVAL'.$newflg.'_'.$_});
1369: my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
1370: $ENV{'form.WGT'.$newflg.'_'.$_};
1.41 ng 1371: my $partial= $pts/$wgt;
1.44 ng 1372: $newrecord{'resource.'.$_.'.awarded'} = $partial
1373: if ($record{'resource.'.$_.'.awarded'} ne $partial);
1374: my $reckey = 'resource.'.$_.'.solved';
1.41 ng 1375: if ($partial == 0) {
1.44 ng 1376: $newrecord{$reckey} = 'incorrect_by_override'
1377: if ($record{$reckey} ne 'incorrect_by_override');
1.41 ng 1378: } else {
1.44 ng 1379: $newrecord{$reckey} = 'correct_by_override'
1380: if ($record{$reckey} ne 'correct_by_override');
1.41 ng 1381: }
1.44 ng 1382: $newrecord{'resource.'.$_.'.submitted_by'} = $submitter
1383: if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));
1.41 ng 1384: }
1385: }
1.44 ng 1386:
1387: if (scalar(keys(%newrecord)) > 0) {
1.41 ng 1388: $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
1.44 ng 1389: &Apache::lonnet::cstore(\%newrecord,$symb,
1390: $ENV{'request.course.id'},$domain,$stuname);
1.41 ng 1391: }
1392: return '';
1.36 ng 1393: }
1.38 ng 1394:
1.44 ng 1395: #--------------------------------------------------------------------------------------
1396: #
1397: #-------------------------- Next few routines handles grading by section or whole class
1398: #
1399: #--- Javascript to handle grading by section or whole class
1.42 ng 1400: sub viewgrades_js {
1401: my ($request) = shift;
1402:
1.41 ng 1403: $request->print(<<VIEWJAVASCRIPT);
1404: <script type="text/javascript" language="javascript">
1.45 ! ng 1405: function writePoint(partid,weight,point) {
1.42 ng 1406: var radioButton = eval("document.classgrade.RADVAL_"+partid);
1407: var textbox = eval("document.classgrade.TEXTVAL_"+partid);
1408: if (point == "textval") {
1409: var point = eval("document.classgrade.TEXTVAL_"+partid+".value");
1410: if (isNaN(point) || point < 0) {
1411: alert("A number equal or greater than 0 is expected. Entered value = "+point);
1412: var resetbox = false;
1413: for (var i=0; i<radioButton.length; i++) {
1414: if (radioButton[i].checked) {
1415: textbox.value = i;
1416: resetbox = true;
1417: }
1418: }
1419: if (!resetbox) {
1420: textbox.value = "";
1421: }
1422: return;
1423: }
1.44 ng 1424: if (point > weight) {
1425: var resp = confirm("You entered a value ("+point+
1426: ") greater than the weight for the part. Accept?");
1427: if (resp == false) {
1428: textbox.value = "";
1429: return;
1430: }
1431: }
1.42 ng 1432: for (var i=0; i<radioButton.length; i++) {
1433: radioButton[i].checked=false;
1434: if (point == i) {
1435: radioButton[i].checked=true;
1436: }
1437: }
1.41 ng 1438:
1.42 ng 1439: } else {
1440: textbox.value = point;
1441: }
1.41 ng 1442: for (i=0;i<document.classgrade.total.value;i++) {
1.43 ng 1443: var user = eval("document.classgrade.ctr"+i+".value");
1444: var scorename = eval("document.classgrade.GD_"+user+
1445: "_"+partid+"_aw");
1446: var saveval = eval("document.classgrade.GD_"+user+
1447: "_"+partid+"_sv_s.value");
1448: var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_sv");
1.42 ng 1449: if (saveval != "correct") {
1450: scorename.value = point;
1.43 ng 1451: if (selname[0].selected != true) {
1452: selname[0].selected = true;
1453: }
1.42 ng 1454: }
1455: }
1456: var selval = eval("document.classgrade.SELVAL_"+partid);
1457: selval[0].selected = true;
1458: }
1459:
1460: function writeRadText(partid,weight) {
1461: var selval = eval("document.classgrade.SELVAL_"+partid);
1.43 ng 1462: var radioButton = eval("document.classgrade.RADVAL_"+partid);
1463: var textbox = eval("document.classgrade.TEXTVAL_"+partid);
1.42 ng 1464: if (selval[1].selected) {
1465: for (var i=0; i<radioButton.length; i++) {
1466: radioButton[i].checked=false;
1467:
1468: }
1469: textbox.value = "";
1470:
1471: for (i=0;i<document.classgrade.total.value;i++) {
1.43 ng 1472: var user = eval("document.classgrade.ctr"+i+".value");
1473: var scorename = eval("document.classgrade.GD_"+user+
1474: "_"+partid+"_aw");
1475: var saveval = eval("document.classgrade.GD_"+user+
1476: "_"+partid+"_sv_s.value");
1477: var selname = eval("document.classgrade.GD_"+user+
1478: "_"+partid+"_sv");
1.42 ng 1479: if (saveval != "correct") {
1480: scorename.value = "";
1481: selname[1].selected = true;
1482: }
1483: }
1.43 ng 1484: } else {
1485: for (i=0;i<document.classgrade.total.value;i++) {
1486: var user = eval("document.classgrade.ctr"+i+".value");
1487: var scorename = eval("document.classgrade.GD_"+user+
1488: "_"+partid+"_aw");
1489: var saveval = eval("document.classgrade.GD_"+user+
1490: "_"+partid+"_sv_s.value");
1491: var selname = eval("document.classgrade.GD_"+user+
1492: "_"+partid+"_sv");
1493: if (saveval != "correct") {
1494: scorename.value = eval("document.classgrade.GD_"+user+
1495: "_"+partid+"_aw_s.value");;
1496: selname[0].selected = true;
1497: }
1498: }
1499: }
1.42 ng 1500: }
1501:
1502: function changeSelect(partid,user) {
1.43 ng 1503: var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_sv");
1.44 ng 1504: var textbox = eval("document.classgrade.GD_"+user+'_'+partid+"_aw");
1505: var point = textbox.value;
1506: var weight = eval("document.classgrade.weight_"+partid+".value");
1507:
1508: if (isNaN(point) || point < 0) {
1509: alert("A number equal or greater than 0 is expected. Entered value = "+point);
1510: textbox.value = "";
1511: return;
1512: }
1513: if (point > weight) {
1514: var resp = confirm("You entered a value ("+point+
1515: ") greater than the weight of the part. Accept?");
1516: if (resp == false) {
1517: textbox.value = "";
1518: return;
1519: }
1520: }
1.42 ng 1521: selval[0].selected = true;
1522: }
1523:
1524: function changeOneScore(partid,user) {
1.43 ng 1525: var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_sv");
1.42 ng 1526: if (selval[1].selected) {
1.43 ng 1527: var boxval = eval("document.classgrade.GD_"+user+'_'+partid+"_aw");
1.42 ng 1528: boxval.value = "";
1529: }
1530: }
1531:
1532: function resetEntry(numpart) {
1533: for (ctpart=0;ctpart<numpart;ctpart++) {
1534: var partid = eval("document.classgrade.partid_"+ctpart+".value");
1535: var radioButton = eval("document.classgrade.RADVAL_"+partid);
1536: var textbox = eval("document.classgrade.TEXTVAL_"+partid);
1537: var selval = eval("document.classgrade.SELVAL_"+partid);
1538: for (var i=0; i<radioButton.length; i++) {
1539: radioButton[i].checked=false;
1540:
1541: }
1542: textbox.value = "";
1543: selval[0].selected = true;
1544:
1545: for (i=0;i<document.classgrade.total.value;i++) {
1.43 ng 1546: var user = eval("document.classgrade.ctr"+i+".value");
1547: var resetscore = eval("document.classgrade.GD_"+user+
1548: "_"+partid+"_aw");
1549: resetscore.value = eval("document.classgrade.GD_"+user+
1550: "_"+partid+"_aw_s.value");
1.42 ng 1551:
1.43 ng 1552: var saveselval = eval("document.classgrade.GD_"+user+
1553: "_"+partid+"_sv_s.value");
1.42 ng 1554:
1.43 ng 1555: var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_sv");
1.42 ng 1556: if (saveselval == "excused") {
1.43 ng 1557: if (selname[1].selected == false) { selname[1].selected = true;}
1.42 ng 1558: } else {
1.43 ng 1559: if (selname[0].selected == false) {selname[0].selected = true};
1.42 ng 1560: }
1561: }
1.41 ng 1562: }
1.42 ng 1563: }
1564:
1.41 ng 1565: </script>
1566: VIEWJAVASCRIPT
1.42 ng 1567: }
1568:
1.44 ng 1569: #--- show scores for a section or whole class w/ option to change/update a score
1.42 ng 1570: sub viewgrades {
1571: my ($request) = shift;
1572: &viewgrades_js($request);
1.41 ng 1573:
1574: my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'});
1.45 ! ng 1575: my $result='<h3><font color="#339933">Manual Grading</font></h3>';
1.38 ng 1576:
1.43 ng 1577: $result.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font>'."\n";
1.41 ng 1578:
1579: #view individual student submission form - called using Javascript viewOneStudent
1.45 ! ng 1580: $result.=&jscriptNform($url,$symb);
1.41 ng 1581:
1.44 ng 1582: #beginning of class grading form
1.41 ng 1583: $result.= '<form action="/adm/grades" method="post" name="classgrade">'."\n".
1584: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
1585: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
1.38 ng 1586: '<input type="hidden" name="command" value="editgrades" />'."\n".
1.41 ng 1587: '<input type="hidden" name="section" value="'.$ENV{'form.section'}.'" />'."\n";
1.42 ng 1588: $result.='To assign the same score for all the students use the radio buttons or '.
1589: 'text box below. To assign scores individually fill in the score boxes for '.
1.44 ng 1590: 'each student in the table below. <font color="red">A part that has already '.
1.42 ng 1591: 'been graded does not get changed using the radio buttons or text box. '.
1592: 'If needed, it has to be changed individually.</font>';
1593:
1.44 ng 1594: #radio buttons/text box for assigning points for a section or class.
1595: #handles different parts of a problem
1.42 ng 1596: my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
1597: my %weight = ();
1598: my $ctsparts = 0;
1.41 ng 1599: $result.='<table border="0">';
1.45 ! ng 1600: my %seen = ();
1.42 ng 1601: for (sort keys(%$handgrade)) {
1.45 ! ng 1602: my ($partid,$respid) = split (/_/);
! 1603: next if $seen{$partid};
! 1604: $seen{$partid}++;
1.42 ng 1605: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
1606: my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb);
1607: $weight{$partid} = $wgt eq '' ? '1' : $wgt;
1608:
1.44 ng 1609: $result.='<input type="hidden" name="partid_'.
1610: $ctsparts.'" value="'.$partid.'" />'."\n";
1611: $result.='<input type="hidden" name="weight_'.
1612: $partid.'" value="'.$weight{$partid}.'" />'."\n";
1613: $result.='<tr><td><b>Part '.$partid.' Point:</b> </td><td>';
1.42 ng 1614: $result.='<table border="0"><tr>';
1.41 ng 1615: my $ctr = 0;
1.42 ng 1616: while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across
1617: $result.= '<td><input type="radio" name="RADVAL_'.$partid.'" '.
1618: 'onclick="javascript:writePoint('.$partid.','.$weight{$partid}.
1.41 ng 1619: ','.$ctr.')" />'.$ctr."</td>\n";
1620: $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : '');
1621: $ctr++;
1622: }
1623: $result.='</tr></table>';
1.44 ng 1624: $result.= '</td><td><b> or </b><input type="text" name="TEXTVAL_'.
1625: $partid.'" size="4" '.
1626: 'onChange="javascript:writePoint('.$partid.','.$weight{$partid}.
1627: ',\'textval\')" /> /'.
1.42 ng 1628: $weight{$partid}.' (problem weight)</td>'."\n";
1629: $result.= '</td><td><select name="SELVAL_'.$partid.'"'.
1630: 'onChange="javascript:writeRadText('.$partid.','.$weight{$partid}.')" /> '.
1631: '<option selected="on"> </option>'.
1632: '<option>excused</option></select></td></tr>'."\n";
1633: $ctsparts++;
1.41 ng 1634: }
1.42 ng 1635: $result.='</table><input type="hidden" name="totalparts" value="'.$ctsparts.'" />';
1636: $result.='<input type="button" value="Reset" '.
1.43 ng 1637: 'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self> ';
1.45 ! ng 1638: $result.='<input type="button" value="Submit Changes" '.
! 1639: 'onClick="javascript:submit();" TARGET=_self />'."\n";
1.41 ng 1640:
1.44 ng 1641: #table listing all the students in a section/class
1642: #header of table
1.42 ng 1643: $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".
1.41 ng 1644: '<table border=0><tr bgcolor="#deffff">'.
1.44 ng 1645: '<td><b>Fullname</b></td><td><b>Username</b></td><td><b>Domain</b></td>'."\n";
1.41 ng 1646: my (@parts) = sort(&getpartlist($url));
1647: foreach my $part (@parts) {
1648: my $display=&Apache::lonnet::metadata($url,$part.'.display');
1649: next if ($display =~ /^Number of Attempts/);
1650: if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
1651: if ($display =~ /^Partial Credit Factor/) {
1652: $_ = $display;
1653: my ($partid) = /.*?(\d+).*/;
1.42 ng 1654: $result.='<td><b>Score Part '.$partid.'<br>(weight = '.
1655: $weight{$partid}.')</b></td>'."\n";
1.41 ng 1656: next;
1657: }
1.42 ng 1658: $display =~ s/Problem Status/Grade Status<br>/;
1.41 ng 1659: $result.='<td><b>'.$display.'</b></td>'."\n";
1660: }
1661: $result.='</tr>';
1.44 ng 1662:
1.41 ng 1663: #get info for each student
1.44 ng 1664: #list all the students - with points and grade status
1.41 ng 1665: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
1666: my $ctr = 0;
1.44 ng 1667: foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
1668: my ($uname,$udom) = split(/:/);
1669: $result.='<input type="hidden" name="ctr'.$ctr.'" value="'.$uname.'" />'."\n";
1.41 ng 1670: $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
1671: $_,$$fullname{$_},\@parts,\%weight);
1672: $ctr++;
1673: }
1674: $result.='</table></td></tr></table>';
1675: $result.='<input type="hidden" name="total" value="'.$ctr.'" />'."\n";
1.45 ! ng 1676: $result.='<input type="button" value="Submit Changes" '.
! 1677: 'onClick="javascript:submit();" TARGET=_self /></form>'."\n";
1.41 ng 1678: $result.=&show_grading_menu_form($symb,$url);
1679: return $result;
1680: }
1681:
1.44 ng 1682: #--- call by previous routine to display each student
1.41 ng 1683: sub viewstudentgrade {
1684: my ($url,$symb,$courseid,$student,$fullname,$parts,$weight) = @_;
1.44 ng 1685: my ($uname,$udom) = split(/:/,$student);
1686: my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
1.41 ng 1687: my $result='<tr bgcolor="#ffffdd"><td>'.
1.44 ng 1688: '<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom.
1689: '\')"; TARGET=_self>'.$fullname.'</a>'.
1690: '</td><td>'.$uname.'</td><td align="middle">'.$udom.'</td>'."\n";
1.41 ng 1691: foreach my $part (@$parts) {
1692: my ($temp,$part,$type)=split(/_/,$part);
1693: my $score=$record{"resource.$part.$type"};
1694: next if $type eq 'tries';
1695: if ($type eq 'awarded') {
1.42 ng 1696: my $pts = $score eq '' ? '' : $score*$$weight{$part};
1697: $result.='<input type="hidden" name="'.
1.44 ng 1698: 'GD_'.$uname.'_'.$part.'_aw_s" value="'.$pts.'" />'."\n";
1.42 ng 1699: $result.='<td align="middle"><input type="text" name="'.
1.44 ng 1700: 'GD_'.$uname.'_'.$part.'_aw" '.
1701: 'onChange="javascript:changeSelect('.$part.',\''.$uname.
1702: '\')" value="'.$pts.'" size="4" /></td>'."\n";
1.41 ng 1703: } elsif ($type eq 'solved') {
1704: my ($status,$foo)=split(/_/,$score,2);
1705: $status = 'nothing' if ($status eq '');
1.42 ng 1706: $result.='<input type="hidden" name="'.
1.44 ng 1707: 'GD_'.$uname.'_'.$part.'_sv_s" value="'.$status.'" />'."\n";
1.42 ng 1708: $result.='<td align="middle"><select name="'.
1.44 ng 1709: 'GD_'.$uname.'_'.$part.'_sv" '.
1710: 'onChange="javascript:changeOneScore('.$part.',\''.$uname.'\')" >'."\n";
1.42 ng 1711: my $optsel = '<option selected="on"> </option><option>excused</option>'."\n";
1712: $optsel = '<option> </option><option selected="on">excused</option>'."\n"
1713: if ($status eq 'excused');
1.41 ng 1714: $result.=$optsel;
1715: $result.="</select></td>\n";
1716: }
1717: }
1718: $result.='</tr>';
1719: return $result;
1.38 ng 1720: }
1721:
1.44 ng 1722: #--- change scores for all the students in a section/class
1723: # record does not get update if unchanged
1.38 ng 1724: sub editgrades {
1.41 ng 1725: my ($request) = @_;
1726:
1727: my $symb=$ENV{'form.symb'};
1.43 ng 1728: my $url =$ENV{'form.url'};
1.45 ! ng 1729: my $title='<h3><font color="#339933">Current Grade Status</font></h3>';
1.44 ng 1730: $title.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br />'."\n";
1731: $title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n";
1732: $title.= &show_grading_menu_form ($symb,$url);
1733: my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n";
1.43 ng 1734: $result.= '<table border="0"><tr bgcolor="#deffff">'.
1735: '<td rowspan=2><b>Username</b></td><td rowspan=2><b>Fullname</b></td>'."\n";
1736:
1737: my %scoreptr = (
1738: 'correct' =>'correct_by_override',
1739: 'incorrect'=>'incorrect_by_override',
1740: 'excused' =>'excused',
1741: 'ungraded' =>'ungraded_attempted',
1742: 'nothing' => '',
1743: );
1744: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
1.34 ng 1745:
1.44 ng 1746: my (@partid);
1747: my %weight = ();
1748: my ($i,$ctr,$count,$rec_update) = (0,0,0,0);
1749: while ($ctr < $ENV{'form.totalparts'}) {
1750: my $partid = $ENV{'form.partid_'.$ctr};
1751: push @partid,$partid;
1752: $weight{$partid} = $ENV{'form.weight_'.$partid};
1753: $ctr++;
1754: $result .= '<td colspan = 2 align="center"><b>Part '.$partid.
1755: '</b> (Weight = '.$weight{$partid}.')</td>';
1756: }
1757: $result .= '</tr><tr bgcolor="#deffff">';
1758: foreach (@partid) {
1759: $result .= '<td align="center"> <b>Old Score</b> </td>'.
1760: '<td align="center"> <b>New Score</b> </td>';
1761: }
1762: $result .= '</tr>'."\n";
1.13 albertel 1763:
1.44 ng 1764: for ($i=0; $i<$ENV{'form.total'}; $i++) {
1765: my $user = $ENV{'form.ctr'.$i};
1766: my %newrecord;
1767: my $updateflag = 0;
1768: my @userdom = grep /^$user:/,keys %$classlist;
1769: my ($foo,$udom) = split(/:/,$userdom[0]);
1.13 albertel 1770:
1.44 ng 1771: $result .= '<tr bgcolor="#ffffde"><td>'.$user.' </td><td>'.
1772: $$fullname{$userdom[0]}.' </td>';
1.13 albertel 1773:
1.44 ng 1774: foreach (@partid) {
1775: my $old_aw = $ENV{'form.GD_'.$user.'_'.$_.'_aw_s'};
1776: my $old_part = $old_aw eq '' ? '' : $old_aw/$weight{$_};
1777: my $old_score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_sv_s'}};
1.38 ng 1778:
1.44 ng 1779: my $awarded = $ENV{'form.GD_'.$user.'_'.$_.'_aw'};
1780: my $partial = $awarded eq '' ? '' : $awarded/$weight{$_};
1781: my $score;
1782: if ($partial eq '') {
1783: $score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_sv_s'}};
1784: } elsif ($partial > 0) {
1785: $score = 'correct_by_override';
1786: } elsif ($partial == 0) {
1787: $score = 'incorrect_by_override';
1788: }
1789: $score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_sv'} eq 'excused') &&
1790: ($score ne 'excused'));
1791: $result .= '<td align="center">'.$old_aw.' </td>'.
1792: '<td align="center">'.$awarded.
1793: ($score eq 'excused' ? $score : '').' </td>';
1.5 albertel 1794:
1.44 ng 1795: next if ($old_part eq $partial && $old_score eq $score);
1.5 albertel 1796:
1.44 ng 1797: $updateflag = 1;
1798: $newrecord{'resource.'.$_.'.awarded'} = $partial if $partial ne '';
1799: $newrecord{'resource.'.$_.'.solved'} = $score;
1800: $rec_update++;
1801: }
1802: $result .= '</tr>'."\n";
1803: if ($updateflag) {
1804: $count++;
1805: $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
1806: &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
1807: $udom,$user);
1808: }
1809: }
1810: $result .= '</table></td></tr></table>'."\n";
1811: my $msg = '<b>Number of records updated = '.$rec_update.
1812: ' for '.$count.' student'.($count <= 1 ? '' : 's').'.</b><br />'.
1813: '<b>Total number of students = '.$ENV{'form.total'}.'</b><br />';
1814: return $title.$msg.$result;
1.5 albertel 1815: }
1.44 ng 1816: #------------- end of section for handling grading by section/class ---------
1817: #
1818: #----------------------------------------------------------------------------
1819:
1.5 albertel 1820:
1.44 ng 1821: #----------------------------------------------------------------------------
1822: #
1823: #-------------------------- Next few routines handles grading by csv upload
1824: #
1825: #--- Javascript to handle csv upload
1.27 albertel 1826: sub csvupload_javascript_reverse_associate {
1827: return(<<ENDPICK);
1828: function verify(vf) {
1829: var foundsomething=0;
1830: var founduname=0;
1831: var founddomain=0;
1832: for (i=0;i<=vf.nfields.value;i++) {
1833: tw=eval('vf.f'+i+'.selectedIndex');
1834: if (i==0 && tw!=0) { founduname=1; }
1835: if (i==1 && tw!=0) { founddomain=1; }
1836: if (i!=0 && i!=1 && tw!=0) { foundsomething=1; }
1837: }
1838: if (founduname==0 || founddomain==0) {
1839: alert('You need to specify at both the username and domain');
1840: return;
1841: }
1842: if (foundsomething==0) {
1843: alert('You need to specify at least one grading field');
1844: return;
1845: }
1846: vf.submit();
1847: }
1848: function flip(vf,tf) {
1849: var nw=eval('vf.f'+tf+'.selectedIndex');
1850: var i;
1851: for (i=0;i<=vf.nfields.value;i++) {
1852: //can not pick the same destination field for both name and domain
1853: if (((i ==0)||(i ==1)) &&
1854: ((tf==0)||(tf==1)) &&
1855: (i!=tf) &&
1856: (eval('vf.f'+i+'.selectedIndex')==nw)) {
1857: eval('vf.f'+i+'.selectedIndex=0;')
1858: }
1859: }
1860: }
1861: ENDPICK
1862: }
1863:
1864: sub csvupload_javascript_forward_associate {
1865: return(<<ENDPICK);
1866: function verify(vf) {
1867: var foundsomething=0;
1868: var founduname=0;
1869: var founddomain=0;
1870: for (i=0;i<=vf.nfields.value;i++) {
1871: tw=eval('vf.f'+i+'.selectedIndex');
1872: if (tw==1) { founduname=1; }
1873: if (tw==2) { founddomain=1; }
1874: if (tw>2) { foundsomething=1; }
1875: }
1876: if (founduname==0 || founddomain==0) {
1877: alert('You need to specify at both the username and domain');
1878: return;
1879: }
1880: if (foundsomething==0) {
1881: alert('You need to specify at least one grading field');
1882: return;
1883: }
1884: vf.submit();
1885: }
1886: function flip(vf,tf) {
1887: var nw=eval('vf.f'+tf+'.selectedIndex');
1888: var i;
1889: //can not pick the same destination field twice
1890: for (i=0;i<=vf.nfields.value;i++) {
1891: if ((i!=tf) && (eval('vf.f'+i+'.selectedIndex')==nw)) {
1892: eval('vf.f'+i+'.selectedIndex=0;')
1893: }
1894: }
1895: }
1896: ENDPICK
1897: }
1898:
1.26 albertel 1899: sub csvuploadmap_header {
1.41 ng 1900: my ($request,$symb,$url,$datatoken,$distotal)= @_;
1901: my $javascript;
1902: if ($ENV{'form.upfile_associate'} eq 'reverse') {
1903: $javascript=&csvupload_javascript_reverse_associate();
1904: } else {
1905: $javascript=&csvupload_javascript_forward_associate();
1906: }
1.45 ! ng 1907:
! 1908: my $result='<table border="0">';
! 1909: $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';
! 1910: my ($partlist,$handgrade) = &response_type($url);
! 1911: my ($resptype,$hdgrade)=('','no');
! 1912: for (sort keys(%$handgrade)) {
! 1913: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
! 1914: $resptype = $responsetype;
! 1915: $hdgrade = $handgrade if ($handgrade eq 'yes');
! 1916: $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
! 1917: '<td><b>Type: </b>'.$responsetype.'</td>'.
! 1918: '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
! 1919: }
! 1920: $result.='</table>';
1.41 ng 1921: $request->print(<<ENDPICK);
1.26 albertel 1922: <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
1.45 ! ng 1923: <h3><font color="#339933">Uploading Class Grades</font></h3>
! 1924: $result
1.26 albertel 1925: <hr>
1926: <h3>Identify fields</h3>
1927: Total number of records found in file: $distotal <hr />
1928: Enter as many fields as you can. The system will inform you and bring you back
1929: to this page if the data selected is insufficient to run your class.<hr />
1930: <input type="button" value="Reverse Association" onClick="javascript:this.form.associate.value='Reverse Association';submit(this.form);" />
1931: <input type="hidden" name="associate" value="" />
1932: <input type="hidden" name="phase" value="three" />
1933: <input type="hidden" name="datatoken" value="$datatoken" />
1934: <input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" />
1935: <input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" />
1936: <input type="hidden" name="upfile_associate"
1937: value="$ENV{'form.upfile_associate'}" />
1938: <input type="hidden" name="symb" value="$symb" />
1939: <input type="hidden" name="url" value="$url" />
1940: <input type="hidden" name="command" value="csvuploadassign" />
1941: <hr />
1942: <script type="text/javascript" language="Javascript">
1943: $javascript
1944: </script>
1945: ENDPICK
1.41 ng 1946: return '';
1.26 albertel 1947:
1948: }
1949:
1950: sub csvupload_fields {
1.41 ng 1951: my ($url) = @_;
1952: my (@parts) = &getpartlist($url);
1953: my @fields=(['username','Student Username'],['domain','Student Domain']);
1954: foreach my $part (sort(@parts)) {
1955: my @datum;
1956: my $display=&Apache::lonnet::metadata($url,$part.'.display');
1957: my $name=$part;
1958: if (!$display) { $display = $name; }
1959: @datum=($name,$display);
1960: push(@fields,\@datum);
1961: }
1962: return (@fields);
1.26 albertel 1963: }
1964:
1965: sub csvuploadmap_footer {
1.41 ng 1966: my ($request,$i,$keyfields) =@_;
1967: $request->print(<<ENDPICK);
1.26 albertel 1968: </table>
1969: <input type="hidden" name="nfields" value="$i" />
1970: <input type="hidden" name="keyfields" value="$keyfields" />
1971: <input type="button" onClick="javascript:verify(this.form)" value="Assign Grades" /><br />
1972: </form>
1973: ENDPICK
1974: }
1975:
1976: sub csvuploadmap {
1.41 ng 1977: my ($request)= @_;
1978: my ($symb,$url)=&get_symb_and_url($request);
1979: if (!$symb) {return '';}
1980: my $datatoken;
1981: if (!$ENV{'form.datatoken'}) {
1982: $datatoken=&Apache::loncommon::upfile_store($request);
1.26 albertel 1983: } else {
1.41 ng 1984: $datatoken=$ENV{'form.datatoken'};
1985: &Apache::loncommon::load_tmp_file($request);
1.26 albertel 1986: }
1.41 ng 1987: my @records=&Apache::loncommon::upfile_record_sep();
1988: &csvuploadmap_header($request,$symb,$url,$datatoken,$#records+1);
1989: my ($i,$keyfields);
1990: if (@records) {
1991: my @fields=&csvupload_fields($url);
1.45 ! ng 1992:
1.41 ng 1993: if ($ENV{'form.upfile_associate'} eq 'reverse') {
1994: &Apache::loncommon::csv_print_samples($request,\@records);
1995: $i=&Apache::loncommon::csv_print_select_table($request,\@records,
1996: \@fields);
1997: foreach (@fields) { $keyfields.=$_->[0].','; }
1998: chop($keyfields);
1999: } else {
2000: unshift(@fields,['none','']);
2001: $i=&Apache::loncommon::csv_samples_select_table($request,\@records,
2002: \@fields);
2003: my %sone=&Apache::loncommon::record_sep($records[0]);
2004: $keyfields=join(',',sort(keys(%sone)));
2005: }
2006: }
2007: &csvuploadmap_footer($request,$i,$keyfields);
2008: return '';
1.27 albertel 2009: }
2010:
2011: sub csvuploadassign {
1.41 ng 2012: my ($request)= @_;
2013: my ($symb,$url)=&get_symb_and_url($request);
2014: if (!$symb) {return '';}
2015: &Apache::loncommon::load_tmp_file($request);
1.44 ng 2016: my @gradedata = &Apache::loncommon::upfile_record_sep();
1.41 ng 2017: my @keyfields = split(/\,/,$ENV{'form.keyfields'});
2018: my %fields=();
2019: for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
2020: if ($ENV{'form.upfile_associate'} eq 'reverse') {
2021: if ($ENV{'form.f'.$i} ne 'none') {
2022: $fields{$keyfields[$i]}=$ENV{'form.f'.$i};
2023: }
2024: } else {
2025: if ($ENV{'form.f'.$i} ne 'none') {
2026: $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
2027: }
2028: }
1.27 albertel 2029: }
1.41 ng 2030: $request->print('<h3>Assigning Grades</h3>');
2031: my $courseid=$ENV{'request.course.id'};
1.34 ng 2032: # my $cdom=$ENV{"course.$courseid.domain"};
2033: # my $cnum=$ENV{"course.$courseid.num"};
1.41 ng 2034: my ($classlist) = &getclasslist('all','1');
2035: my @skipped;
2036: my $countdone=0;
2037: foreach my $grade (@gradedata) {
2038: my %entries=&Apache::loncommon::record_sep($grade);
2039: my $username=$entries{$fields{'username'}};
2040: my $domain=$entries{$fields{'domain'}};
2041: if (!exists($$classlist{"$username:$domain"})) {
2042: push(@skipped,"$username:$domain");
2043: next;
2044: }
2045: my %grades;
2046: foreach my $dest (keys(%fields)) {
2047: if ($dest eq 'username' || $dest eq 'domain') { next; }
2048: if ($entries{$fields{$dest}} eq '') { next; }
2049: my $store_key=$dest;
2050: $store_key=~s/^stores/resource/;
2051: $store_key=~s/_/\./g;
2052: $grades{$store_key}=$entries{$fields{$dest}};
2053: }
2054: $grades{"resource.regrader"}="$ENV{'user.name'}:$ENV{'user.domain'}";
2055: &Apache::lonnet::cstore(\%grades,$symb,$ENV{'request.course.id'},
2056: $domain,$username);
2057: $request->print('.');
2058: $request->rflush();
2059: $countdone++;
2060: }
2061: $request->print("<br />Stored $countdone students\n");
2062: if (@skipped) {
2063: $request->print('<br /><font size="+1"><b>Skipped Students</b></font><br />');
2064: foreach my $student (@skipped) { $request->print("<br />$student"); }
2065: }
2066: $request->print(&view_edit_entire_class_form($symb,$url));
2067: $request->print(&show_grading_menu_form($symb,$url));
2068: return '';
1.26 albertel 2069: }
1.44 ng 2070: #------------- end of section for handling csv file upload ---------
2071: #
2072: #-------------------------------------------------------------------
2073:
2074: #-------------------------- Menu interface -------------------------
2075: #
2076: #--- Show a Grading Menu button - Calls the next routine ---
2077: sub show_grading_menu_form {
2078: my ($symb,$url)=@_;
2079: my $result.='<form action="/adm/grades" method="post">'."\n".
2080: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
2081: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
2082: '<input type="hidden" name="command" value="gradingmenu" />'."\n".
2083: '<input type="submit" name="submit" value="Grading Menu" />'."\n".
2084: '</form>'."\n";
2085: return $result;
2086: }
2087:
2088: #--- Displays the main menu page -------
2089: sub gradingmenu {
2090: my ($request) = @_;
2091: my ($symb,$url)=&get_symb_and_url($request);
2092: if (!$symb) {return '';}
1.45 ! ng 2093: my $result='<h3> <font color="#339933">Select a Grading Method</font></h3>';
1.44 ng 2094: $result.='<table border="0">';
2095: $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';
2096: my ($partlist,$handgrade) = &response_type($url);
2097: my ($resptype,$hdgrade)=('','no');
2098: for (sort keys(%$handgrade)) {
2099: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
2100: $resptype = $responsetype;
2101: $hdgrade = $handgrade if ($handgrade eq 'yes');
2102: $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
2103: '<td><b>Type: </b>'.$responsetype.'</td>'.
2104: '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
2105: }
2106: $result.='</table>';
2107: $result.=&view_edit_entire_class_form($symb,$url).'<br />';
2108: $result.=&upcsvScores_form($symb,$url).'<br />';
2109: $result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />';
2110: $result.=&verifyReceipt_form($symb,$url)
2111: if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb));
2112:
2113: return $result;
2114: }
2115:
2116: #--- Menu for grading a section or the whole class ---
2117: sub view_edit_entire_class_form {
2118: my ($symb,$url)=@_;
2119: my ($classlist,$sections) = &getclasslist('all','0');
2120: my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
2121: $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
2122: $result.=' <b>View/Grade Entire Section/Class</b></td></tr>'."\n";
2123: $result.='<tr bgcolor=#ffffe6><td>'."\n";
2124: $result.='<form action="/adm/grades" method="post">'."\n".
2125: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
2126: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
2127: '<input type="hidden" name="command" value="viewgrades" />'."\n";
2128: $result.=' <b>Select section:</b> <select name="section">'."\n";
2129: foreach (sort (@$sections)) {
2130: $result.= '<option>'.$_.'</option>'."\n";
2131: }
2132: $result.='<option selected="on">all</select>'."<br />\n";
2133: $result.=' <input type="submit" name="submit" value="View/Grade" /></form>'."\n";
2134: $result.='</td></tr></table>'."\n";
2135: $result.='</td></tr></table>'."\n";
2136: return $result;
2137: }
2138:
2139: #--- Menu to upload a csv scores ---
2140: sub upcsvScores_form {
2141: my ($symb,$url) = @_;
2142: if (!$symb) {return '';}
2143: my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
2144: $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
2145: $result.=' <b>Specify a file containing the class scores for above resource</b></td></tr>'."\n";
2146: $result.='<tr bgcolor=#ffffe6><td>'."\n";
2147: my $upfile_select=&Apache::loncommon::upfile_select_html();
2148: $result.=<<ENDUPFORM;
2149: <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
2150: <input type="hidden" name="symb" value="$symb" />
2151: <input type="hidden" name="url" value="$url" />
2152: <input type="hidden" name="command" value="csvuploadmap" />
2153: $upfile_select
2154: <br /> <input type="submit" name="submit" value="Upload Grades" />
2155: </form>
2156: ENDUPFORM
2157: $result.='</td></tr></table>'."\n";
2158: $result.='</td></tr></table>'."\n";
2159: return $result;
2160: }
2161:
2162: #--- Handgrading problems ---
2163: sub viewGradeaStu_form {
2164: my ($symb,$url,$response,$handgrade) = @_;
2165: my ($classlist,$sections) = &getclasslist('all','0');
2166: my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
2167: $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
2168: $result.=' <b>View/Grade an Individual Student\'s Submission</b></td></tr>'."\n";
2169: $result.='<tr bgcolor=#ffffe6><td>'."\n";
2170: $result.='<form action="/adm/grades" method="post">'."\n".
2171: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
2172: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
2173: '<input type="hidden" name="response" value="'.$response.'" />'."\n".
2174: '<input type="hidden" name="handgrade" value="'.$handgrade.'" />'."\n".
2175: '<input type="hidden" name="showgrading" value="yes" />'."\n".
2176: '<input type="hidden" name="command" value="submission" />'."\n";
1.26 albertel 2177:
1.44 ng 2178: $result.=' <b>Select section:</b> <select name="section">'."\n";
2179: foreach (sort (@$sections)) {
2180: $result.= '<option>'.$_.'</option>'."\n";
2181: }
2182: $result.= '<option selected="on">all</select>'."\n";
2183: $result.=' <b>Display students who has: </b>'.
2184: '<input type="radio" name="submitonly" value="yes" checked> submitted'.
2185: '<input type="radio" name="submitonly" value="all"> everybody <br />';
2186: $result.=' (Section "no" implies the students were not assigned a section.)<br />'
2187: if (grep /no/,@$sections);
2188:
2189: $result.='<br /> <input type="submit" name="submit" value="View/Grade" />'."\n".
2190: '</form>'."\n";
2191: $result.='</td></tr></table>'."\n";
2192: $result.='</td></tr></table>'."\n";
2193: return $result;
1.2 albertel 2194: }
2195:
1.44 ng 2196: #--- Form to input a receipt number ---
2197: sub verifyReceipt_form {
2198: my ($symb,$url) = @_;
2199: my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};
2200: my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};
2201: my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
2202:
2203: my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
2204: $result.='<table width=100% border=0><tr><td bgcolor=#e6ffff>'."\n";
2205: $result.=' <b>Verify a Submission Receipt Issued by this Server</td></tr>'."\n";
2206: $result.='<tr bgcolor=#ffffe6><td>'."\n";
2207: $result.='<form action="/adm/grades" method="post">'."\n";
2208: $result.=' <tt>'.$hostver.'-<input type="text" name="receipt" size="4"></tt><br />'."\n";
2209: $result.=' <input type="submit" name="submit" value="Verify Receipt">'."\n";
2210: $result.='<input type="hidden" name="command" value="verify">'."\n";
2211: if ($ENV{'form.url'}) {
2212: $result.='<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />';
2213: }
2214: if ($ENV{'form.symb'}) {
2215: $result.='<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />';
2216: }
2217: $result.='</form>';
2218: $result.='</td></tr></table>'."\n";
2219: $result.='</td></tr></table>'."\n";
2220: return $result;
1.2 albertel 2221: }
2222:
1.1 albertel 2223: sub handler {
1.41 ng 2224: my $request=$_[0];
2225:
2226: if ($ENV{'browser.mathml'}) {
2227: $request->content_type('text/xml');
2228: } else {
2229: $request->content_type('text/html');
2230: }
2231: $request->send_http_header;
1.44 ng 2232: return '' if $request->header_only;
1.41 ng 2233: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
2234: my $url=$ENV{'form.url'};
2235: my $symb=$ENV{'form.symb'};
2236: my $command=$ENV{'form.command'};
2237: if (!$url) {
2238: my ($temp1,$temp2);
2239: ($temp1,$temp2,$ENV{'form.url'})=split(/___/,$symb);
2240: $url = $ENV{'form.url'};
2241: }
2242: &send_header($request);
2243: if ($url eq '' && $symb eq '') {
2244: if ($ENV{'user.adv'}) {
2245: if (($ENV{'form.codeone'}) && ($ENV{'form.codetwo'}) &&
2246: ($ENV{'form.codethree'})) {
2247: my $token=$ENV{'form.codeone'}.'*'.$ENV{'form.codetwo'}.'*'.
2248: $ENV{'form.codethree'};
2249: my ($tsymb,$tuname,$tudom,$tcrsid)=
2250: &Apache::lonnet::checkin($token);
2251: if ($tsymb) {
2252: my ($map,$id,$url)=split(/\_\_\_/,$tsymb);
2253: if (&Apache::lonnet::allowed('mgr',$tcrsid)) {
2254: $request->print(
2255: &Apache::lonnet::ssi('/res/'.$url,
2256: ('grade_username' => $tuname,
2257: 'grade_domain' => $tudom,
2258: 'grade_courseid' => $tcrsid,
2259: 'grade_symb' => $tsymb)));
2260: } else {
1.45 ! ng 2261: $request->print('<h3>Not authorized: '.$token.'</h3>');
1.41 ng 2262: }
2263: } else {
1.45 ! ng 2264: $request->print('<h3>Not a valid DocID: '.$token.'</h3>');
1.41 ng 2265: }
1.14 www 2266: } else {
1.41 ng 2267: $request->print(&Apache::lonxml::tokeninputfield());
2268: }
2269: }
2270: } else {
2271: #&Apache::lonhomework::showhashsubset(\%ENV,'^form');
2272: $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
2273: if ($command eq 'submission') {
2274: &listStudents($request) if ($ENV{'form.student'} eq '');
2275: &submission($request,0,0) if ($ENV{'form.student'} ne '');
2276: } elsif ($command eq 'processGroup') {
2277: &processGroup($request);
2278: } elsif ($command eq 'gradingmenu') {
2279: $request->print(&gradingmenu($request));
2280: } elsif ($command eq 'viewgrades') {
2281: $request->print(&viewgrades($request));
2282: } elsif ($command eq 'handgrade') {
2283: $request->print(&processHandGrade($request));
2284: } elsif ($command eq 'editgrades') {
2285: $request->print(&editgrades($request));
2286: } elsif ($command eq 'verify') {
2287: $request->print(&verifyreceipt($request));
2288: } elsif ($command eq 'csvupload') {
2289: $request->print(&csvupload($request));
2290: } elsif ($command eq 'viewclasslist') {
2291: $request->print(&viewclasslist($request));
2292: } elsif ($command eq 'csvuploadmap') {
2293: $request->print(&csvuploadmap($request));
2294: } elsif ($command eq 'csvuploadassign') {
2295: if ($ENV{'form.associate'} ne 'Reverse Association') {
2296: $request->print(&csvuploadassign($request));
2297: } else {
2298: if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
2299: $ENV{'form.upfile_associate'} = 'reverse';
2300: } else {
2301: $ENV{'form.upfile_associate'} = 'forward';
2302: }
2303: $request->print(&csvuploadmap($request));
2304: }
1.26 albertel 2305: } else {
1.41 ng 2306: $request->print("Unknown action: $command:");
1.26 albertel 2307: }
1.2 albertel 2308: }
1.41 ng 2309: &send_footer($request);
1.44 ng 2310: return '';
2311: }
2312:
2313: sub send_header {
2314: my ($request)= @_;
2315: $request->print(&Apache::lontexconvert::header());
2316: # $request->print("
2317: #<script>
2318: #remotewindow=open('','homeworkremote');
2319: #remotewindow.close();
2320: #</script>");
2321: $request->print('<body bgcolor="#FFFFFF">');
2322: }
2323:
2324: sub send_footer {
2325: my ($request)= @_;
2326: $request->print('</body>');
2327: $request->print(&Apache::lontexconvert::footer());
1.1 albertel 2328: }
2329:
2330: 1;
2331:
1.13 albertel 2332: __END__;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>