Annotation of loncom/homework/grades.pm, revision 1.49
1.17 albertel 1: # The LearningOnline Network with CAPA
1.13 albertel 2: # The LON-CAPA Grading handler
1.17 albertel 3: #
1.49 ! albertel 4: # $Id: grades.pm,v 1.48 2002/09/06 20:59:28 albertel 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: #
48: # --- Retrieve the parts that matches stores_\d+ from the metadata file.---
49: sub getpartlist {
50: my ($url) = @_;
51: my @parts =();
52: my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys'));
53: foreach my $key (@metakeys) {
54: if ( $key =~ m/stores_([0-9]+)_.*/) {
55: push(@parts,$key);
1.41 ng 56: }
1.16 albertel 57: }
1.44 ng 58: return @parts;
1.2 albertel 59: }
60:
1.44 ng 61: # --- Get the symbolic name of a problem and the url
62: sub get_symb_and_url {
63: my ($request) = @_;
64: (my $url=$ENV{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.41 ng 65: my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
1.44 ng 66: if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
67: return ($symb,$url);
1.32 ng 68: }
69:
1.44 ng 70: # --- Retrieve the fullname for a user. Return lastname, first middle ---
71: # --- Generation is attached next to the lastname if it exists. ---
1.34 ng 72: sub get_fullname {
1.39 ng 73: my ($uname,$udom) = @_;
1.34 ng 74: my %name=&Apache::lonnet::get('environment', ['lastname','generation',
1.41 ng 75: 'firstname','middlename'],$udom,$uname);
1.34 ng 76: my $fullname;
77: my ($tmp) = keys(%name);
78: if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
79: $fullname=$name{'lastname'}.$name{'generation'};
80: if ($fullname =~ /[^\s]+/) { $fullname.=', '; }
81: $fullname.=$name{'firstname'}.' '.$name{'middlename'};
82: }
83: return $fullname;
84: }
85:
1.44 ng 86: #--- Get the partlist and the response type for a given problem. ---
87: #--- Indicate if a response type is coded handgraded or not. ---
1.39 ng 88: sub response_type {
1.41 ng 89: my ($url) = shift;
90: my $allkeys = &Apache::lonnet::metadata($url,'keys');
91: my %seen = ();
92: my (@partlist,%handgrade);
93: foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
1.43 ng 94: if (/^\w+response_\d+.*/) {
1.41 ng 95: my ($responsetype,$part) = split(/_/,$_,2);
96: my ($partid,$respid) = split(/_/,$part);
97: $handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no');
98: next if ($seen{$partid} > 0);
99: $seen{$partid}++;
100: push @partlist,$partid;
101: }
102: }
103: return \@partlist,\%handgrade;
1.39 ng 104: }
105:
1.44 ng 106: #--- Dumps the class list with usernames,list of sections,
107: #--- section, ids and fullnames for each user.
108: sub getclasslist {
109: my ($getsec,$hideexpired) = @_;
110: my $now = time;
111: my %classlist=&Apache::lonnet::dump('classlist',
112: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
113: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.49 ! albertel 114: my ($tmp) = keys(%classlist);
! 115: # Bail out if we were unable to get the classlist
! 116: return if ($tmp =~ /^(con_lost|error|no_such_host)/i);
! 117:
1.44 ng 118: # codes to check for fields in the classlist
119: # should contain end:start:id:section:fullname
120: for (keys %classlist) {
121: my (@fields) = split(/:/,$classlist{$_});
122: %classlist = &reformat_classlist(\%classlist) if (scalar(@fields) <= 2);
123: last;
124: }
125:
126: my (@holdsec,@sections,%allids,%stusec,%fullname);
127: foreach (keys(%classlist)) {
128: my ($end,$start,$id,$section,$fullname)=split(/:/,$classlist{$_});
129: # still a student?
130: if (($hideexpired) && ($end) && ($end < $now)) {
131: next;
132: }
133: $section = ($section ne '' ? $section : 'no');
134: push @holdsec,$section;
135: if ($getsec eq 'all' || $getsec eq $section) {
136: push (@{ $classlist{$getsec} }, $_);
137: $allids{$_} =$id;
138: $stusec{$_} =$section;
139: $fullname{$_}=$fullname;
140: }
141: }
142: my %seen = ();
143: foreach my $item (@holdsec) {
144: push (@sections, $item) unless $seen{$item}++;
145: }
146: return (\%classlist,\@sections,\%allids,\%stusec,\%fullname);
147: }
148:
149: # add id, section and fullname to the classlist.db
150: # done to maintain backward compatibility with older versions
151: sub reformat_classlist {
152: my ($classlist) = shift;
153: foreach (sort keys(%$classlist)) {
154: my ($unam,$udom) = split(/:/);
155: my $section = &Apache::lonnet::usection($udom,$unam,$ENV{'request.course.id'});
156: my $fullname = &get_fullname ($unam,$udom);
157: my %userid = &Apache::lonnet::idrget($udom,($unam));
158: $$classlist{$_} = $$classlist{$_}.':'.$userid{$unam}.':'.$section.':'.$fullname;
159: }
160: my $putresult = &Apache::lonnet::put
161: ('classlist',\%$classlist,
162: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
163: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
164:
165: return %$classlist;
166: }
167:
168: #find user domain
169: sub finduser {
170: my ($name) = @_;
171: my $domain = '';
172: if ( $Apache::grades::viewgrades eq 'F' ) {
173: my %classlist=&Apache::lonnet::dump('classlist',
174: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
175: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
176: my (@fields) = grep /^$name:/, keys %classlist;
177: ($name, $domain) = split(/:/,$fields[0]);
178: return ($name,$domain);
179: } else {
180: return ($ENV{'user.name'},$ENV{'user.domain'});
181: }
182: }
183:
184: #--- Prompts a user to enter a username.
185: sub moreinfo {
186: my ($request,$reason) = @_;
187: $request->print("Unable to process request: $reason");
188: if ( $Apache::grades::viewgrades eq 'F' ) {
189: $request->print('<form action="/adm/grades" method="post">'."\n");
190: if ($ENV{'form.url'}) {
191: $request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />'."\n");
192: }
193: if ($ENV{'form.symb'}) {
194: $request->print('<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'."\n");
195: }
196: $request->print('<input type="hidden" name="command" value="'.$ENV{'form.command'}.'" />'."\n");
197: $request->print("Student:".'<input type="text" name="student" value="'.$ENV{'form.student'}.'" />'."<br />\n");
198: $request->print("Domain:".'<input type="text" name="domain" value="'.$ENV{'user.domain'}.'" />'."<br />\n");
199: $request->print('<input type="submit" name="submit" value="ReSubmit" />'."<br />\n");
200: $request->print('</form>');
201: }
202: return '';
203: }
204:
205: #--- Retrieve the grade status of a student for all the parts
206: sub student_gradeStatus {
207: my ($url,$symb,$udom,$uname,$partlist) = @_;
208: my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
209: my %partstatus = ();
210: foreach (@$partlist) {
211: my ($status,$foo) = split(/_/,$record{"resource.$_.solved"},2);
212: $status = 'nothing' if ($status eq '');
213: $partstatus{$_} = $status;
214: my $subkey = "resource.$_.submitted_by";
215: $partstatus{$subkey} = $record{$subkey} if ($record{$subkey} ne '');
216: }
217: return %partstatus;
218: }
219:
1.45 ng 220: # hidden form and javascript that calls the form
221: # Use by verifyscript and viewgrades
222: # Shows a student's view of problem and submission
223: sub jscriptNform {
224: my ($url,$symb) = @_;
225: my $jscript='<script type="text/javascript" language="javascript">'."\n".
226: ' function viewOneStudent(user,domain) {'."\n".
227: ' document.onestudent.student.value = user;'."\n".
228: ' document.onestudent.userdom.value = domain;'."\n".
229: ' document.onestudent.submit();'."\n".
230: ' }'."\n".
231: '</script>'."\n";
232: $jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n".
233: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
234: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
235: '<input type="hidden" name="command" value="submission" />'."\n".
236: '<input type="hidden" name="student" value="" />'."\n".
237: '<input type="hidden" name="userdom" value="" />'."\n".
238: '</form>'."\n";
239: return $jscript;
240: }
1.39 ng 241:
1.44 ng 242: #------------------ End of general use routines --------------------
243: #-------------------------------------------------------------------
244:
245: #------------------------------------ Receipt Verification Routines
1.45 ng 246: #
1.44 ng 247: #--- Check whether a receipt number is valid.---
248: sub verifyreceipt {
249: my $request = shift;
250:
251: my $courseid = $ENV{'request.course.id'};
252: my $receipt = unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).'-'.
253: $ENV{'form.receipt'};
254: $receipt =~ s/[^\-\d]//g;
255: my $url = $ENV{'form.url'};
256: my $symb = $ENV{'form.symb'};
257: unless ($symb) {
258: $symb = &Apache::lonnet::symbread($url);
259: }
260:
1.45 ng 261: my $title.='<h3><font color="#339933">Verifying Submission Receipt '.
262: $receipt.'</h3></font>'."\n".
1.44 ng 263: '<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br><br>'."\n";
264:
265: my ($string,$contents,$matches) = ('','',0);
266: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0');
267:
268: foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
269: my ($uname,$udom)=split(/\:/);
270: if ($receipt eq
271: &Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb)) {
272: $contents.='<tr bgcolor="#ffffe6"><td> '."\n".
273: '<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom.
274: '\')"; TARGET=_self>'.$$fullname{$_}.'</a> </td>'."\n".
275: '<td> '.$uname.' </td>'.
276: '<td> '.$udom.' </td></tr>'."\n";
277:
278: $matches++;
279: }
280: }
281: if ($matches == 0) {
282: $string = $title.'No match found for the above receipt.';
283: } else {
1.45 ng 284: $string = &jscriptNform($url,$symb).$title.
1.44 ng 285: 'The above receipt matches the following student'.
286: ($matches <= 1 ? '.' : 's.')."\n".
287: '<table border="0"><tr><td bgcolor="#777777">'."\n".
288: '<table border="0"><tr bgcolor="#e6ffff">'."\n".
289: '<td><b> Fullname </b></td>'."\n".
290: '<td><b> Username </b></td>'."\n".
291: '<td><b> Domain </b></td></tr>'."\n".
292: $contents.
293: '</table></td></tr></table>'."\n";
294: }
295: return $string.&show_grading_menu_form ($symb,$url);
296: }
297:
298: #--- This is called by a number of programs.
299: #--- Called from the Grading Menu - View/Grade an individual student
300: #--- Also called directly when one clicks on the subm button
301: # on the problem page.
1.30 ng 302: sub listStudents {
1.41 ng 303: my ($request) = shift;
1.49 ! albertel 304:
! 305: my ($symb,$url) = &get_symb_and_url();
! 306: my $cdom = $ENV{"course.$ENV{'request.course.id'}.domain"};
! 307: my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"};
! 308: my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
! 309: my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};
! 310:
! 311: my $result;
! 312: my ($partlist,$handgrade) = &response_type($url);
! 313: for (sort keys(%$handgrade)) {
! 314: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
! 315: $ENV{'form.handgrade'} = 'yes' if ($handgrade eq 'yes');
! 316: $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
! 317: '<td><b>Type: </b>'.$responsetype.'</td>'.
! 318: '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
! 319: }
! 320: $result.='</table>';
! 321:
! 322: my $viewgrade;
! 323: if ($ENV{'form.handgrade'} eq 'yes') {
! 324: $viewgrade = 'View/Grade';
! 325: } else {
! 326: $viewgrade = 'View';
! 327: }
! 328:
! 329: $result='<h3><font color="#339933"> '.
! 330: $viewgrade.
! 331: ' Submissions for a Student or a Group of Students</font></h3>'.
! 332: '<table border="0"><tr><td colspan=3><font size=+1>'.
! 333: '<b>Resource: </b>'.$url.'</font></td></tr>'.$result;
! 334:
1.45 ng 335: $request->print(<<LISTJAVASCRIPT);
336: <script type="text/javascript" language="javascript">
337: function checkSelect(checkBox) {
338: var ctr=0;
1.46 ng 339: var sense="";
1.45 ng 340: if (checkBox.length > 1) {
341: for (var i=0; i<checkBox.length; i++) {
342: if (checkBox[i].checked) {
343: ctr++;
344: }
345: }
1.46 ng 346: sense = "a student or group of students";
1.45 ng 347: } else {
348: if (checkBox.checked) {
349: ctr = 1;
350: }
1.46 ng 351: sense = "the student";
1.45 ng 352: }
353: if (ctr == 0) {
1.49 ! albertel 354: alert("Please select "+sense+" before clicking on the $viewgrade button.");
1.45 ng 355: return false;
356: }
357: document.gradesub.submit();
358: }
359: </script>
360: LISTJAVASCRIPT
361:
1.41 ng 362: $request->print($result);
1.39 ng 363:
1.45 ng 364: my $checkhdgrade = $ENV{'form.handgrade'} eq 'yes' ? 'checked' : '';
365: my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
1.44 ng 366:
1.45 ng 367: my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n".
368: ' <b>View Problem: </b><input type="radio" name="vProb" value="no" checked> no '."\n".
369: '<input type="radio" name="vProb" value="yes"> yes <br />'."\n".
1.49 ! albertel 370: ' <b>Submissions: </b>'."\n";
! 371: if ($ENV{'form.handgrade'} eq 'yes') {
! 372: $gradeTable.='<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n";
! 373: }
! 374: $gradeTable.='<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last sub only'."\n".
1.45 ng 375: '<input type="radio" name="lastSub" value="last" /> last sub & parts info'."\n".
376: '<input type="radio" name="lastSub" value="all" /> all details'."\n".
377: '<input type="hidden" name="section" value="'.$getsec.'" />'."\n".
378: '<input type="hidden" name="submitonly" value="'.$submitonly.'" />'."\n".
379: '<input type="hidden" name="response" value="'.$ENV{'form.response'}.'" />'."\n".
380: '<input type="hidden" name="handgrade" value="'.$ENV{'form.handgrade'}.'" /><br />'."\n".
381: '<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" /><br />'."\n".
1.48 albertel 382: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
383: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
1.49 ! albertel 384: 'To '.lc($viewgrade).' a submission, click on the check box next to the student\'s name. Then '."\n".
! 385: 'click on the '.$viewgrade.' button. To view the submissions for a group of students, click'."\n".
1.45 ng 386: ' on the check boxes for the group of students.<br />'."\n".
387: '<input type="hidden" name="command" value="processGroup" />'."\n".
388: '<input type="button" '."\n".
389: 'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n".
1.49 ! albertel 390: 'value="'.$viewgrade.'" />'."\n";
1.45 ng 391:
1.41 ng 392: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');
393:
1.45 ng 394: $gradeTable.='<table border="0"><tr><td bgcolor="#777777">'.
1.41 ng 395: '<table border="0"><tr bgcolor="#e6ffff">'.
1.44 ng 396: '<td><b> Select </b></td><td><b> Fullname </b></td>'.
397: '<td><b> Username </b></td><td><b> Domain </b></td>';
1.41 ng 398: foreach (sort(@$partlist)) {
1.45 ng 399: $gradeTable.='<td><b> Part '.(split(/_/))[0].' Status </b></td>';
1.41 ng 400: }
1.45 ng 401: $gradeTable.='</tr>'."\n";
1.41 ng 402:
1.45 ng 403: my $ctr = 0;
1.44 ng 404: foreach my $student (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
1.41 ng 405: my ($uname,$udom) = split(/:/,$student);
1.48 albertel 406: my (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
1.41 ng 407: my $statusflg = '';
408: foreach (keys(%status)) {
409: $statusflg = 1 if ($status{$_} ne 'nothing');
1.43 ng 410: my ($foo,$partid,$foo1) = split(/\./,$_);
1.41 ng 411: if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
412: $statusflg = '';
1.45 ng 413: $gradeTable.='<input type="hidden" name="'.
414: $student.':submitted_by" value="'.
415: $status{'resource.'.$partid.'.submitted_by'}.'" />';
1.41 ng 416: }
417: }
418: next if ($statusflg eq '' && $submitonly eq 'yes');
1.34 ng 419:
1.45 ng 420: $ctr++;
1.41 ng 421: if ( $Apache::grades::viewgrades eq 'F' ) {
1.45 ng 422: $gradeTable.='<tr bgcolor="#ffffe6">'.
1.41 ng 423: '<td align="center"><input type=checkbox name="stuinfo" value="'.
424: $student.':'.$$fullname{$student}.'"></td>'."\n".
1.44 ng 425: '<td> '.$$fullname{$student}.' </td>'."\n".
1.41 ng 426: '<td> '.$uname.' </td>'."\n".
427: '<td align="middle"> '.$udom.' </td>'."\n";
428:
429: foreach (sort keys(%status)) {
430: next if (/^resource.*?submitted_by$/);
1.45 ng 431: $gradeTable.='<td align="middle"> '.$status{$_}.' </td>'."\n";
1.41 ng 432: }
1.45 ng 433: $gradeTable.='</tr>'."\n";
1.41 ng 434: }
435: }
1.45 ng 436: $gradeTable.='</table></td></tr></table>'.
437: '<input type="button" '.
438: 'onClick="javascript:checkSelect(this.form.stuinfo);" '.
1.49 ! albertel 439: 'value="'.$viewgrade.'" /><form />'."\n";
1.45 ng 440: if ($ctr == 0) {
441: $gradeTable='<br /> <font color="red">'.
442: 'No submission found for this resource.</font><br />';
1.48 albertel 443: $gradeTable.=&show_grading_menu_form($symb,$url);
1.46 ng 444: } elsif ($ctr == 1) {
445: $gradeTable =~ s/type=checkbox/type=checkbox checked/;
1.45 ng 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");
1.46 ng 555: alert("Please assign a score for "+name+", part "+partid+".");
1.45 ng 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=="") {
1.46 ng 597: alert("Please select a word or group of words from document and then click this link.");
1.44 ng 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.='<b>Fullname: </b>'.$ENV{'form.fullname'}.
933: '<font color="#999999"> Username: '.$uname.'</font>'.
1.45 ng 934: '<font color="#999999"> Domain: '.$udom.'</font><br />'."\n";
935: $result.='<input type="hidden" name="name'.$counter.
936: '" value="'.$ENV{'form.fullname'}.'" />'."\n";
1.41 ng 937:
1.44 ng 938: # If this is handgraded, then check for collaborators
1.45 ng 939: my @col_fullnames;
1.41 ng 940: if ($ENV{'form.handgrade'} eq 'yes') {
941: my @col_list;
942: ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0');
943: for (keys (%$handgrade)) {
1.44 ng 944: my $ncol = &Apache::lonnet::EXT('resource.'.$_.
945: '.maxcollaborators',$symb,$udom,$uname);
1.41 ng 946: if ($ncol > 0) {
947: s/\_/\./g;
948: if ($record{'resource.'.$_.'.collaborators'} ne '') {
1.44 ng 949: my (@collaborators) = split(/,?\s+/,
950: $record{'resource.'.$_.'.collaborators'});
1.41 ng 951: my (@badcollaborators);
952: if (scalar(@collaborators) != 0) {
1.44 ng 953: $result.='<b>Collaborators: </b>';
1.41 ng 954: foreach my $collaborator (@collaborators) {
955: $collaborator = $collaborator =~ /\@|:/ ?
956: (split(/@|:/,$collaborator))[0] : $collaborator;
957: next if ($collaborator eq $uname);
958: if (!grep /^$collaborator:/i,keys %$classlist) {
959: push @badcollaborators,$collaborator;
960: next;
961: }
962: push @col_list, $collaborator;
1.45 ng 963: my ($lastname,$givenn) = split(/,/,$$fullname{$collaborator.':'.$udom});
964: push @col_fullnames, $givenn.' '.$lastname;
1.44 ng 965: $result.=$$fullname{$collaborator.':'.$udom}.' ';
1.41 ng 966: }
1.44 ng 967: $result.='<br />'."\n";
968: $result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'.
969: 'This student has submitted '.
970: (scalar (@badcollaborators) > 1 ? '' : 'an').
1.41 ng 971: ' invalid collaborator'.(scalar (@badcollaborators) > 1 ? 's. ' : '. ').
1.44 ng 972: (join ', ',@badcollaborators).'</td></tr></table>'
1.41 ng 973: if (scalar(@badcollaborators) > 0);
974:
1.44 ng 975: $result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'.
1.41 ng 976: 'This student has submitted too many collaborators. Maximum is '.
1.44 ng 977: $ncol.'.</td></tr></table>' if (scalar(@collaborators) > $ncol);
1.41 ng 978: $result.='<input type="hidden" name="collaborator'.$counter.
979: '" value="'.(join ':',@col_list).'" />'."\n";
980: }
981: }
982: }
983: }
984: }
1.44 ng 985: $request->print($result."\n");
1.33 ng 986:
1.44 ng 987: # print student answer/submission
988: # Options are (1) Handgaded submission only
989: # (2) Last submission, includes submission that is not handgraded
990: # (for multi-response type part)
991: # (3) Last submission plus the parts info
992: # (4) The whole record for this student
1.41 ng 993: if ($ENV{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) {
994: if ($ENV{'form.'.$uname.':'.$udom.':submitted_by'}) {
1.44 ng 995: my $submitby=''.
1.41 ng 996: '<b>Collaborative submission by: </b>'.
1.44 ng 997: '<a href="javascript:viewSubmitter(\''.
998: $ENV{'form.'.$uname.':'.$udom.':submitted_by'}.
1.41 ng 999: '\')"; TARGET=_self>'.
1000: $$fullname{$ENV{'form.'.$uname.':'.$udom.':submitted_by'}}.'</a>';
1001: $request->print($submitby);
1002: } else {
1.44 ng 1003: my ($string,$timestamp)=
1.46 ng 1004: &get_last_submission (%record);
1.44 ng 1005: my $lastsubonly.=''.
1006: ($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '.
1007: $$timestamp).'';
1.41 ng 1008: if ($$timestamp eq '') {
1.45 ng 1009: $lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0].'</td></tr>'."\n";
1.41 ng 1010: } else {
1011: for my $part (sort keys(%$handgrade)) {
1012: foreach (@$string) {
1013: my ($partid,$respid) = /^resource\.(\d+)\.(\d+)\.submission/;
1014: if ($part eq ($partid.'_'.$respid)) {
1015: my ($ressub,$subval) = split(/:/,$_,2);
1.44 ng 1016: $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
1017: $partid.'</b> <font color="#999999">( ID '.$respid.
1018: ' )</font> <b>Answer: </b>'.
1.45 ng 1019: &keywords_highlight($subval).'</td></tr>'."\n"
1.41 ng 1020: if ($ENV{'form.lastSub'} eq 'lastonly' ||
1.44 ng 1021: ($ENV{'form.lastSub'} eq 'hdgrade' &&
1022: $$handgrade{$part} =~ /:yes$/));
1.41 ng 1023: }
1024: }
1025: }
1026: }
1.45 ng 1027: $lastsubonly.='</td></tr>'."\n";
1.41 ng 1028: $request->print($lastsubonly);
1029: }
1030: } else {
1031: $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
1.44 ng 1032: $ENV{'request.course.id'},
1033: $last,'.submission',
1034: 'Apache::grades::keywords_highlight'));
1.41 ng 1035: }
1036:
1.44 ng 1037: # return if view submission with no grading option
1.41 ng 1038: if ($ENV{'form.showgrading'} eq '') {
1.45 ng 1039: $request->print('</td></tr></table></td></tr></table></form>'."\n");
1.41 ng 1040: return;
1041: }
1.33 ng 1042:
1.44 ng 1043: # Grading options
1.41 ng 1044: $result='<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n".
1045: '<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".
1.45 ng 1046: '<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'
1047: .$udom.'" />'."\n";
1048: my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
1049: my $msgfor = $givenn.' '.$lastname;
1050: if (scalar(@col_fullnames) > 0) {
1051: my $lastone = pop @col_fullnames;
1052: $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
1053: }
1054: $result.='<tr><td bgcolor="#ffffff">'."\n".
1055: ' <a href="javascript:msgCenter(document.SCORE,'.$counter.
1056: ',\''.$msgfor.'\')"; TARGET=_self>'.
1057: 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a>'.
1.44 ng 1058: '<br /> (Message will be sent when you click on Save & Next below.)'."\n"
1059: if ($ENV{'form.handgrade'} eq 'yes');
1.41 ng 1060: $request->print($result);
1061:
1062: my %seen = ();
1063: my @partlist;
1064: for (sort keys(%$handgrade)) {
1065: my ($partid,$respid) = split(/_/);
1066: next if ($seen{$partid} > 0);
1067: $seen{$partid}++;
1068: next if ($$handgrade{$_} =~ /:no$/);
1069: push @partlist,$partid;
1070: my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
1.44 ng 1071: my $wgtmsg = ($wgt > 0 ? '(problem weight)' :
1072: '<font color="red">problem weight assigned by computer</font>');
1.41 ng 1073: $wgt = ($wgt > 0 ? $wgt : '1');
1074: my $score = ($record{'resource.'.$partid.'.awarded'} eq '' ?
1075: '' : $record{'resource.'.$partid.'.awarded'}*$wgt);
1076: $result='<input type="hidden" name="WGT'.$counter.'_'.$partid.'" value="'.$wgt.'" />';
1.44 ng 1077: $result.='<table border="0"><tr><td><b>Part </b>'.$partid.' <b>Points: </b></td><td>';
1.41 ng 1078:
1079: my $ctr = 0;
1080: $result.='<table border="0"><tr>'; # display radio buttons in a nice table 10 across
1081: while ($ctr<=$wgt) {
1082: $result.= '<td><input type="radio" name="RADVAL'.$counter.'_'.$partid.'" '.
1.43 ng 1083: 'onclick="javascript:writeBox(this.form.GD_BOX'.$counter.'_'.$partid.
1084: ',this.form.GD_SEL'.$counter.'_'.$partid.','.$ctr.
1.41 ng 1085: ',this.form.stores'.$counter.'_'.$partid.')" '.
1086: ($score eq $ctr ? 'checked':'').' /> '.$ctr."</td>\n";
1087: $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : '');
1088: $ctr++;
1089: }
1090: $result.='</tr></table>';
1.39 ng 1091:
1.41 ng 1092: $result.='</td><td> <b>or</b> </td>';
1.43 ng 1093: $result.='<td><input type="text" name="GD_BOX'.$counter.'_'.$partid.'"'.
1.41 ng 1094: ($score ne ''? ' value = "'.$score.'"':'').' size="4" '.
1095: 'onChange="javascript:updateRadio(this.form.RADVAL'.$counter.'_'.$partid.
1.43 ng 1096: ',this.form.GD_BOX'.$counter.'_'.$partid.
1097: ',this.form.GD_SEL'.$counter.'_'.$partid.
1.44 ng 1098: ',this.form.stores'.$counter.'_'.$partid.
1099: ','.$wgt.')" /></td>'."\n";
1.41 ng 1100: $result.='<td>/'.$wgt.' '.$wgtmsg.' </td><td>';
1101:
1.43 ng 1102: $result.='<select name="GD_SEL'.$counter.'_'.$partid.'" '.
1.41 ng 1103: 'onChange="javascript:clearRadBox(this.form.RADVAL'.$counter.'_'.$partid.
1.43 ng 1104: ',this.form.GD_BOX'.$counter.'_'.$partid.
1105: ',this.form.GD_SEL'.$counter.'_'.$partid.
1.41 ng 1106: ',this.form.stores'.$counter.'_'.$partid.')" />'."\n".
1107: '<option selected="on"> </option>'.
1108: '<option>excused</option></select>'."  \n";
1109: $result.='<input type="hidden" name="stores'.$counter.'_'.$partid.'" value="0" />';
1.45 ng 1110: $result.='</td></tr></table>'."\n";
1.41 ng 1111: $request->print($result);
1112: }
1.45 ng 1113: $result='<input type="hidden" name="partlist'.$counter.
1114: '" value="'.(join ":",@partlist).'" />'."\n";
1115: my $ctr = 0;
1116: while ($ctr < scalar(@partlist)) {
1117: $result.='<input type="hidden" name="partid'.$counter.'_'.$ctr.'" value="'.
1118: $partlist[$ctr].'" />'."\n";
1119: $ctr++;
1120: }
1121: $request->print($result.'</td></tr></table></td></tr></table>'."\n");
1.41 ng 1122:
1123: # print end of form
1124: if ($counter == $total) {
1.45 ng 1125: my $endform='<table border="0"><tr><td>'.
1126: '<input type="hidden" name="gradeOpt" value="" />'."\n";
1127: if ($ENV{'form.handgrade'} eq 'yes') {
1128: $endform.='<input type="button" value="Save & Next" '.
1129: 'onClick="javascript:checksubmit(\'Save & Next\','.
1130: $total.','.scalar(@partlist).');" TARGET=_self> '."\n";
1131: my $ntstu ='<select name="NTSTU">'.
1132: '<option>1</option><option>2</option>'.
1133: '<option>3</option><option>5</option>'.
1134: '<option>7</option><option>10</option></select>'."\n";
1135: my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');
1136: $ntstu =~ s/<option>$nsel</<option selected="on">$nsel</;
1137: $endform.=$ntstu.'student(s) ';
1138: } else {
1139: $endform.='<input type="hidden" name="NTSTU" value="1" />'."\n";
1140: }
1141: $endform.='<input type="button" value="Next" '.
1142: 'onClick="javascript:checksubmit(\'Next\');" TARGET=_self> '."\n".
1143: '<input type="button" value="Previous" '.
1144: 'onClick="javascript:checksubmit(\'Previous\');" TARGET=_self> ';
1145: $endform.='(Next and Previous do not save the scores.)'."\n"
1146: if ($ENV{'form.handgrade'} eq 'yes');
1147: $endform.='</td><tr></table></form>';
1.41 ng 1148: $request->print($endform);
1149: }
1150: return '';
1.38 ng 1151: }
1152:
1.44 ng 1153: #--- Retrieve the last submission for all the parts
1.38 ng 1154: sub get_last_submission {
1.46 ng 1155: my (%returnhash)=@_;
1156: my (@string,$timestamp);
1157: if ($returnhash{'version'}) {
1158: my %lasthash=();
1159: my ($version);
1160: for ($version=1;$version<=$returnhash{'version'};$version++) {
1161: foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
1162: $lasthash{$_}=$returnhash{$version.':'.$_};
1163: if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {
1164: $timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
1165: }
1166: }
1167: }
1168: foreach ((keys %lasthash)) {
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{$_}));
1.41 ng 1174: }
1175: }
1176: }
1.46 ng 1177: @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
1178: return \@string,\$timestamp;
1.38 ng 1179: }
1.35 ng 1180:
1.44 ng 1181: #--- High light keywords, with style choosen by user.
1.38 ng 1182: sub keywords_highlight {
1.44 ng 1183: my $string = shift;
1184: my $size = $ENV{'form.kwsize'} eq '0' ? '' : 'size='.$ENV{'form.kwsize'};
1185: my $styleon = $ENV{'form.kwstyle'} eq '' ? '' : $ENV{'form.kwstyle'};
1.41 ng 1186: (my $styleoff = $styleon) =~ s/\</\<\//;
1.44 ng 1187: my @keylist = split(/[,\s+]/,$ENV{'form.keywords'});
1.41 ng 1188: foreach (@keylist) {
1189: $string =~ s/\b$_(\b|\.)/\<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff\<\/font\>/gi;
1190: }
1191: return $string;
1.38 ng 1192: }
1.36 ng 1193:
1.44 ng 1194: #--- Called from submission routine
1.38 ng 1195: sub processHandGrade {
1.41 ng 1196: my ($request) = shift;
1197: my $url = $ENV{'form.url'};
1198: my $symb = $ENV{'form.symb'};
1199: my $button = $ENV{'form.gradeOpt'};
1200: my $ngrade = $ENV{'form.NCT'};
1201: my $ntstu = $ENV{'form.NTSTU'};
1202:
1.44 ng 1203: if ($button eq 'Save & Next') {
1204: my $ctr = 0;
1205: while ($ctr < $ngrade) {
1206: my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
1.45 ng 1207: my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
1.44 ng 1208:
1209: my $includemsg = $ENV{'form.includemsg'.$ctr};
1210: my ($subject,$message,$msgstatus) = ('','','');
1211: if ($includemsg =~ /savemsg|new$ctr/) {
1212: $subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/);
1213: my (@msgnum) = split(/,/,$includemsg);
1214: foreach (@msgnum) {
1215: $message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
1216: }
1217: $message =~ s/\s+/ /g;
1218: $msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom,
1219: $ENV{'form.msgsub'},$message);
1220: }
1221: if ($ENV{'form.collaborator'.$ctr}) {
1222: my (@collaborators) = split(/:/,$ENV{'form.collaborator'.$ctr});
1223: foreach (@collaborators) {
1224: &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,
1225: $ENV{'form.unamedom'.$ctr});
1226: if ($message ne '') {
1227: $msgstatus = &Apache::lonmsg::user_normal_msg ($_,$udom,
1228: $ENV{'form.msgsub'},
1229: $message);
1230: }
1231: }
1232: }
1233: $ctr++;
1234: }
1235: }
1236:
1237: # Keywords sorted in alphabatical order
1.41 ng 1238: my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
1239: my %keyhash = ();
1240: $ENV{'form.keywords'} =~ s/,\s{0,}|\s+/ /g;
1241: $ENV{'form.keywords'} =~ s/^\s+|\s+$//;
1.44 ng 1242: my (@keywords) = sort(split(/\s+/,$ENV{'form.keywords'}));
1243: $ENV{'form.keywords'} = join(' ',@keywords);
1.41 ng 1244: $keyhash{$symb.'_keywords'} = $ENV{'form.keywords'};
1245: $keyhash{$symb.'_subject'} = $ENV{'form.msgsub'};
1246: $keyhash{$loginuser.'_kwclr'} = $ENV{'form.kwclr'};
1247: $keyhash{$loginuser.'_kwsize'} = $ENV{'form.kwsize'};
1248: $keyhash{$loginuser.'_kwstyle'} = $ENV{'form.kwstyle'};
1249:
1.44 ng 1250: # message center - Order of message gets changed. Blank line is eliminated.
1251: # New messages are saved in ENV for the next student.
1252: # All messages are saved in nohist_handgrade.db
1.41 ng 1253: my ($ctr,$idx) = (1,1);
1254: while ($ctr <= $ENV{'form.savemsgN'}) {
1255: if ($ENV{'form.savemsg'.$ctr} ne '') {
1256: $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.savemsg'.$ctr};
1257: $idx++;
1258: }
1259: $ctr++;
1260: }
1261: $ctr = 0;
1262: while ($ctr < $ngrade) {
1263: if ($ENV{'form.newmsg'.$ctr} ne '') {
1264: $keyhash{$symb.'_savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
1265: $ENV{'form.savemsg'.$idx} = $ENV{'form.newmsg'.$ctr};
1266: $idx++;
1267: }
1268: $ctr++;
1269: }
1270: $ENV{'form.savemsgN'} = --$idx;
1271: $keyhash{$symb.'_savemsgN'} = $ENV{'form.savemsgN'};
1272: my $putresult = &Apache::lonnet::put
1273: ('nohist_handgrade',\%keyhash,
1274: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1275: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1276:
1.44 ng 1277: # Called by Save & Refresh from Highlight Attribute Window
1.41 ng 1278: if ($ENV{'form.refresh'} eq 'on') {
1279: my $ctr = 0;
1280: $ENV{'form.NTSTU'}=$ngrade;
1281: while ($ctr < $ngrade) {
1.44 ng 1282: ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$ENV{'form.unamedom'.$ctr});
1.41 ng 1283: &submission($request,$ctr,$ngrade-1);
1284: $ctr++;
1285: }
1286: return '';
1287: }
1.36 ng 1288:
1.44 ng 1289: # Get the next/previous one or group of students
1.41 ng 1290: my $firststu = $ENV{'form.unamedom0'};
1291: my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
1292: $ctr = 2;
1293: while ($laststu eq '') {
1294: $laststu = $ENV{'form.unamedom'.($ngrade-$ctr)};
1295: $ctr++;
1296: $laststu = $firststu if ($ctr > $ngrade);
1297: }
1.44 ng 1298:
1.41 ng 1299: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
1300: my (@parsedlist,@nextlist);
1301: my ($nextflg) = 0;
1.44 ng 1302: foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
1.41 ng 1303: if ($nextflg == 1 && $button =~ /Next$/) {
1304: push @parsedlist,$_;
1305: }
1306: $nextflg = 1 if ($_ eq $laststu);
1307: if ($button eq 'Previous') {
1308: last if ($_ eq $firststu);
1309: push @parsedlist,$_;
1310: }
1311: }
1312: $ctr = 0;
1313: my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
1314: @parsedlist = reverse @parsedlist if ($button eq 'Previous');
1315: foreach my $student (@parsedlist) {
1316: my ($uname,$udom) = split(/:/,$student);
1317: if ($ENV{'form.submitonly'} eq 'yes') {
1.44 ng 1318: my (%status) = &student_gradeStatus($ENV{'form.url'},$symb,$udom,$uname,$partlist) ;
1.41 ng 1319: my $statusflg = '';
1320: foreach (keys(%status)) {
1321: $statusflg = 1 if ($status{$_} ne 'nothing');
1.44 ng 1322: my ($foo,$partid,$foo1) = split(/\./);
1.41 ng 1323: $statusflg = '' if ($status{'resource.'.$partid.'.submitted_by'} ne '');
1324: }
1325: next if ($statusflg eq '');
1326: }
1327: push @nextlist,$student if ($ctr < $ntstu);
1328: $ctr++;
1329: }
1.36 ng 1330:
1.41 ng 1331: $ctr = 0;
1332: my $total = scalar(@nextlist)-1;
1.39 ng 1333:
1.41 ng 1334: foreach (sort @nextlist) {
1335: my ($uname,$udom,$submitter) = split(/:/);
1.44 ng 1336: $ENV{'form.student'} = $uname;
1337: $ENV{'form.userdom'} = $udom;
1.41 ng 1338: $ENV{'form.fullname'} = $$fullname{$_};
1339: # $ENV{'form.'.$_.':submitted_by'} = $submitter;
1340: # print "submitter=$ENV{'form.'.$_.':submitted_by'}= $submitter:<br>";
1341: &submission($request,$ctr,$total);
1342: $ctr++;
1343: }
1344: if ($total < 0) {
1345: my $the_end = '<h3><font color="red">LON-CAPA User Message</font></h3><br />'."\n";
1346: $the_end.='<b>Message: </b> No more students for this section or class.<br /><br />'."\n";
1347: $the_end.='Click on the button below to return to the grading menu.<br /><br />'."\n";
1348: $the_end.=&show_grading_menu_form ($symb,$url);
1349: $request->print($the_end);
1350: }
1351: return '';
1.38 ng 1352: }
1.36 ng 1353:
1.44 ng 1354: #---- Save the score and award for each student, if changed
1.38 ng 1355: sub saveHandGrade {
1.41 ng 1356: my ($request,$url,$symb,$stuname,$domain,$newflg,$submitter) = @_;
1.44 ng 1357: my %record=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname);
1.41 ng 1358: my %newrecord;
1359: foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
1.43 ng 1360: if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {
1.44 ng 1361: $newrecord{'resource.'.$_.'.solved'} = 'excused'
1362: if ($record{'resource.'.$_.'.solved'} ne 'excused');
1.41 ng 1363: } else {
1.44 ng 1364: my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?
1365: $ENV{'form.GD_BOX'.$newflg.'_'.$_} :
1366: $ENV{'form.RADVAL'.$newflg.'_'.$_});
1367: my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :
1368: $ENV{'form.WGT'.$newflg.'_'.$_};
1.41 ng 1369: my $partial= $pts/$wgt;
1.44 ng 1370: $newrecord{'resource.'.$_.'.awarded'} = $partial
1371: if ($record{'resource.'.$_.'.awarded'} ne $partial);
1372: my $reckey = 'resource.'.$_.'.solved';
1.41 ng 1373: if ($partial == 0) {
1.44 ng 1374: $newrecord{$reckey} = 'incorrect_by_override'
1375: if ($record{$reckey} ne 'incorrect_by_override');
1.41 ng 1376: } else {
1.44 ng 1377: $newrecord{$reckey} = 'correct_by_override'
1378: if ($record{$reckey} ne 'correct_by_override');
1.41 ng 1379: }
1.44 ng 1380: $newrecord{'resource.'.$_.'.submitted_by'} = $submitter
1381: if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));
1.41 ng 1382: }
1383: }
1.44 ng 1384:
1385: if (scalar(keys(%newrecord)) > 0) {
1.41 ng 1386: $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
1.44 ng 1387: &Apache::lonnet::cstore(\%newrecord,$symb,
1388: $ENV{'request.course.id'},$domain,$stuname);
1.41 ng 1389: }
1390: return '';
1.36 ng 1391: }
1.38 ng 1392:
1.44 ng 1393: #--------------------------------------------------------------------------------------
1394: #
1395: #-------------------------- Next few routines handles grading by section or whole class
1396: #
1397: #--- Javascript to handle grading by section or whole class
1.42 ng 1398: sub viewgrades_js {
1399: my ($request) = shift;
1400:
1.41 ng 1401: $request->print(<<VIEWJAVASCRIPT);
1402: <script type="text/javascript" language="javascript">
1.45 ng 1403: function writePoint(partid,weight,point) {
1.42 ng 1404: var radioButton = eval("document.classgrade.RADVAL_"+partid);
1405: var textbox = eval("document.classgrade.TEXTVAL_"+partid);
1406: if (point == "textval") {
1407: var point = eval("document.classgrade.TEXTVAL_"+partid+".value");
1408: if (isNaN(point) || point < 0) {
1409: alert("A number equal or greater than 0 is expected. Entered value = "+point);
1410: var resetbox = false;
1411: for (var i=0; i<radioButton.length; i++) {
1412: if (radioButton[i].checked) {
1413: textbox.value = i;
1414: resetbox = true;
1415: }
1416: }
1417: if (!resetbox) {
1418: textbox.value = "";
1419: }
1420: return;
1421: }
1.44 ng 1422: if (point > weight) {
1423: var resp = confirm("You entered a value ("+point+
1424: ") greater than the weight for the part. Accept?");
1425: if (resp == false) {
1426: textbox.value = "";
1427: return;
1428: }
1429: }
1.42 ng 1430: for (var i=0; i<radioButton.length; i++) {
1431: radioButton[i].checked=false;
1432: if (point == i) {
1433: radioButton[i].checked=true;
1434: }
1435: }
1.41 ng 1436:
1.42 ng 1437: } else {
1438: textbox.value = point;
1439: }
1.41 ng 1440: for (i=0;i<document.classgrade.total.value;i++) {
1.43 ng 1441: var user = eval("document.classgrade.ctr"+i+".value");
1442: var scorename = eval("document.classgrade.GD_"+user+
1443: "_"+partid+"_aw");
1444: var saveval = eval("document.classgrade.GD_"+user+
1445: "_"+partid+"_sv_s.value");
1446: var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_sv");
1.42 ng 1447: if (saveval != "correct") {
1448: scorename.value = point;
1.43 ng 1449: if (selname[0].selected != true) {
1450: selname[0].selected = true;
1451: }
1.42 ng 1452: }
1453: }
1454: var selval = eval("document.classgrade.SELVAL_"+partid);
1455: selval[0].selected = true;
1456: }
1457:
1458: function writeRadText(partid,weight) {
1459: var selval = eval("document.classgrade.SELVAL_"+partid);
1.43 ng 1460: var radioButton = eval("document.classgrade.RADVAL_"+partid);
1461: var textbox = eval("document.classgrade.TEXTVAL_"+partid);
1.42 ng 1462: if (selval[1].selected) {
1463: for (var i=0; i<radioButton.length; i++) {
1464: radioButton[i].checked=false;
1465:
1466: }
1467: textbox.value = "";
1468:
1469: for (i=0;i<document.classgrade.total.value;i++) {
1.43 ng 1470: var user = eval("document.classgrade.ctr"+i+".value");
1471: var scorename = eval("document.classgrade.GD_"+user+
1472: "_"+partid+"_aw");
1473: var saveval = eval("document.classgrade.GD_"+user+
1474: "_"+partid+"_sv_s.value");
1475: var selname = eval("document.classgrade.GD_"+user+
1476: "_"+partid+"_sv");
1.42 ng 1477: if (saveval != "correct") {
1478: scorename.value = "";
1479: selname[1].selected = true;
1480: }
1481: }
1.43 ng 1482: } else {
1483: for (i=0;i<document.classgrade.total.value;i++) {
1484: var user = eval("document.classgrade.ctr"+i+".value");
1485: var scorename = eval("document.classgrade.GD_"+user+
1486: "_"+partid+"_aw");
1487: var saveval = eval("document.classgrade.GD_"+user+
1488: "_"+partid+"_sv_s.value");
1489: var selname = eval("document.classgrade.GD_"+user+
1490: "_"+partid+"_sv");
1491: if (saveval != "correct") {
1492: scorename.value = eval("document.classgrade.GD_"+user+
1493: "_"+partid+"_aw_s.value");;
1494: selname[0].selected = true;
1495: }
1496: }
1497: }
1.42 ng 1498: }
1499:
1500: function changeSelect(partid,user) {
1.43 ng 1501: var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_sv");
1.44 ng 1502: var textbox = eval("document.classgrade.GD_"+user+'_'+partid+"_aw");
1503: var point = textbox.value;
1504: var weight = eval("document.classgrade.weight_"+partid+".value");
1505:
1506: if (isNaN(point) || point < 0) {
1507: alert("A number equal or greater than 0 is expected. Entered value = "+point);
1508: textbox.value = "";
1509: return;
1510: }
1511: if (point > weight) {
1512: var resp = confirm("You entered a value ("+point+
1513: ") greater than the weight of the part. Accept?");
1514: if (resp == false) {
1515: textbox.value = "";
1516: return;
1517: }
1518: }
1.42 ng 1519: selval[0].selected = true;
1520: }
1521:
1522: function changeOneScore(partid,user) {
1.43 ng 1523: var selval = eval("document.classgrade.GD_"+user+'_'+partid+"_sv");
1.42 ng 1524: if (selval[1].selected) {
1.43 ng 1525: var boxval = eval("document.classgrade.GD_"+user+'_'+partid+"_aw");
1.42 ng 1526: boxval.value = "";
1527: }
1528: }
1529:
1530: function resetEntry(numpart) {
1531: for (ctpart=0;ctpart<numpart;ctpart++) {
1532: var partid = eval("document.classgrade.partid_"+ctpart+".value");
1533: var radioButton = eval("document.classgrade.RADVAL_"+partid);
1534: var textbox = eval("document.classgrade.TEXTVAL_"+partid);
1535: var selval = eval("document.classgrade.SELVAL_"+partid);
1536: for (var i=0; i<radioButton.length; i++) {
1537: radioButton[i].checked=false;
1538:
1539: }
1540: textbox.value = "";
1541: selval[0].selected = true;
1542:
1543: for (i=0;i<document.classgrade.total.value;i++) {
1.43 ng 1544: var user = eval("document.classgrade.ctr"+i+".value");
1545: var resetscore = eval("document.classgrade.GD_"+user+
1546: "_"+partid+"_aw");
1547: resetscore.value = eval("document.classgrade.GD_"+user+
1548: "_"+partid+"_aw_s.value");
1.42 ng 1549:
1.43 ng 1550: var saveselval = eval("document.classgrade.GD_"+user+
1551: "_"+partid+"_sv_s.value");
1.42 ng 1552:
1.43 ng 1553: var selname = eval("document.classgrade.GD_"+user+"_"+partid+"_sv");
1.42 ng 1554: if (saveselval == "excused") {
1.43 ng 1555: if (selname[1].selected == false) { selname[1].selected = true;}
1.42 ng 1556: } else {
1.43 ng 1557: if (selname[0].selected == false) {selname[0].selected = true};
1.42 ng 1558: }
1559: }
1.41 ng 1560: }
1.42 ng 1561: }
1562:
1.41 ng 1563: </script>
1564: VIEWJAVASCRIPT
1.42 ng 1565: }
1566:
1.44 ng 1567: #--- show scores for a section or whole class w/ option to change/update a score
1.42 ng 1568: sub viewgrades {
1569: my ($request) = shift;
1570: &viewgrades_js($request);
1.41 ng 1571:
1572: my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'});
1.45 ng 1573: my $result='<h3><font color="#339933">Manual Grading</font></h3>';
1.38 ng 1574:
1.43 ng 1575: $result.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font>'."\n";
1.41 ng 1576:
1577: #view individual student submission form - called using Javascript viewOneStudent
1.45 ng 1578: $result.=&jscriptNform($url,$symb);
1.41 ng 1579:
1.44 ng 1580: #beginning of class grading form
1.41 ng 1581: $result.= '<form action="/adm/grades" method="post" name="classgrade">'."\n".
1582: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
1583: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
1.38 ng 1584: '<input type="hidden" name="command" value="editgrades" />'."\n".
1.41 ng 1585: '<input type="hidden" name="section" value="'.$ENV{'form.section'}.'" />'."\n";
1.42 ng 1586: $result.='To assign the same score for all the students use the radio buttons or '.
1587: 'text box below. To assign scores individually fill in the score boxes for '.
1.44 ng 1588: 'each student in the table below. <font color="red">A part that has already '.
1.42 ng 1589: 'been graded does not get changed using the radio buttons or text box. '.
1590: 'If needed, it has to be changed individually.</font>';
1591:
1.44 ng 1592: #radio buttons/text box for assigning points for a section or class.
1593: #handles different parts of a problem
1.42 ng 1594: my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
1595: my %weight = ();
1596: my $ctsparts = 0;
1.41 ng 1597: $result.='<table border="0">';
1.45 ng 1598: my %seen = ();
1.42 ng 1599: for (sort keys(%$handgrade)) {
1.45 ng 1600: my ($partid,$respid) = split (/_/);
1601: next if $seen{$partid};
1602: $seen{$partid}++;
1.42 ng 1603: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
1604: my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb);
1605: $weight{$partid} = $wgt eq '' ? '1' : $wgt;
1606:
1.44 ng 1607: $result.='<input type="hidden" name="partid_'.
1608: $ctsparts.'" value="'.$partid.'" />'."\n";
1609: $result.='<input type="hidden" name="weight_'.
1610: $partid.'" value="'.$weight{$partid}.'" />'."\n";
1611: $result.='<tr><td><b>Part '.$partid.' Point:</b> </td><td>';
1.42 ng 1612: $result.='<table border="0"><tr>';
1.41 ng 1613: my $ctr = 0;
1.42 ng 1614: while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across
1615: $result.= '<td><input type="radio" name="RADVAL_'.$partid.'" '.
1616: 'onclick="javascript:writePoint('.$partid.','.$weight{$partid}.
1.41 ng 1617: ','.$ctr.')" />'.$ctr."</td>\n";
1618: $result.=(($ctr+1)%10 == 0 ? '</tr><tr>' : '');
1619: $ctr++;
1620: }
1621: $result.='</tr></table>';
1.44 ng 1622: $result.= '</td><td><b> or </b><input type="text" name="TEXTVAL_'.
1623: $partid.'" size="4" '.
1624: 'onChange="javascript:writePoint('.$partid.','.$weight{$partid}.
1625: ',\'textval\')" /> /'.
1.42 ng 1626: $weight{$partid}.' (problem weight)</td>'."\n";
1627: $result.= '</td><td><select name="SELVAL_'.$partid.'"'.
1628: 'onChange="javascript:writeRadText('.$partid.','.$weight{$partid}.')" /> '.
1629: '<option selected="on"> </option>'.
1630: '<option>excused</option></select></td></tr>'."\n";
1631: $ctsparts++;
1.41 ng 1632: }
1.42 ng 1633: $result.='</table><input type="hidden" name="totalparts" value="'.$ctsparts.'" />';
1634: $result.='<input type="button" value="Reset" '.
1.43 ng 1635: 'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self> ';
1.45 ng 1636: $result.='<input type="button" value="Submit Changes" '.
1637: 'onClick="javascript:submit();" TARGET=_self />'."\n";
1.41 ng 1638:
1.44 ng 1639: #table listing all the students in a section/class
1640: #header of table
1.42 ng 1641: $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".
1.41 ng 1642: '<table border=0><tr bgcolor="#deffff">'.
1.44 ng 1643: '<td><b>Fullname</b></td><td><b>Username</b></td><td><b>Domain</b></td>'."\n";
1.41 ng 1644: my (@parts) = sort(&getpartlist($url));
1645: foreach my $part (@parts) {
1646: my $display=&Apache::lonnet::metadata($url,$part.'.display');
1647: next if ($display =~ /^Number of Attempts/);
1648: if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
1649: if ($display =~ /^Partial Credit Factor/) {
1650: $_ = $display;
1651: my ($partid) = /.*?(\d+).*/;
1.42 ng 1652: $result.='<td><b>Score Part '.$partid.'<br>(weight = '.
1653: $weight{$partid}.')</b></td>'."\n";
1.41 ng 1654: next;
1655: }
1.42 ng 1656: $display =~ s/Problem Status/Grade Status<br>/;
1.41 ng 1657: $result.='<td><b>'.$display.'</b></td>'."\n";
1658: }
1659: $result.='</tr>';
1.44 ng 1660:
1.41 ng 1661: #get info for each student
1.44 ng 1662: #list all the students - with points and grade status
1.41 ng 1663: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
1664: my $ctr = 0;
1.44 ng 1665: foreach (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
1666: my ($uname,$udom) = split(/:/);
1667: $result.='<input type="hidden" name="ctr'.$ctr.'" value="'.$uname.'" />'."\n";
1.41 ng 1668: $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
1669: $_,$$fullname{$_},\@parts,\%weight);
1670: $ctr++;
1671: }
1672: $result.='</table></td></tr></table>';
1673: $result.='<input type="hidden" name="total" value="'.$ctr.'" />'."\n";
1.45 ng 1674: $result.='<input type="button" value="Submit Changes" '.
1675: 'onClick="javascript:submit();" TARGET=_self /></form>'."\n";
1.41 ng 1676: $result.=&show_grading_menu_form($symb,$url);
1677: return $result;
1678: }
1679:
1.44 ng 1680: #--- call by previous routine to display each student
1.41 ng 1681: sub viewstudentgrade {
1682: my ($url,$symb,$courseid,$student,$fullname,$parts,$weight) = @_;
1.44 ng 1683: my ($uname,$udom) = split(/:/,$student);
1684: my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
1.41 ng 1685: my $result='<tr bgcolor="#ffffdd"><td>'.
1.44 ng 1686: '<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom.
1687: '\')"; TARGET=_self>'.$fullname.'</a>'.
1688: '</td><td>'.$uname.'</td><td align="middle">'.$udom.'</td>'."\n";
1.41 ng 1689: foreach my $part (@$parts) {
1690: my ($temp,$part,$type)=split(/_/,$part);
1691: my $score=$record{"resource.$part.$type"};
1692: next if $type eq 'tries';
1693: if ($type eq 'awarded') {
1.42 ng 1694: my $pts = $score eq '' ? '' : $score*$$weight{$part};
1695: $result.='<input type="hidden" name="'.
1.44 ng 1696: 'GD_'.$uname.'_'.$part.'_aw_s" value="'.$pts.'" />'."\n";
1.42 ng 1697: $result.='<td align="middle"><input type="text" name="'.
1.44 ng 1698: 'GD_'.$uname.'_'.$part.'_aw" '.
1699: 'onChange="javascript:changeSelect('.$part.',\''.$uname.
1700: '\')" value="'.$pts.'" size="4" /></td>'."\n";
1.41 ng 1701: } elsif ($type eq 'solved') {
1702: my ($status,$foo)=split(/_/,$score,2);
1703: $status = 'nothing' if ($status eq '');
1.42 ng 1704: $result.='<input type="hidden" name="'.
1.44 ng 1705: 'GD_'.$uname.'_'.$part.'_sv_s" value="'.$status.'" />'."\n";
1.42 ng 1706: $result.='<td align="middle"><select name="'.
1.44 ng 1707: 'GD_'.$uname.'_'.$part.'_sv" '.
1708: 'onChange="javascript:changeOneScore('.$part.',\''.$uname.'\')" >'."\n";
1.42 ng 1709: my $optsel = '<option selected="on"> </option><option>excused</option>'."\n";
1710: $optsel = '<option> </option><option selected="on">excused</option>'."\n"
1711: if ($status eq 'excused');
1.41 ng 1712: $result.=$optsel;
1713: $result.="</select></td>\n";
1714: }
1715: }
1716: $result.='</tr>';
1717: return $result;
1.38 ng 1718: }
1719:
1.44 ng 1720: #--- change scores for all the students in a section/class
1721: # record does not get update if unchanged
1.38 ng 1722: sub editgrades {
1.41 ng 1723: my ($request) = @_;
1724:
1725: my $symb=$ENV{'form.symb'};
1.43 ng 1726: my $url =$ENV{'form.url'};
1.45 ng 1727: my $title='<h3><font color="#339933">Current Grade Status</font></h3>';
1.44 ng 1728: $title.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br />'."\n";
1729: $title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n";
1730: $title.= &show_grading_menu_form ($symb,$url);
1731: my $result= '<table border="0"><tr><td bgcolor="#777777">'."\n";
1.43 ng 1732: $result.= '<table border="0"><tr bgcolor="#deffff">'.
1733: '<td rowspan=2><b>Username</b></td><td rowspan=2><b>Fullname</b></td>'."\n";
1734:
1735: my %scoreptr = (
1736: 'correct' =>'correct_by_override',
1737: 'incorrect'=>'incorrect_by_override',
1738: 'excused' =>'excused',
1739: 'ungraded' =>'ungraded_attempted',
1740: 'nothing' => '',
1741: );
1742: my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($ENV{'form.section'},'0');
1.34 ng 1743:
1.44 ng 1744: my (@partid);
1745: my %weight = ();
1746: my ($i,$ctr,$count,$rec_update) = (0,0,0,0);
1747: while ($ctr < $ENV{'form.totalparts'}) {
1748: my $partid = $ENV{'form.partid_'.$ctr};
1749: push @partid,$partid;
1750: $weight{$partid} = $ENV{'form.weight_'.$partid};
1751: $ctr++;
1752: $result .= '<td colspan = 2 align="center"><b>Part '.$partid.
1753: '</b> (Weight = '.$weight{$partid}.')</td>';
1754: }
1755: $result .= '</tr><tr bgcolor="#deffff">';
1756: foreach (@partid) {
1757: $result .= '<td align="center"> <b>Old Score</b> </td>'.
1758: '<td align="center"> <b>New Score</b> </td>';
1759: }
1760: $result .= '</tr>'."\n";
1.13 albertel 1761:
1.44 ng 1762: for ($i=0; $i<$ENV{'form.total'}; $i++) {
1763: my $user = $ENV{'form.ctr'.$i};
1764: my %newrecord;
1765: my $updateflag = 0;
1766: my @userdom = grep /^$user:/,keys %$classlist;
1767: my ($foo,$udom) = split(/:/,$userdom[0]);
1.13 albertel 1768:
1.44 ng 1769: $result .= '<tr bgcolor="#ffffde"><td>'.$user.' </td><td>'.
1770: $$fullname{$userdom[0]}.' </td>';
1.13 albertel 1771:
1.44 ng 1772: foreach (@partid) {
1773: my $old_aw = $ENV{'form.GD_'.$user.'_'.$_.'_aw_s'};
1774: my $old_part = $old_aw eq '' ? '' : $old_aw/$weight{$_};
1775: my $old_score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_sv_s'}};
1.38 ng 1776:
1.44 ng 1777: my $awarded = $ENV{'form.GD_'.$user.'_'.$_.'_aw'};
1778: my $partial = $awarded eq '' ? '' : $awarded/$weight{$_};
1779: my $score;
1780: if ($partial eq '') {
1781: $score = $scoreptr{$ENV{'form.GD_'.$user.'_'.$_.'_sv_s'}};
1782: } elsif ($partial > 0) {
1783: $score = 'correct_by_override';
1784: } elsif ($partial == 0) {
1785: $score = 'incorrect_by_override';
1786: }
1787: $score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_sv'} eq 'excused') &&
1788: ($score ne 'excused'));
1789: $result .= '<td align="center">'.$old_aw.' </td>'.
1790: '<td align="center">'.$awarded.
1791: ($score eq 'excused' ? $score : '').' </td>';
1.5 albertel 1792:
1.44 ng 1793: next if ($old_part eq $partial && $old_score eq $score);
1.5 albertel 1794:
1.44 ng 1795: $updateflag = 1;
1796: $newrecord{'resource.'.$_.'.awarded'} = $partial if $partial ne '';
1797: $newrecord{'resource.'.$_.'.solved'} = $score;
1798: $rec_update++;
1799: }
1800: $result .= '</tr>'."\n";
1801: if ($updateflag) {
1802: $count++;
1803: $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
1804: &Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
1805: $udom,$user);
1806: }
1807: }
1808: $result .= '</table></td></tr></table>'."\n";
1809: my $msg = '<b>Number of records updated = '.$rec_update.
1810: ' for '.$count.' student'.($count <= 1 ? '' : 's').'.</b><br />'.
1811: '<b>Total number of students = '.$ENV{'form.total'}.'</b><br />';
1812: return $title.$msg.$result;
1.5 albertel 1813: }
1.44 ng 1814: #------------- end of section for handling grading by section/class ---------
1815: #
1816: #----------------------------------------------------------------------------
1817:
1.5 albertel 1818:
1.44 ng 1819: #----------------------------------------------------------------------------
1820: #
1821: #-------------------------- Next few routines handles grading by csv upload
1822: #
1823: #--- Javascript to handle csv upload
1.27 albertel 1824: sub csvupload_javascript_reverse_associate {
1825: return(<<ENDPICK);
1826: function verify(vf) {
1827: var foundsomething=0;
1828: var founduname=0;
1829: var founddomain=0;
1830: for (i=0;i<=vf.nfields.value;i++) {
1831: tw=eval('vf.f'+i+'.selectedIndex');
1832: if (i==0 && tw!=0) { founduname=1; }
1833: if (i==1 && tw!=0) { founddomain=1; }
1834: if (i!=0 && i!=1 && tw!=0) { foundsomething=1; }
1835: }
1836: if (founduname==0 || founddomain==0) {
1837: alert('You need to specify at both the username and domain');
1838: return;
1839: }
1840: if (foundsomething==0) {
1841: alert('You need to specify at least one grading field');
1842: return;
1843: }
1844: vf.submit();
1845: }
1846: function flip(vf,tf) {
1847: var nw=eval('vf.f'+tf+'.selectedIndex');
1848: var i;
1849: for (i=0;i<=vf.nfields.value;i++) {
1850: //can not pick the same destination field for both name and domain
1851: if (((i ==0)||(i ==1)) &&
1852: ((tf==0)||(tf==1)) &&
1853: (i!=tf) &&
1854: (eval('vf.f'+i+'.selectedIndex')==nw)) {
1855: eval('vf.f'+i+'.selectedIndex=0;')
1856: }
1857: }
1858: }
1859: ENDPICK
1860: }
1861:
1862: sub csvupload_javascript_forward_associate {
1863: return(<<ENDPICK);
1864: function verify(vf) {
1865: var foundsomething=0;
1866: var founduname=0;
1867: var founddomain=0;
1868: for (i=0;i<=vf.nfields.value;i++) {
1869: tw=eval('vf.f'+i+'.selectedIndex');
1870: if (tw==1) { founduname=1; }
1871: if (tw==2) { founddomain=1; }
1872: if (tw>2) { foundsomething=1; }
1873: }
1874: if (founduname==0 || founddomain==0) {
1875: alert('You need to specify at both the username and domain');
1876: return;
1877: }
1878: if (foundsomething==0) {
1879: alert('You need to specify at least one grading field');
1880: return;
1881: }
1882: vf.submit();
1883: }
1884: function flip(vf,tf) {
1885: var nw=eval('vf.f'+tf+'.selectedIndex');
1886: var i;
1887: //can not pick the same destination field twice
1888: for (i=0;i<=vf.nfields.value;i++) {
1889: if ((i!=tf) && (eval('vf.f'+i+'.selectedIndex')==nw)) {
1890: eval('vf.f'+i+'.selectedIndex=0;')
1891: }
1892: }
1893: }
1894: ENDPICK
1895: }
1896:
1.26 albertel 1897: sub csvuploadmap_header {
1.41 ng 1898: my ($request,$symb,$url,$datatoken,$distotal)= @_;
1899: my $javascript;
1900: if ($ENV{'form.upfile_associate'} eq 'reverse') {
1901: $javascript=&csvupload_javascript_reverse_associate();
1902: } else {
1903: $javascript=&csvupload_javascript_forward_associate();
1904: }
1.45 ng 1905:
1906: my $result='<table border="0">';
1907: $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';
1908: my ($partlist,$handgrade) = &response_type($url);
1909: my ($resptype,$hdgrade)=('','no');
1910: for (sort keys(%$handgrade)) {
1911: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
1912: $resptype = $responsetype;
1913: $hdgrade = $handgrade if ($handgrade eq 'yes');
1914: $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
1915: '<td><b>Type: </b>'.$responsetype.'</td>'.
1916: '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
1917: }
1918: $result.='</table>';
1.41 ng 1919: $request->print(<<ENDPICK);
1.26 albertel 1920: <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
1.45 ng 1921: <h3><font color="#339933">Uploading Class Grades</font></h3>
1922: $result
1.26 albertel 1923: <hr>
1924: <h3>Identify fields</h3>
1925: Total number of records found in file: $distotal <hr />
1926: Enter as many fields as you can. The system will inform you and bring you back
1927: to this page if the data selected is insufficient to run your class.<hr />
1928: <input type="button" value="Reverse Association" onClick="javascript:this.form.associate.value='Reverse Association';submit(this.form);" />
1929: <input type="hidden" name="associate" value="" />
1930: <input type="hidden" name="phase" value="three" />
1931: <input type="hidden" name="datatoken" value="$datatoken" />
1932: <input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" />
1933: <input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" />
1934: <input type="hidden" name="upfile_associate"
1935: value="$ENV{'form.upfile_associate'}" />
1936: <input type="hidden" name="symb" value="$symb" />
1937: <input type="hidden" name="url" value="$url" />
1938: <input type="hidden" name="command" value="csvuploadassign" />
1939: <hr />
1940: <script type="text/javascript" language="Javascript">
1941: $javascript
1942: </script>
1943: ENDPICK
1.41 ng 1944: return '';
1.26 albertel 1945:
1946: }
1947:
1948: sub csvupload_fields {
1.41 ng 1949: my ($url) = @_;
1950: my (@parts) = &getpartlist($url);
1951: my @fields=(['username','Student Username'],['domain','Student Domain']);
1952: foreach my $part (sort(@parts)) {
1953: my @datum;
1954: my $display=&Apache::lonnet::metadata($url,$part.'.display');
1955: my $name=$part;
1956: if (!$display) { $display = $name; }
1957: @datum=($name,$display);
1958: push(@fields,\@datum);
1959: }
1960: return (@fields);
1.26 albertel 1961: }
1962:
1963: sub csvuploadmap_footer {
1.41 ng 1964: my ($request,$i,$keyfields) =@_;
1965: $request->print(<<ENDPICK);
1.26 albertel 1966: </table>
1967: <input type="hidden" name="nfields" value="$i" />
1968: <input type="hidden" name="keyfields" value="$keyfields" />
1969: <input type="button" onClick="javascript:verify(this.form)" value="Assign Grades" /><br />
1970: </form>
1971: ENDPICK
1972: }
1973:
1974: sub csvuploadmap {
1.41 ng 1975: my ($request)= @_;
1976: my ($symb,$url)=&get_symb_and_url($request);
1977: if (!$symb) {return '';}
1978: my $datatoken;
1979: if (!$ENV{'form.datatoken'}) {
1980: $datatoken=&Apache::loncommon::upfile_store($request);
1.26 albertel 1981: } else {
1.41 ng 1982: $datatoken=$ENV{'form.datatoken'};
1983: &Apache::loncommon::load_tmp_file($request);
1.26 albertel 1984: }
1.41 ng 1985: my @records=&Apache::loncommon::upfile_record_sep();
1986: &csvuploadmap_header($request,$symb,$url,$datatoken,$#records+1);
1987: my ($i,$keyfields);
1988: if (@records) {
1989: my @fields=&csvupload_fields($url);
1.45 ng 1990:
1.41 ng 1991: if ($ENV{'form.upfile_associate'} eq 'reverse') {
1992: &Apache::loncommon::csv_print_samples($request,\@records);
1993: $i=&Apache::loncommon::csv_print_select_table($request,\@records,
1994: \@fields);
1995: foreach (@fields) { $keyfields.=$_->[0].','; }
1996: chop($keyfields);
1997: } else {
1998: unshift(@fields,['none','']);
1999: $i=&Apache::loncommon::csv_samples_select_table($request,\@records,
2000: \@fields);
2001: my %sone=&Apache::loncommon::record_sep($records[0]);
2002: $keyfields=join(',',sort(keys(%sone)));
2003: }
2004: }
2005: &csvuploadmap_footer($request,$i,$keyfields);
2006: return '';
1.27 albertel 2007: }
2008:
2009: sub csvuploadassign {
1.41 ng 2010: my ($request)= @_;
2011: my ($symb,$url)=&get_symb_and_url($request);
2012: if (!$symb) {return '';}
2013: &Apache::loncommon::load_tmp_file($request);
1.44 ng 2014: my @gradedata = &Apache::loncommon::upfile_record_sep();
1.41 ng 2015: my @keyfields = split(/\,/,$ENV{'form.keyfields'});
2016: my %fields=();
2017: for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
2018: if ($ENV{'form.upfile_associate'} eq 'reverse') {
2019: if ($ENV{'form.f'.$i} ne 'none') {
2020: $fields{$keyfields[$i]}=$ENV{'form.f'.$i};
2021: }
2022: } else {
2023: if ($ENV{'form.f'.$i} ne 'none') {
2024: $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
2025: }
2026: }
1.27 albertel 2027: }
1.41 ng 2028: $request->print('<h3>Assigning Grades</h3>');
2029: my $courseid=$ENV{'request.course.id'};
2030: my ($classlist) = &getclasslist('all','1');
2031: my @skipped;
2032: my $countdone=0;
2033: foreach my $grade (@gradedata) {
2034: my %entries=&Apache::loncommon::record_sep($grade);
2035: my $username=$entries{$fields{'username'}};
2036: my $domain=$entries{$fields{'domain'}};
2037: if (!exists($$classlist{"$username:$domain"})) {
2038: push(@skipped,"$username:$domain");
2039: next;
2040: }
2041: my %grades;
2042: foreach my $dest (keys(%fields)) {
2043: if ($dest eq 'username' || $dest eq 'domain') { next; }
2044: if ($entries{$fields{$dest}} eq '') { next; }
2045: my $store_key=$dest;
2046: $store_key=~s/^stores/resource/;
2047: $store_key=~s/_/\./g;
2048: $grades{$store_key}=$entries{$fields{$dest}};
2049: }
2050: $grades{"resource.regrader"}="$ENV{'user.name'}:$ENV{'user.domain'}";
2051: &Apache::lonnet::cstore(\%grades,$symb,$ENV{'request.course.id'},
2052: $domain,$username);
2053: $request->print('.');
2054: $request->rflush();
2055: $countdone++;
2056: }
2057: $request->print("<br />Stored $countdone students\n");
2058: if (@skipped) {
2059: $request->print('<br /><font size="+1"><b>Skipped Students</b></font><br />');
2060: foreach my $student (@skipped) { $request->print("<br />$student"); }
2061: }
2062: $request->print(&view_edit_entire_class_form($symb,$url));
2063: $request->print(&show_grading_menu_form($symb,$url));
2064: return '';
1.26 albertel 2065: }
1.44 ng 2066: #------------- end of section for handling csv file upload ---------
2067: #
2068: #-------------------------------------------------------------------
2069:
2070: #-------------------------- Menu interface -------------------------
2071: #
2072: #--- Show a Grading Menu button - Calls the next routine ---
2073: sub show_grading_menu_form {
2074: my ($symb,$url)=@_;
2075: my $result.='<form action="/adm/grades" method="post">'."\n".
2076: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
2077: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
2078: '<input type="hidden" name="command" value="gradingmenu" />'."\n".
2079: '<input type="submit" name="submit" value="Grading Menu" />'."\n".
2080: '</form>'."\n";
2081: return $result;
2082: }
2083:
2084: #--- Displays the main menu page -------
2085: sub gradingmenu {
2086: my ($request) = @_;
2087: my ($symb,$url)=&get_symb_and_url($request);
2088: if (!$symb) {return '';}
1.45 ng 2089: my $result='<h3> <font color="#339933">Select a Grading Method</font></h3>';
1.44 ng 2090: $result.='<table border="0">';
2091: $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';
2092: my ($partlist,$handgrade) = &response_type($url);
2093: my ($resptype,$hdgrade)=('','no');
2094: for (sort keys(%$handgrade)) {
2095: my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
2096: $resptype = $responsetype;
2097: $hdgrade = $handgrade if ($handgrade eq 'yes');
2098: $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
2099: '<td><b>Type: </b>'.$responsetype.'</td>'.
2100: '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
2101: }
2102: $result.='</table>';
2103: $result.=&view_edit_entire_class_form($symb,$url).'<br />';
2104: $result.=&upcsvScores_form($symb,$url).'<br />';
2105: $result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />';
2106: $result.=&verifyReceipt_form($symb,$url)
2107: if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb));
2108:
2109: return $result;
2110: }
2111:
2112: #--- Menu for grading a section or the whole class ---
2113: sub view_edit_entire_class_form {
2114: my ($symb,$url)=@_;
2115: my ($classlist,$sections) = &getclasslist('all','0');
2116: my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
2117: $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
2118: $result.=' <b>View/Grade Entire Section/Class</b></td></tr>'."\n";
2119: $result.='<tr bgcolor=#ffffe6><td>'."\n";
2120: $result.='<form action="/adm/grades" method="post">'."\n".
2121: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
2122: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
2123: '<input type="hidden" name="command" value="viewgrades" />'."\n";
2124: $result.=' <b>Select section:</b> <select name="section">'."\n";
1.49 ! albertel 2125: if (ref($sections)) {
! 2126: foreach (sort (@$sections)) {
! 2127: $result.= '<option>'.$_.'</option>'."\n";
! 2128: }
1.44 ng 2129: }
2130: $result.='<option selected="on">all</select>'."<br />\n";
1.46 ng 2131: $result.=' <input type="button" onClick="submit();" value="View/Grade" /></form>'."\n";
1.44 ng 2132: $result.='</td></tr></table>'."\n";
2133: $result.='</td></tr></table>'."\n";
2134: return $result;
2135: }
2136:
2137: #--- Menu to upload a csv scores ---
2138: sub upcsvScores_form {
2139: my ($symb,$url) = @_;
2140: if (!$symb) {return '';}
1.46 ng 2141: my $result = '<script type="text/javascript" language="javascript">'."\n".
2142: ' function checkUpload(formname) {'."\n".
2143: ' if (formname.upfile.value == "") {'."\n".
2144: ' alert("Please use the browse button to select a file from your local directory.");'."\n".
2145: ' return false;'."\n".
2146: ' }'."\n".
2147: ' formname.submit();'."\n".
2148: ' }'."\n".
2149: '</script>'."\n";
2150:
2151: $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
1.44 ng 2152: $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
2153: $result.=' <b>Specify a file containing the class scores for above resource</b></td></tr>'."\n";
2154: $result.='<tr bgcolor=#ffffe6><td>'."\n";
2155: my $upfile_select=&Apache::loncommon::upfile_select_html();
2156: $result.=<<ENDUPFORM;
2157: <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
2158: <input type="hidden" name="symb" value="$symb" />
2159: <input type="hidden" name="url" value="$url" />
2160: <input type="hidden" name="command" value="csvuploadmap" />
2161: $upfile_select
1.46 ng 2162: <br /> <input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Grades" />
1.44 ng 2163: </form>
2164: ENDUPFORM
2165: $result.='</td></tr></table>'."\n";
2166: $result.='</td></tr></table>'."\n";
2167: return $result;
2168: }
2169:
2170: #--- Handgrading problems ---
2171: sub viewGradeaStu_form {
2172: my ($symb,$url,$response,$handgrade) = @_;
2173: my ($classlist,$sections) = &getclasslist('all','0');
2174: my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
2175: $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
1.49 ! albertel 2176: $result.=' <b>';
! 2177: if ($handgrade eq 'yes') {
! 2178: $result.="View/Grade ";
! 2179: } else {
! 2180: $result.="View ";
! 2181: }
! 2182: $result.='an Individual Student\'s Submission</b></td></tr>'."\n";
1.44 ng 2183: $result.='<tr bgcolor=#ffffe6><td>'."\n";
2184: $result.='<form action="/adm/grades" method="post">'."\n".
2185: '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
2186: '<input type="hidden" name="url" value="'.$url.'" />'."\n".
2187: '<input type="hidden" name="response" value="'.$response.'" />'."\n".
2188: '<input type="hidden" name="handgrade" value="'.$handgrade.'" />'."\n".
2189: '<input type="hidden" name="showgrading" value="yes" />'."\n".
2190: '<input type="hidden" name="command" value="submission" />'."\n";
1.26 albertel 2191:
1.44 ng 2192: $result.=' <b>Select section:</b> <select name="section">'."\n";
1.49 ! albertel 2193: if (ref($sections)) {
! 2194: foreach (sort (@$sections)) {$result.='<option>'.$_.'</option>'."\n";}
1.44 ng 2195: }
2196: $result.= '<option selected="on">all</select>'."\n";
2197: $result.=' <b>Display students who has: </b>'.
2198: '<input type="radio" name="submitonly" value="yes" checked> submitted'.
2199: '<input type="radio" name="submitonly" value="all"> everybody <br />';
1.49 ! albertel 2200: if (ref($sections)) {
! 2201: $result.=' (Section "no" implies the students were not assigned a section.)<br />'
! 2202: if (grep /no/,@$sections);
! 2203: }
! 2204:
! 2205:
! 2206: $result.='<br /> <input type="button" onClick="submit();" value="';
! 2207: if ($handgrade eq 'yes') {
! 2208: $result.="View/Grade";
! 2209: } else {
! 2210: $result.="View";
! 2211: }
! 2212: $result.='" />'."\n".'</form>'."\n";
1.44 ng 2213: $result.='</td></tr></table>'."\n";
2214: $result.='</td></tr></table>'."\n";
2215: return $result;
1.2 albertel 2216: }
2217:
1.44 ng 2218: #--- Form to input a receipt number ---
2219: sub verifyReceipt_form {
2220: my ($symb,$url) = @_;
1.46 ng 2221: my $result = '<script type="text/javascript" language="javascript">'."\n".
2222: ' function checkEntry(formname) {'."\n".
2223: ' var receipt = formname.receipt.value;'."\n".
2224: ' if (isNaN(receipt) || receipt == "") {'."\n".
2225: ' alert("Please enter a receipt number given by a student in the box.");'."\n".
2226: ' return false;'."\n".
2227: ' }'."\n".
2228: ' formname.submit();'."\n".
2229: ' }'."\n".
2230: '</script>'."\n";
2231:
1.44 ng 2232: my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
2233:
1.46 ng 2234: $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
1.44 ng 2235: $result.='<table width=100% border=0><tr><td bgcolor=#e6ffff>'."\n";
2236: $result.=' <b>Verify a Submission Receipt Issued by this Server</td></tr>'."\n";
2237: $result.='<tr bgcolor=#ffffe6><td>'."\n";
1.46 ng 2238: $result.='<form action="/adm/grades" method="post" name="verifyform">'."\n";
1.44 ng 2239: $result.=' <tt>'.$hostver.'-<input type="text" name="receipt" size="4"></tt><br />'."\n";
1.46 ng 2240: $result.=' <input type="button" onClick="javascript:checkEntry(this.form);"'.
2241: ' value="Verify Receipt">'."\n";
1.44 ng 2242: $result.='<input type="hidden" name="command" value="verify">'."\n";
2243: if ($ENV{'form.url'}) {
2244: $result.='<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />';
2245: }
2246: if ($ENV{'form.symb'}) {
2247: $result.='<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />';
2248: }
2249: $result.='</form>';
2250: $result.='</td></tr></table>'."\n";
2251: $result.='</td></tr></table>'."\n";
2252: return $result;
1.2 albertel 2253: }
2254:
1.1 albertel 2255: sub handler {
1.41 ng 2256: my $request=$_[0];
2257:
2258: if ($ENV{'browser.mathml'}) {
2259: $request->content_type('text/xml');
2260: } else {
2261: $request->content_type('text/html');
2262: }
2263: $request->send_http_header;
1.44 ng 2264: return '' if $request->header_only;
1.41 ng 2265: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
2266: my $url=$ENV{'form.url'};
2267: my $symb=$ENV{'form.symb'};
2268: my $command=$ENV{'form.command'};
2269: if (!$url) {
2270: my ($temp1,$temp2);
2271: ($temp1,$temp2,$ENV{'form.url'})=split(/___/,$symb);
2272: $url = $ENV{'form.url'};
2273: }
2274: &send_header($request);
2275: if ($url eq '' && $symb eq '') {
2276: if ($ENV{'user.adv'}) {
2277: if (($ENV{'form.codeone'}) && ($ENV{'form.codetwo'}) &&
2278: ($ENV{'form.codethree'})) {
2279: my $token=$ENV{'form.codeone'}.'*'.$ENV{'form.codetwo'}.'*'.
2280: $ENV{'form.codethree'};
2281: my ($tsymb,$tuname,$tudom,$tcrsid)=
2282: &Apache::lonnet::checkin($token);
2283: if ($tsymb) {
2284: my ($map,$id,$url)=split(/\_\_\_/,$tsymb);
2285: if (&Apache::lonnet::allowed('mgr',$tcrsid)) {
2286: $request->print(
2287: &Apache::lonnet::ssi('/res/'.$url,
2288: ('grade_username' => $tuname,
2289: 'grade_domain' => $tudom,
2290: 'grade_courseid' => $tcrsid,
2291: 'grade_symb' => $tsymb)));
2292: } else {
1.45 ng 2293: $request->print('<h3>Not authorized: '.$token.'</h3>');
1.41 ng 2294: }
2295: } else {
1.45 ng 2296: $request->print('<h3>Not a valid DocID: '.$token.'</h3>');
1.41 ng 2297: }
1.14 www 2298: } else {
1.41 ng 2299: $request->print(&Apache::lonxml::tokeninputfield());
2300: }
2301: }
2302: } else {
2303: $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
2304: if ($command eq 'submission') {
2305: &listStudents($request) if ($ENV{'form.student'} eq '');
2306: &submission($request,0,0) if ($ENV{'form.student'} ne '');
2307: } elsif ($command eq 'processGroup') {
2308: &processGroup($request);
2309: } elsif ($command eq 'gradingmenu') {
2310: $request->print(&gradingmenu($request));
2311: } elsif ($command eq 'viewgrades') {
2312: $request->print(&viewgrades($request));
2313: } elsif ($command eq 'handgrade') {
2314: $request->print(&processHandGrade($request));
2315: } elsif ($command eq 'editgrades') {
2316: $request->print(&editgrades($request));
2317: } elsif ($command eq 'verify') {
2318: $request->print(&verifyreceipt($request));
2319: } elsif ($command eq 'csvupload') {
2320: $request->print(&csvupload($request));
2321: } elsif ($command eq 'viewclasslist') {
2322: $request->print(&viewclasslist($request));
2323: } elsif ($command eq 'csvuploadmap') {
2324: $request->print(&csvuploadmap($request));
2325: } elsif ($command eq 'csvuploadassign') {
2326: if ($ENV{'form.associate'} ne 'Reverse Association') {
2327: $request->print(&csvuploadassign($request));
2328: } else {
2329: if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
2330: $ENV{'form.upfile_associate'} = 'reverse';
2331: } else {
2332: $ENV{'form.upfile_associate'} = 'forward';
2333: }
2334: $request->print(&csvuploadmap($request));
2335: }
1.26 albertel 2336: } else {
1.41 ng 2337: $request->print("Unknown action: $command:");
1.26 albertel 2338: }
1.2 albertel 2339: }
1.41 ng 2340: &send_footer($request);
1.44 ng 2341: return '';
2342: }
2343:
2344: sub send_header {
2345: my ($request)= @_;
2346: $request->print(&Apache::lontexconvert::header());
2347: # $request->print("
2348: #<script>
2349: #remotewindow=open('','homeworkremote');
2350: #remotewindow.close();
2351: #</script>");
1.47 www 2352: $request->print(&Apache::loncommon::bodytag('Grading'));
1.44 ng 2353: }
2354:
2355: sub send_footer {
2356: my ($request)= @_;
2357: $request->print('</body>');
2358: $request->print(&Apache::lontexconvert::footer());
1.1 albertel 2359: }
2360:
2361: 1;
2362:
1.13 albertel 2363: __END__;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>