Annotation of loncom/homework/bridgetask.pm, revision 1.111
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # definition of tags that give a structure to a document
3: #
1.111 ! albertel 4: # $Id: bridgetask.pm,v 1.110 2006/02/14 19:51:29 albertel Exp $
1.1 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: #
28: ###
29:
30:
31: package Apache::bridgetask;
32:
33: use strict;
34: use Apache::lonnet;
35: use Apache::File();
36: use Apache::lonmenu;
37: use Apache::lonlocal;
38: use Apache::lonxml;
1.37 albertel 39: use Apache::slotrequest();
1.1 albertel 40: use Time::HiRes qw( gettimeofday tv_interval );
1.9 albertel 41:
1.1 albertel 42: BEGIN {
43: &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Instance','InstanceText','Criteria','ClosingParagraph'));
44: }
45:
1.9 albertel 46: sub initialize_bridgetask {
47: # id of current Dimension, 0 means that no dimension is current
48: # (inside <Task> only)
49: $Apache::bridgetask::dimension='';
50: # list of all Dimension ids seen
51: @Apache::bridgetask::dimensionlist=();
1.20 albertel 52: # mandatory attribute of all Dimensions seen
53: %Apache::bridgetask::dimensionmandatory=();
1.9 albertel 54: # list of all current Instance ids
55: @Apache::bridgetask::instance=();
56: # list of all Instance ids seen in this problem
57: @Apache::bridgetask::instancelist=();
1.15 albertel 58: # key of queud user data that we are currently grading
59: $Apache::bridgetask::queue_key='';
1.9 albertel 60: }
61:
1.4 albertel 62: sub proctor_check_auth {
1.81 albertel 63: my ($slot_name,$slot,$type)=@_;
1.11 albertel 64: my $user=$env{'form.proctorname'};
65: my $domain=$env{'form.proctordomain'};
1.4 albertel 66:
67: my @allowed=split(",",$slot->{'proctor'});
68: foreach my $possible (@allowed) {
69: my ($puser,$pdom)=(split('@',$possible));
70: if ($puser eq $user && $pdom eq $domain) {
1.72 albertel 71: my $authenticated=0;
72: if ( $slot->{'secret'} =~ /\S/ &&
73: $env{'form.proctorpassword'} eq $slot->{'secret'} ) {
74: $authenticated=1;
75: } else {
76:
77: my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
78: if ($authhost ne 'no_host') {
79: $authenticated=1;
80: }
81: }
1.81 albertel 82: if ($authenticated && $type eq 'Task') {
1.93 albertel 83: # increment version
1.23 albertel 84: my $version=
1.90 albertel 85: $Apache::lonhomework::history{'resource.0.version'};
86: $version++;
1.93 albertel 87:
88: #clean out all current results
89: foreach my $key (keys(%Apache::lonhomework::history)) {
90: if ($key=~/^resource\.0\./) {
91: $Apache::lonhomework::results{$key}='';
92: }
93: }
94:
95: #setup new version and who did it
1.90 albertel 96: $Apache::lonhomework::results{'resource.0.version'}=$version;
1.89 albertel 97: $Apache::lonhomework::results{"resource.$version.0.checkedin"}=
1.4 albertel 98: $user.'@'.$domain;
1.89 albertel 99: $Apache::lonhomework::results{"resource.$version.0.checkedin.slot"}=
1.22 albertel 100: $slot_name;
1.93 albertel 101:
1.4 albertel 102: return 1;
1.81 albertel 103: } elsif ($authenticated && $type eq 'problem') {
1.90 albertel 104: &Apache::lonxml::debug("authed $slot_name");
1.81 albertel 105: $Apache::lonhomework::results{"resource.0.checkedin"}=
106: $user.'@'.$domain;
107: $Apache::lonhomework::results{"resource.0.checkedin.slot"}=
108: $slot_name;
1.4 albertel 109: }
110: }
111: }
112: return 0;
113: }
114:
1.25 albertel 115: sub get_version {
1.29 albertel 116: my ($version,$previous);
1.25 albertel 117: if ($env{'form.previousversion'} &&
1.36 albertel 118: $env{'form.previousversion'} ne 'current' &&
1.89 albertel 119: defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.0.status'})) {
1.29 albertel 120: $version=$env{'form.previousversion'};
121: $previous=1;
122: } else {
1.89 albertel 123: $version=$Apache::lonhomework::history{'resource.0.version'};
1.29 albertel 124: $previous=0;
125: }
126: if (wantarray) {
127: return ($version,$previous);
1.25 albertel 128: }
1.29 albertel 129: return $version;
1.25 albertel 130: }
131:
1.8 albertel 132: sub add_previous_version_button {
1.25 albertel 133: my ($status)=@_;
1.8 albertel 134: my $result;
1.89 albertel 135: if ($Apache::lonhomework::history{'resource.0.version'} eq '') {
1.25 albertel 136: return '';
137: }
1.89 albertel 138: if ($Apache::lonhomework::history{'resource.0.version'} < 2 &&
1.29 albertel 139: $status ne 'NEEDS_CHECKIN') {
1.25 albertel 140: return '';
141: }
1.29 albertel 142: my $version=&get_version();
143: if ($env{'form.previousversion'} ne '' &&
144: $env{'form.previousversion'} eq $version) {
145: $result.="<h3>".&mt("Showing previous version [_1]",$version).
146: "</h3>\n";
147: }
148: my @to_show;
1.89 albertel 149: foreach my $test_version (1..$Apache::lonhomework::history{'resource.0.version'}) {
150: if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.0.status'})) {
1.29 albertel 151: push(@to_show,$test_version);
152: }
153: }
154: my $list='<option>'.
155: join("</option>\n<option>",@to_show).
156: "</option>\n";
1.36 albertel 157: $list.='<option value="current">'.&mt('Current').'</option>';
1.29 albertel 158: $result.='<form name="getprevious" method="POST" action="';
159: my $uri=$env{'request.uri'};
160: if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
161: $result.=$uri.'">'.
162: &mt(' Show a previously done version: [_1]','<select onchange="this.form.submit()" name="previousversion">
163: <option>'.&mt('Pick one').'</option>
164: '.$list.'
165: </select>')."</form>";
1.8 albertel 166: return $result;
167: }
168:
1.13 albertel 169: sub add_grading_button {
1.59 albertel 170: my (undef,$cid)=&Apache::lonxml::whichuser();
171: my $cnum=$env{'course.'.$cid.'.num'};
172: my $cdom=$env{'course.'.$cid.'.domain'};
173: my %sections;
174: my $numsections=&Apache::loncommon::get_sections($cdom,$cnum,\%sections);
175: my $size=5;
176: if (scalar(keys(%sections)) < 3) {
177: $size=scalar(keys(%sections))+2;
178: }
179: my $sec_select = '<select multiple name="chosensections" size="'.$size.'">'."\n";
180: $sec_select .= "<option value='all' selected='selected'>all</option>\n";
181: foreach my $sec (sort {lc($a) cmp lc($b)} (keys(%sections))) {
182: $sec_select .= "<option name=\"$sec\">$sec</option>\n";
183: }
184: $sec_select .= "<option value='none'>none</option></select>\n";
185:
1.29 albertel 186: my $result=' <input type="submit" name="gradeasubmission" value="'.
1.13 albertel 187: &mt("Get a submission to grade").'" />';
188: $result.='<input type="hidden" name="grade_target" value="webgrade" />';
1.40 albertel 189: if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
1.34 albertel 190: my ($entries,$ready,$locks)=&get_queue_counts('gradingqueue');
1.106 albertel 191: $result.='<table><tr>';
192: $result.='<td rowspan="4">Specify a section: </td><td rowspan="4">'.$sec_select.'</td>';
193: $result.='<td>'.' <input type="submit" name="reviewagrading" value="'.
194: &mt("Select an entry from the grading queue:").'" /> ';
1.34 albertel 195:
1.107 albertel 196: $result.= &mt("[_1] entries, [_2] ready, [_3] being graded",$entries,$ready,$locks).' </td></tr>'."\n";
1.34 albertel 197:
198: ($entries,$ready,$locks)=&get_queue_counts('reviewqueue');
1.106 albertel 199: $result.='<tr><td>'.
200: ' <input type="submit" name="reviewasubmission" value="'.
201: &mt("Select an entry from the review queue:").'" /> ';
202: $result.=&mt("[_1] entries, [_2] ready, [_3] being graded",
203: $entries,$ready,$locks).'</td></tr>'."\n";
204: $result.='<tr><td> <input type="submit" name="regradeasubmission" value="'.
205: &mt("List of user's grade status").'" /> </td></tr></table>'."\n";
1.105 albertel 206: $result.='<p> <input type="submit" name="regradeaspecificsubmission" value="'.
1.106 albertel 207: &mt("Regrade specific user:").'" />'."\n";
1.105 albertel 208: $result.='<input type="text" size="12" name="gradinguser" />';
209: $result.=&Apache::loncommon::select_dom_form($env{'user.domain'},
210: 'gradingdomain');
211: $result.=' '.
212: &Apache::loncommon::selectstudent_link('gradesubmission',
213: 'gradinguser',
214: 'gradingdomain');
215: $result.=&Apache::loncommon::studentbrowser_javascript();
216: }
1.13 albertel 217: return $result;
218: }
219:
1.22 albertel 220: sub add_request_another_attempt_button {
1.38 albertel 221: my ($text)=@_;
222: if (!$text) { $text="Request another attempt"; }
1.25 albertel 223: my $result;
1.36 albertel 224: my $symb=&Apache::lonnet::symbread();
1.37 albertel 225: my ($slot_name,$slot)=&Apache::slotrequest::check_for_reservation($symb);
1.38 albertel 226: my $action='get_reservation';
1.37 albertel 227: if ($slot_name) {
1.38 albertel 228: $text="Change reservation.";
229: $action='change_reservation';
1.37 albertel 230: my $description=&Apache::slotrequest::get_description($slot_name,
231: $slot);
232: $result.=(<<STUFF);
233: <p> Will be next available: $description </p>
234: STUFF
235: }
1.38 albertel 236:
237: if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); }
238: $symb=&Apache::lonnet::escape($symb);
239: $result.='<form method="POST" action="/adm/slotrequest">'.
240: '<input type="hidden" name="symb" value="'.$symb.'" />'.
241: '<input type="hidden" name="command" value="'.$action.'" />'.
242: '<input type="submit" name="requestattempt" value="'.
243: &mt($text).'" />'.
244: '</form>';
1.25 albertel 245: return $result;
1.22 albertel 246: }
247:
1.30 albertel 248: sub preserve_grade_info {
249: my $result;
250: # if we are viewing someone else preserve that info
251: if (defined $env{'form.grade_symb'}) {
252: foreach my $field ('symb','courseid','domain','username') {
253: $result .= '<input type="hidden" name="grade_'.$field.
254: '" value="'.$env{"form.grade_$field"}.'" />'."\n";
255: }
256: }
257: return $result;
258: }
259:
1.53 albertel 260: sub style {
261: return (<<STYLE);
262: <style type="text/css">
263: .fail, .pass, .neutral {
264: position: relative;
265: margin : 5px;
266: margin-bottom :10px;
267: padding : 4px;
268: padding-left : 75px;
269: border : thin solid;
270: font-weight : bolder;
271: font-size: smaller;
272: font-family: Arial;
273: background-color : rgb(255,240,225);
274: }
275:
276: .fail h4, .pass h4 {
277: position:absolute;
278: left: -4px;
279: top: -8px;
280: padding:2px;
281: margin:0;
282: background-color : rgb(255,240,225);
283: border : thin solid;
284: }
285:
286: .fail {
287: color: red;
288: }
289:
290: .pass {
291: color : green;
292: }
293:
294: .neutral {
295: color : blue;
296: }
297:
298: .question {
299: border : thin solid black;
300: padding : 4px;
301: margin-bottom : 1em;
302: }
303:
304: .grade {
305: font-size: x-large;
306: font-family: Arial;
307: position:absolute;
308: left: 5px;
309: top: -5px;
310: width: 70px;
311: }
312:
313: div#feedback h1 {
314: color : inherit;
315: }
316: </style>
317: STYLE
318:
319: }
320:
1.54 albertel 321: sub show_task {
322: my ($status,$previous)=@_;
323: if (!$previous && (
324: ( $status eq 'CLOSED' ) ||
325: ( $status eq 'BANNED') ||
326: ( $status eq 'UNAVAILABLE') ||
327: ( $status eq 'NOT_IN_A_SLOT') ||
328: ( $status eq 'NEEDS_CHECKIN') ||
329: ( $status eq 'WAITING_FOR_GRADE') ||
330: ( $status eq 'INVALID_ACCESS') )) {
331: return 0;
332: }
1.64 albertel 333: if ($env{'form.donescreen'}) { return 0; }
1.54 albertel 334: return 1;
335: }
336:
337: sub internal_location {
338: my ($id)=@_;
339: return '<!-- LONCAPA_INTERNAL_ADD_TASK_STATUS'.$id.' -->';
340: }
341:
1.60 albertel 342: sub submission_time_stamp {
343: my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
344: my $submissiontime;
1.89 albertel 345: my $version=$Apache::lonhomework::history{'resource.0.version'};
1.60 albertel 346: for (my $v=$Apache::lonhomework::history{'version'};$v>0;$v--) {
347: if (defined($Apache::lonhomework::history{$v.':resource.'.$version.'.0.bridgetask.portfiles'})) {
348: $submissiontime=$Apache::lonhomework::history{$v.':timestamp'};
349: }
350: }
351: my $result;
352: if ($submissiontime) {
1.89 albertel 353: my $slot_name=$Apache::lonhomework::history{'resource.'.$version.'.0.checkedin.slot'};
1.60 albertel 354: my %slot=&Apache::lonnet::get_slot($slot_name);
355: my $diff = $slot{'endtime'} - $submissiontime;
1.71 albertel 356: my ($color,$when)=('#FF6666','after');
357: if ($diff > 0) { ($color,$when)=('#336600','before'); }
1.60 albertel 358: my $info;
359: if ($diff%60) { $info=($diff%60).' seconds'; }
360: $diff=int($diff/60);
361: if ($diff%60) { $info=($diff%60).' minutes '.$info; }
362: $diff=int($diff/60);
363: if ($diff) { $info=$diff.' hours '.$info; }
364: $result='<p><font color="'.$color.'">'.
365: &mt('Student submitted [_1] [_2] the deadline.
366: (Submission was at [_3], end of period was [_4].)',
367: $info,$when,scalar(localtime($submissiontime)),
368: scalar(localtime($slot{'endtime'}))).
369: '</font></p>';
370: }
371: return $result;
372: }
373:
1.70 albertel 374: sub webgrade_standard_info {
375: my ($version)=&get_version();
376: my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
377: my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
378: my $file_list="<ul>\n";
379: foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"})) {
380: my $file=$file_url.$partial_file;
381: $file=~s|/+|/|g;
382: &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
1.73 albertel 383: $file_list.='<li><nobr><a href="'.$file.'?rawmode=1" target="lonGRDs"><img src="'.
1.109 albertel 384: &Apache::loncommon::icon($file).'" border="0"> '.$file.
1.70 albertel 385: '</a></nobr></li>'."\n";
386: }
387: $file_list.="</ul>\n";
388:
389: my %lt=&Apache::lonlocal::texthash('done' => 'Done',
390: 'stop' => 'Stop',
391: );
392:
393: my $result=<<INFO;
394: <div class="handininfo">
1.111 ! albertel 395: <div class="maincontrols">
! 396: <input type="submit" name="next" value="$lt{'done'}" />
! 397: <input type="submit" name="stop" value="$lt{'stop'}" />
! 398: </div>
1.70 albertel 399: $file_list
400: </div>
401: INFO
402: return $result;
403: }
404:
1.1 albertel 405: sub start_Task {
1.87 albertel 406: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.1 albertel 407:
1.4 albertel 408: my ($status,$accessmsg,$slot);
1.16 albertel 409: if ($target ne 'webgrade') {
1.70 albertel 410: &Apache::structuretags::init_problem_globals('Task');
1.16 albertel 411: &Apache::structuretags::initialize_storage();
412: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
1.74 albertel 413: if ($env{'request.state'} eq 'construct') {
414: &Apache::structuretags::setup_rndseed($safeeval);
415: }
1.16 albertel 416: }
417:
1.4 albertel 418: $Apache::lonhomework::parsing_a_task=1;
1.1 albertel 419: #should get back a <html> or the neccesary stuff to start XML/MathML
420: my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
421: &Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
1.16 albertel 422:
1.74 albertel 423: if ($target eq 'web' && $env{'request.state'} ne 'construct') {
1.13 albertel 424: if ($Apache::lonhomework::modifygrades) {
425: $body_tag_start.='<form name="gradesubmission" method="POST" action="';
426: my $uri=$env{'request.uri'};
427: if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
428: $body_tag_start.=$uri.'">'.&add_grading_button()."</form>";
1.38 albertel 429: my $symb=&Apache::lonnet::symbread();
1.40 albertel 430: if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
1.108 albertel 431: $body_tag_start.='<form method="POST" name="slotrequest" action="/adm/slotrequest">'.
1.40 albertel 432: '<input type="hidden" name="symb" value="'.$symb.'" />'.
433: '<input type="hidden" name="command" value="showslots" />'.
434: '<input type="submit" name="requestattempt" value="'.
435: &mt('Show Slot list').'" />'.
436: '</form>';
1.108 albertel 437: my $target_id =
438: &Apache::lonstathelpers::make_target_id({symb => $symb,
439: part => '0'});
440: $body_tag_start.='<form method="POST" name="gradingstatus" action="/adm/statistics">'.
441: '<input type="hidden" name="problemchoice" value="'.$target_id.'" />'.
442: '<input type="hidden" name="reportSelected" value="grading_analysis" />'.
443: '<input type="submit" name="grading" value="'.
444: &mt('Show Grading Status').'" />'.
445: '</form>';
1.40 albertel 446: }
1.13 albertel 447: }
1.8 albertel 448: }
1.74 albertel 449: if ($target eq 'web' && $env{'request.state'} eq 'construct') {
450: $form_tag_start.=&Apache::structuretags::problem_web_to_edit_header($env{'form.rndseed'});
451: }
1.21 albertel 452: if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
1.1 albertel 453: $target eq 'tex') {
1.29 albertel 454: my ($version,$previous)=&get_version();
1.14 albertel 455: ($status,$accessmsg,my $slot_name,$slot) =
1.81 albertel 456: &Apache::lonhomework::check_slot_access('0','Task');
1.9 albertel 457: push(@Apache::inputtags::status,$status);
1.14 albertel 458: $Apache::inputtags::slot_name=$slot_name;
1.1 albertel 459: my $expression='$external::datestatus="'.$status.'";';
1.89 albertel 460: $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.0.solved"}.'";';
1.1 albertel 461: &Apache::run::run($expression,$safeeval);
462: &Apache::lonxml::debug("Got $status");
1.25 albertel 463: $body_tag_start.=&add_previous_version_button($status);
1.54 albertel 464: if (!&show_task($status,$previous)) {
1.87 albertel 465: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
1.1 albertel 466: if ( $target eq "web" ) {
1.4 albertel 467: $result.= $head_tag_start.'</head>'.$body_tag_start;
1.74 albertel 468: if ($env{'request.state'} eq 'construct') {
469: $result.=$form_tag_start;
470: }
1.4 albertel 471: my $msg;
1.1 albertel 472: if ($status eq 'UNAVAILABLE') {
473: $msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>';
1.3 albertel 474: } elsif ($status eq 'NOT_IN_A_SLOT') {
475: $msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>';
1.38 albertel 476: $msg.=&add_request_another_attempt_button("Sign up for time to work.");
1.4 albertel 477: } elsif ($status eq 'NEEDS_CHECKIN') {
478: $msg.='<h1>'.&mt('You need the Proctor to validate you.').
479: '</h1>'.&proctor_validation_screen($slot);
1.22 albertel 480: } elsif ($status eq 'WAITING_FOR_GRADE') {
481: $msg.='<h1>'.&mt('Your submission is in the grading queue.').'</h1>';
1.64 albertel 482: } elsif ($env{'form.donescreen'}) {
483: my $title=&Apache::lonnet::gettitle();
1.67 albertel 484: my @files=split(',',$Apache::lonhomework::history{'resource.'.$version.'.0.bridgetask.portfiles'});
485: my $files='<ul><li>'.join('</li><li>',@files).'</li></ul>';
1.64 albertel 486: $result.=<<DONESCREEN;
487: <h2>$title</h2>
488: <p> Files submitted: $files </p>
1.67 albertel 489: <p> You are now done with this Bridge Task </p>
1.64 albertel 490: <hr />
491: <p> <a href="/adm/logout">Logout</a> </p>
492: <p> <a href="/adm/roles">Change to a different course</a> </p>
493: DONESCREEN
1.1 albertel 494: } elsif ($status ne 'NOT_YET_VIEWED') {
495: $msg.='<h1>'.&mt('Not open to be viewed').'</h1>';
496: }
497: if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
498: $msg.='The problem '.$accessmsg;
499: }
500: $result.=$msg.'<br />';
501: } elsif ($target eq 'tex') {
502: $result.='\begin{document}\noindent \vskip 1 mm \begin{minipage}{\textwidth}\vskip 0 mm';
503: if ($status eq 'UNAVAILABLE') {
504: $result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
505: } else {
506: $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
507: }
1.22 albertel 508: } elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
1.4 albertel 509: if ($status eq 'NEEDS_CHECKIN') {
1.83 albertel 510: if(&proctor_check_auth($slot_name,$slot,'Task')
511: && defined($Apache::inputtags::slot_name)) {
1.77 albertel 512: my $result=&add_to_queue('gradingqueue',
1.82 albertel 513: [$Apache::inputtags::slot_name]);
1.77 albertel 514: &Apache::lonxml::debug("add_to_queue said $result");
515: }
1.4 albertel 516: }
1.1 albertel 517: }
518: } elsif ($target eq 'web') {
519: my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
520: $result.="$head_tag_start<title>$name</title></head>
1.53 albertel 521: $body_tag_start \n".&style();
1.36 albertel 522:
1.57 albertel 523: $result.=&preserve_grade_info();
524: $result.=&internal_location();
1.36 albertel 525: $result.=$form_tag_start.
526: '<input type="hidden" name="submitted" value="yes" />';
1.54 albertel 527: &Apache::lonxml::startredirection();
1.1 albertel 528: }
1.21 albertel 529: } elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
530: $target eq 'webgrade') {
1.32 albertel 531: my $webgrade='yes';
1.21 albertel 532: if ($target eq 'webgrade') {
1.110 albertel 533: $result.=$head_tag_start.'</head>'.$body_tag_start;
1.49 albertel 534: #$result.='<br />Review'.&show_queue('reviewqueue');
535: #$result.='<br />Grade'.&show_queue('gradingqueue');
1.30 albertel 536: }
1.33 albertel 537: # FIXME Blast! still need to reorg this, need to reshow the
538: # queue being reviewed once done with the grade pass...
539: # Hrrm, vaildation pass should perhaps say 'not_locked'
540: # perhaps do a search if there is a key that is mine and if
541: # there isn't reshow the queue....
1.105 albertel 542: my ($todo,$status_code,$msg)=&get_key_todo($target);
1.33 albertel 543:
544: if ($todo) {
545: &setup_env_for_other_user($todo,$safeeval);
546: my ($symb,$uname,$udom)=&decode_queue_key($todo);
547: $result.="\n".'<table><tr><td>Found '.
548: &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'</td></tr></table>';
549: $form_tag_start.=
550: '<input type="hidden" name="gradingkey" value="'.
551: &Apache::lonnet::escape($todo).'" />';
552: $Apache::bridgetask::queue_key=$todo;
553: &Apache::structuretags::initialize_storage();
554: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
1.110 albertel 555: if ($target eq 'webgrade' && $status_code eq 'selected') {
556: $form_tag_start.=
557: '<input type="hidden" name="queuemode" value="selected" />';
1.33 albertel 558: }
1.15 albertel 559: } else {
1.33 albertel 560: if ($target eq 'webgrade') {
561: $result.="\n";
1.81 albertel 562: my $back='<p><a href="/adm/flip?postdata=return:">'.
563: &mt('Return to resource').'</a></p>';
1.33 albertel 564: if ($status_code eq 'stop') {
1.81 albertel 565: $result.='<b>'.&mt("Stopped grading.").'</b>'.$back;
1.33 albertel 566: } elsif ($status_code eq 'lock_failed') {
1.105 albertel 567: $result.='<b>'.&mt("Failed to lock the requested record.")
1.81 albertel 568: .'</b>'.$back;
1.33 albertel 569: } elsif ($status_code eq 'unlock') {
1.81 albertel 570: $result.='<b>'.&mt("Unlocked the requested record.")
571: .'</b>'.$back;
1.33 albertel 572: $result.=&show_queue($env{'form.queue'},1);
573: } elsif ($status_code eq 'show_list') {
574: $result.=&show_queue($env{'form.queue'},1);
1.49 albertel 575: } elsif ($status_code eq 'select_user') {
576: $result.=&select_user();
1.95 albertel 577: } elsif ($status_code eq 'unable') {
578: $result.='<b>'.&mt("Unable to aqcuire a user to grade.").'</b>'.$back;
1.105 albertel 579: } elsif ($status_code eq 'not_allowed') {
580: $result.='<b>'.&mt('Not allowed to grade the requested user.').' '.$msg.'</b>'.$back;
1.33 albertel 581: } else {
1.81 albertel 582: $result.='<b>'.&mt("No user to be graded.").'</b>'.$back;
1.32 albertel 583: }
1.21 albertel 584: }
1.33 albertel 585: $webgrade='no';
1.87 albertel 586: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
1.32 albertel 587: }
588: if ($target eq 'webgrade' && defined($env{'form.queue'})) {
1.61 albertel 589: if ($webgrade eq 'yes') {
590: $result.=&submission_time_stamp();
591: }
1.32 albertel 592: $result.=$form_tag_start;
593: $result.='<input type="hidden" name="webgrade" value="'.
594: $webgrade.'" />';
595: $result.='<input type="hidden" name="queue" value="'.
596: $env{'form.queue'}.'" />';
1.52 albertel 597: if ($env{'form.regrade'}) {
598: $result.='<input type="hidden" name="regrade" value="'.
599: $env{'form.regrade'}.'" />';
600: }
1.62 albertel 601: if ($env{'form.chosensections'}) {
602: my @chosen_sections=
603: &Apache::loncommon::get_env_multiple('form.chosensections');
604: foreach my $sec (@chosen_sections) {
605: $result.='<input type="hidden" name="chosensections"
606: value="'.$sec.'" />';
607: }
608: }
1.70 albertel 609: if ($webgrade eq 'yes') { $result.=&webgrade_standard_info(); }
1.15 albertel 610: }
1.110 albertel 611: if ($target eq 'webgrade') {
1.111 ! albertel 612: $result.="\n".'<div id="criterialist">';
1.110 albertel 613: }
1.74 albertel 614: } elsif ($target eq 'edit') {
615: $result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.
616: &Apache::structuretags::problem_edit_header();
617: $Apache::lonxml::warnings_error_header=
618: &mt("Editor Errors - these errors might not effect the running of the problem, but they will likely cause problems with further use of the Edit mode. Please use the EditXML mode to fix these errors.")."<br />";
619: my $temp=&Apache::edit::insertlist($target,$token);
620: $result.=$temp;
1.1 albertel 621: } else {
622: # page_start returned a starting result, delete it if we don't need it
623: $result = '';
624: }
625: return $result;
626: }
627:
1.32 albertel 628: sub get_key_todo {
629: my ($target)=@_;
630: my $todo;
1.33 albertel 631:
632: if (defined($env{'form.reviewasubmission'})) {
1.54 albertel 633: &Apache::lonxml::debug("review a submission....");
1.33 albertel 634: $env{'form.queue'}='reviewqueue';
635: return (undef,'show_list');
636: }
637:
638: if (defined($env{'form.reviewagrading'})) {
639: &Apache::lonxml::debug("review a grading....");
640: $env{'form.queue'}='gradingqueue';
641: return (undef,'show_list');
642: }
643:
1.49 albertel 644: if (defined($env{'form.regradeasubmission'})) {
645: &Apache::lonxml::debug("regrade a grading....");
646: $env{'form.queue'}='none';
647: return (undef,'select_user');
648: }
649:
1.105 albertel 650:
651: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
652:
653: #need to try both queues..
654: if (defined($env{'form.regradeaspecificsubmission'}) &&
655: defined($env{'form.gradinguser'}) &&
656: defined($env{'form.gradingdomain'}) ) {
657: my ($symb,$cid)=&Apache::lonxml::whichuser();
658: my $cnum = $env{'course.'.$cid.'.num'};
659: my $cdom = $env{'course.'.$cid.'.domain'};
660: my $uname = $env{'form.gradinguser'};
661: my $udom = $env{'form.gradingdomain'};
662:
663: my $gradingkey=&encode_queue_key($symb,$udom,$uname);
664:
665: my $queue;
666:
667: if (&in_queue('gradingqueue',$symb,$cdom,$cnum,$udom,$uname)) {
668: $env{'form.queue'} = $queue = 'gradingqueue';
669: } elsif (&in_queue('reviewqueue' ,$symb,$cdom,$cnum,$udom,$uname)) {
670: $env{'form.queue'} = $queue = 'reviewqueue';
671: }
672:
673: if (!$queue) {
674: $env{'form.queue'} = $queue = 'none';
675: #not queued so doing either a re or pre grade
676: return ($gradingkey);
677: }
678:
679: my $who=&queue_key_locked($queue,$gradingkey);
680: if ($who eq $me) {
681: #already have the lock
682: $env{'form.gradingkey'}=&Apache::lonnet::escape($gradingkey);
683: return ($gradingkey);
684: }
685:
686: if (!defined($who)) {
687: if (&lock_key($queue,$gradingkey)) {
688: return ($gradingkey);
689: } else {
690: return (undef,'lock_failed');
691: }
692: }
693:
694: #otherwise (defined($who) && $who ne $me) some else has it...
695: return (undef,'not_allowed',
696: &mt('Another user ([_1]) currently has the record for [_2] locked.',
697: $who,$env{'form.gradinguser'}.'@'.$env{'form.gradingdomain'}));
698: }
699:
700:
1.32 albertel 701: my $queue=$env{'form.queue'};
1.33 albertel 702:
1.32 albertel 703: if (!defined($queue)) {
704: $env{'form.queue'}=$queue='gradingqueue';
705: }
1.33 albertel 706:
1.32 albertel 707: my $gradingkey=&Apache::lonnet::unescape($env{'form.gradingkey'});
1.33 albertel 708:
1.49 albertel 709: if ($env{'form.queue'} eq 'none') {
710: if (defined($env{'form.gradingkey'})) {
711: if ($target eq 'webgrade') {
712: if ($env{'form.stop'}) {
713: return (undef,'stop');
714: } elsif ($env{'form.next'}) {
1.59 albertel 715: return (undef,'select_user');
1.49 albertel 716: }
717: }
718: return ($gradingkey,'selected');
719: } else {
1.59 albertel 720: return (undef,'select_user');
1.49 albertel 721: }
722: }
1.32 albertel 723: if (defined($env{'form.queue'}) && defined($env{'form.gradingkey'})
1.33 albertel 724: && !defined($env{'form.gradingaction'})
725: && $env{'form.queuemode'} eq 'selected') {
726:
727: my $who=&queue_key_locked($queue,$gradingkey);
728: if ($who eq $me) {
729: &Apache::lonxml::debug("Found a key was given to me");
730: return ($gradingkey,'selected');
731: } else {
732: return (undef,'show_list');
733: }
734:
735: }
736:
737: if ($target eq 'webgrade' && $env{'form.queuemode'} eq 'selected') {
738: if ($env{'form.gradingaction'} eq 'resume') {
739: delete($env{'form.gradingaction'});
740: &Apache::lonxml::debug("Resuming a key");
1.32 albertel 741: return ($gradingkey);
1.33 albertel 742: } elsif ($env{'form.gradingaction'} eq 'unlock') {
743: &Apache::lonxml::debug("Unlocking a key ".
744: &check_queue_unlock($queue,$gradingkey,1));
745: return (undef,'unlock');
746: } elsif ($env{'form.gradingaction'} eq 'select') {
747: &Apache::lonxml::debug("Locking a key");
748: if (&lock_key($queue,$gradingkey)) {
749: &Apache::lonxml::debug("Success $queue");
750: return ($gradingkey);
751: }
752: &Apache::lonxml::debug("Failed $queue");
753: return (undef,'lock_failed');
1.32 albertel 754: }
755: }
1.33 albertel 756:
757: if ($env{'form.queuemode'} ne 'selected') {
758: # don't get something new from the queue if they hit the stop button
759: if (!($env{'form.stop'} && $target eq 'webgrade')
760: && !$env{'form.gradingaction'}) {
761: &Apache::lonxml::debug("Getting anew $queue");
762: return (&get_from_queue($queue));
763: } else {
764: return (undef,'stop');
765: }
1.32 albertel 766: }
1.33 albertel 767: return (undef,undef)
1.32 albertel 768: }
1.94 albertel 769:
770: sub minimize_storage {
771: foreach my $key (keys(%Apache::lonhomework::results)) {
772: if ($key =~ /regrader$/) { next; }
773: if ($Apache::lonhomework::results{$key} eq
774: $Apache::lonhomework::history{$key}) {
775: delete($Apache::lonhomework::results{$key});
776: }
777: }
778: }
779:
1.1 albertel 780: sub end_Task {
781: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
782: my $result='';
783: my $status=$Apache::inputtags::status['-1'];
1.29 albertel 784: my ($version,$previous)=&get_version();
1.1 albertel 785: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
1.15 albertel 786: $target eq 'tex') {
1.69 albertel 787: if ($target eq 'web' || $target eq 'answer' || $target eq 'tex') {
1.1 albertel 788: if ($target eq 'web') {
1.54 albertel 789: if (&show_task($status,$previous)) {
790: $result.=&Apache::lonxml::endredirection();
791: }
1.64 albertel 792: if ($status eq 'CAN_ANSWER' && !$previous &&
793: !$env{'form.donescreen'}) {
1.15 albertel 794: $result.="\n".'<table border="1">'.
1.28 albertel 795: &Apache::inputtags::file_selector("$version.0",
796: "bridgetask","*",
1.46 albertel 797: 'portfolioonly',
798: '
799: <h2>'.&mt('Submit Portfolio Files for Grading').'</h2>
800: <p>'.&mt('Indicate the files from your portfolio to be evaluated in grading this task.').'</p>').
1.9 albertel 801: "</table>";
1.77 albertel 802: }
1.78 albertel 803: if (!$previous && $status ne 'SHOW_ANSWER' &&
804: &show_task($status,$previous)) {
1.9 albertel 805: $result.=&Apache::inputtags::gradestatus('0');
1.64 albertel 806: $result.='</form>';
807: $result.=<<DONEBUTTON;
808: <form method="POST">
809: <input type="hidden" name="donescreen" value="1" />
810: <input type="submit" value="Done" />
811: </form>
812: DONEBUTTON
1.77 albertel 813: }
1.56 albertel 814: if (&show_task($status,$previous) &&
1.89 albertel 815: $Apache::lonhomework::history{"resource.$version.0.status"} =~ /^(pass|fail)$/) {
816: my $bt_status=$Apache::lonhomework::history{"resource.$version.0.status"};
1.54 albertel 817: my $title=&Apache::lonnet::gettitle();
1.80 albertel 818:
819: my $slot_name=
1.89 albertel 820: $Apache::lonhomework::history{"resource.$version.0.checkedin.slot"};
1.80 albertel 821: my %slot=&Apache::lonnet::get_slot($slot_name);
1.55 albertel 822: my $start_time=
823: &Apache::lonlocal::locallocaltime($slot{'starttime'});
1.54 albertel 824:
1.80 albertel 825: my $status = "\n<div class='$bt_status'>\n";
1.54 albertel 826:
827: if ($bt_status eq 'pass') {
828: $status.='<h2>You passed the '.$title.' given on '.
1.80 albertel 829: $start_time.'</h2>';
1.54 albertel 830: }
831: if ($bt_status eq 'fail') {
832: $status.='<h2>You did not pass the '.$title.' given on '.
1.80 albertel 833: $start_time.'</h2>';
1.54 albertel 834: if (!$previous) {
835: $status.=&add_request_another_attempt_button();
836: }
837: }
838: my $man_count=0;
839: my $opt_count=0;
840: my $opt_passed=0;
841: foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
842: if ($Apache::bridgetask::dimensionmandatory{$dim_id}
843: eq 'N') {
844: $opt_count++;
1.89 albertel 845: if ($Apache::lonhomework::history{"resource.$version.0.$dim_id.status"} eq 'pass') {
1.54 albertel 846: $opt_passed++;
847: }
848: } else {
849: $man_count++;
850: }
851: }
852: my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
853: $parstack,$safeeval);
854: if ($opt_req !~ /\S/) { $opt_req='0'; }
1.99 albertel 855: $status.="\n<p>".&mt('You needed to pass all of the [_1] mandatory components and [_2] of the [_3] optional components, of which you passed [_4].',$man_count,$opt_req,$opt_count,$opt_passed)."</p></div>\n";
1.54 albertel 856:
857: my $internal_location=&internal_location();
858: $result=~s/\Q$internal_location\E/$status/;
859: }
1.13 albertel 860: }
861: if ($target eq 'web' || $target eq 'webgrade') {
1.1 albertel 862: $result.=&Apache::lonxml::xmlend().'</html>';
863: }
864: }
1.29 albertel 865: if ($target eq 'grade' && !$env{'form.webgrade'} && !$previous) {
1.12 albertel 866: my $award='SUBMITTED';
1.28 albertel 867: &Apache::essayresponse::file_submission("$version.0",'bridgetask',
1.20 albertel 868: 'portfiles',\$award);
1.14 albertel 869: if ($award eq 'SUBMITTED' &&
1.28 albertel 870: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}) {
871: $Apache::lonhomework::results{"resource.0.tries"}=
872: $Apache::lonhomework::results{"resource.$version.0.tries"}=
873: 1+$Apache::lonhomework::history{"resource.$version.0.tries"};
874:
875: $Apache::lonhomework::results{"resource.0.award"}=
876: $Apache::lonhomework::results{"resource.$version.0.award"}=
877: $award;
1.51 albertel 878: $Apache::lonhomework::results{"resource.0.submission"}=
879: $Apache::lonhomework::results{"resource.$version.0.submission"}='';
1.64 albertel 880: } else {
881: delete($Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"});
1.77 albertel 882: $award = '';
1.10 albertel 883: }
1.4 albertel 884: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
885: &Apache::structuretags::finalize_storage();
1.83 albertel 886: if ($award eq 'SUBMITTED'
887: && defined($Apache::inputtags::slot_name)) {
1.82 albertel 888: &add_to_queue('gradingqueue',[$Apache::inputtags::slot_name]);
1.14 albertel 889: }
1.79 albertel 890: } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
891: &Apache::structuretags::finalize_storage();
1.1 albertel 892: }
1.32 albertel 893: if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
1.20 albertel 894: my $optional_required=
895: &Apache::lonxml::get_param('OptionalRequired',$parstack,
896: $safeeval);
897: my $optional_passed=0;
898: my $mandatory_failed=0;
899: my $ungraded=0;
900: my $review=0;
1.21 albertel 901: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
1.20 albertel 902: foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
903: my $status=
1.89 albertel 904: $Apache::lonhomework::results{"resource.$version.0.$dim_id.status"};
1.20 albertel 905: my $mandatory=
906: ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
907: if ($status eq 'pass') {
908: if (!$mandatory) { $optional_passed++; }
909: } elsif ($status eq 'fail') {
910: if ($mandatory) { $mandatory_failed++; }
911: } elsif ($status eq 'ungraded') {
912: $ungraded++;
913: } elsif ($status eq 'review') {
914: $review++;
1.49 albertel 915: } else {
916: $ungraded++;
917: }
1.20 albertel 918: }
919: if ($optional_passed < $optional_required) {
920: $mandatory_failed++;
921: }
1.21 albertel 922: &Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
1.89 albertel 923: $Apache::lonhomework::results{'resource.0.regrader'}=
1.20 albertel 924: $env{'user.name'}.'@'.$env{'user.domain'};
925: if ($review) {
1.89 albertel 926: $Apache::lonhomework::results{"resource.$version.0.status"}='review';
1.33 albertel 927: if ($env{'form.queue'} eq 'reviewqueue') {
928: &check_queue_unlock($env{'form.queue'});
929: &Apache::lonxml::debug(" still needs review not changing status.");
930: } else {
1.49 albertel 931: &move_between_queues($env{'form.queue'},'reviewqueue');
1.33 albertel 932: }
1.20 albertel 933: } elsif ($ungraded) {
1.89 albertel 934: $Apache::lonhomework::results{"resource.$version.0.status"}='ungraded';
1.49 albertel 935: if ($env{'form.queue'} eq 'reviewqueue' ||
936: $env{'form.queue'} eq 'none' ) {
1.33 albertel 937: &Apache::lonxml::debug("moving back.");
1.49 albertel 938: &move_between_queues($env{'form.queue'},'gradingqueue');
1.33 albertel 939: } else {
940: &check_queue_unlock($env{'form.queue'});
941: }
1.20 albertel 942: } elsif ($mandatory_failed) {
1.89 albertel 943: $Apache::lonhomework::results{"resource.$version.0.status"}='fail';
1.25 albertel 944: $Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
945: $Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
946: $Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
1.39 albertel 947: &remove_from_queue($env{'form.queue'});
948:
949: my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
1.52 albertel 950:
951: if ($env{'form.regrade'} ne 'yes') {
952: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
953: $Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
954: &Apache::grades::version_portfiles(
955: \%Apache::lonhomework::results,
956: ["$version.0.bridgetask"],$courseid,
957: $symb,$udom,$uname,
958: ["$version.0.bridgetask"]);
959: }
1.20 albertel 960: } else {
1.89 albertel 961: $Apache::lonhomework::results{"resource.$version.0.status"}='pass';
1.25 albertel 962: $Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
963: $Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
964: $Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
1.32 albertel 965: &remove_from_queue($env{'form.queue'});
1.39 albertel 966:
967: my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
1.52 albertel 968: if ($env{'form.regrade'} ne 'yes') {
969: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
970: $Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
971: &Apache::grades::version_portfiles(
972: \%Apache::lonhomework::results,
973: ["$version.0.bridgetask"],$courseid,
974: $symb,$udom,$uname,
975: ["$version.0.bridgetask"]);
976: }
1.20 albertel 977: }
1.89 albertel 978: $Apache::lonhomework::results{"resource.0.status"}=
979: $Apache::lonhomework::results{"resource.$version.0.status"};
1.28 albertel 980: if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) {
1.26 albertel 981: $Apache::lonhomework::results{"resource.0.award"}=
1.50 albertel 982: $Apache::lonhomework::results{"resource.$version.0.award"};
1.26 albertel 983: $Apache::lonhomework::results{"resource.0.awarded"}=
1.50 albertel 984: $Apache::lonhomework::results{"resource.$version.0.awarded"};
1.26 albertel 985: $Apache::lonhomework::results{"resource.0.solved"}=
1.50 albertel 986: $Apache::lonhomework::results{"resource.$version.0.solved"};
1.25 albertel 987: }
1.94 albertel 988: &minimize_storage();
1.21 albertel 989: &Apache::structuretags::finalize_storage();
1.20 albertel 990: }
1.15 albertel 991: } elsif ($target eq 'webgrade') {
1.111 ! albertel 992: $result.="</div>\n<hr />";
1.20 albertel 993: #$result.='<input type="submit" name="next" value="'.
994: # &mt('Save & Next').'" /> ';
995: #$result.='<input type="submit" name="end" value="'.
996: # &mt('Save & Stop Grading').'" /> ';
997: #$result.='<input type="submit" name="throwaway" value="'.
998: # &mt('Throw Away & Stop Grading').'" /> ';
999: #$result.='<input type="submit" name="save" value="'.
1000: # &mt('Save Partial Grade and Continue Grading').'" /> ';
1.15 albertel 1001: $result.='</form>'.&Apache::loncommon::endbodytag().'</html>';
1.1 albertel 1002: } elsif ($target eq 'meta') {
1.70 albertel 1003: $result.=&Apache::response::meta_package_write('Task');
1.77 albertel 1004: $result.=&Apache::response::meta_stores_write('solved','string',
1005: 'Problem Status');
1006: $result.=&Apache::response::meta_stores_write('tries','int_zeropos',
1007: 'Number of Attempts');
1008: $result.=&Apache::response::meta_stores_write('awarded','float',
1009: 'Partial Credit Factor');
1010: $result.=&Apache::response::meta_stores_write('status','string',
1011: 'Bridge Task Status');
1.1 albertel 1012: }
1.4 albertel 1013: undef($Apache::lonhomework::parsing_a_task);
1.1 albertel 1014: return $result;
1015: }
1016:
1.31 albertel 1017: sub move_between_queues {
1018: my ($src_queue,$dest_queue)=@_;
1.49 albertel 1019: my $cur_data;
1020: if ($src_queue ne 'none') {
1021: $cur_data=&get_queue_data($src_queue);
1022: if (!$cur_data) { return 'not_exist'; }
1023: } else {
1024: $cur_data = ['none'];
1025: }
1.82 albertel 1026: my $result=&add_to_queue($dest_queue,[$cur_data->[0]]);
1.31 albertel 1027: if ($result ne 'ok') {
1028: return $result;
1029: }
1030: &check_queue_unlock($src_queue);
1031: return &remove_from_queue($src_queue);
1.21 albertel 1032: }
1033:
1034: sub check_queue_unlock {
1.32 albertel 1035: my ($queue,$key,$allow_not_me)=@_;
1.49 albertel 1036: if ($queue eq 'none') { return 'ok'; }
1.30 albertel 1037: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1.32 albertel 1038: if (!defined($key)) {
1039: $key="$symb\0queue\0$uname\@$udom";
1040: }
1.30 albertel 1041: my $cnum=$env{'course.'.$cid.'.num'};
1042: my $cdom=$env{'course.'.$cid.'.domain'};
1043: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1044: my $who=&queue_key_locked($queue,$key,$cdom,$cnum);
1045: if ($who eq $me) {
1.32 albertel 1046: return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
1047: } elsif ($allow_not_me) {
1.33 albertel 1048: &Apache::lonxml::debug("unlocking $who by $me");
1.32 albertel 1049: return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
1.30 albertel 1050: }
1.32 albertel 1051: return 'not_owner';
1.21 albertel 1052: }
1053:
1.88 albertel 1054: sub in_queue {
1055: my ($queue,$symb,$cdom,$cnum,$udom,$uname)=@_;
1056: if ($queue eq 'none') { return 0; }
1057: if (!defined($symb) || !defined($cdom) || !defined($cnum)
1058: || !defined($udom) || !defined($uname)) {
1059: ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser();
1060: $cnum=$env{'course.'.$cid.'.num'};
1061: $cdom=$env{'course.'.$cid.'.domain'};
1062: }
1063:
1064: my $key=&encode_queue_key($symb,$udom,$uname);
1065: my %results = &Apache::lonnet::get($queue,[$key],$cdom,$cnum);
1066:
1067: if (defined($results{$key})) {
1068: return 1;
1069: }
1070: return 0;
1071: }
1072:
1.21 albertel 1073: sub remove_from_queue {
1.86 albertel 1074: my ($queue,$symb,$cdom,$cnum,$udom,$uname)=@_;
1.49 albertel 1075: if ($queue eq 'none') { return 'ok'; }
1.86 albertel 1076: if (!defined($symb) || !defined($cdom) || !defined($cnum)
1077: || !defined($udom) || !defined($uname)) {
1078: ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser();
1079: $cnum=$env{'course.'.$cid.'.num'};
1080: $cdom=$env{'course.'.$cid.'.domain'};
1081: }
1.88 albertel 1082: if (!&in_queue($queue,$symb,$cdom,$cnum,$udom,$uname)) {
1083: return 'ok';
1084: }
1.86 albertel 1085: my $key=&encode_queue_key($symb,$udom,$uname);
1.27 albertel 1086: my @keys=($key,"$key\0locked");
1.31 albertel 1087: return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
1.21 albertel 1088: }
1089:
1.16 albertel 1090: sub setup_env_for_other_user {
1091: my ($queue_key,$safeeval)=@_;
1092: my ($symb,$uname,$udom)=&decode_queue_key($queue_key);
1.30 albertel 1093: &Apache::lonxml::debug("setup_env for $queue_key");
1.16 albertel 1094: $env{'form.grade_symb'}=$symb;
1095: $env{'form.grade_domain'}=$udom;
1096: $env{'form.grade_username'}=$uname;
1097: $env{'form.grade_courseid'}=$env{'request.course.id'};
1098: &Apache::lonxml::initialize_rndseed($safeeval);
1099: }
1100:
1.31 albertel 1101: sub get_queue_data {
1102: my ($queue)=@_;
1103: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1104: my $cnum=$env{'course.'.$cid.'.num'};
1105: my $cdom=$env{'course.'.$cid.'.domain'};
1106: my $todo="$symb\0queue\0$uname\@$udom";
1107: my ($key,$value)=&Apache::lonnet::get($queue,[$todo],$cdom,$cnum);
1108: if ($key eq $todo && ref($value)) {
1109: return $value;
1110: }
1111: return undef;
1112: }
1113:
1.84 albertel 1114:
1.49 albertel 1115: sub check_queue_for_key {
1.84 albertel 1116: my ($cdom,$cnum,$queue,$todo)=@_;
1117:
1.49 albertel 1118: my %results=
1119: &Apache::lonnet::get($queue,[$todo,"$todo\0locked"],$cdom,$cnum);
1120:
1121: if (exists($results{$todo}) && ref($results{$todo})) {
1122: if (defined($results{"$todo\0locked"})) {
1123: return 'locked';
1124: }
1.86 albertel 1125: my $slot;
1126: if (ref($results{$todo}) eq 'ARRAY') {
1127: $slot = $results{$todo}[0];
1128: } elsif (ref($results{$todo}) eq 'HASH') {
1129: $slot = $results{$todo}{'slot'};
1130: }
1131: if (defined($slot)) {
1132: my %slot_data=&Apache::lonnet::get_slot($slot);
1133: if ($slot_data{'endtime'} > time) {
1134: return 'in_progress';
1135: }
1.58 albertel 1136: }
1.49 albertel 1137: return 'enqueued';
1138: }
1139: return undef;
1140: }
1141:
1.14 albertel 1142: sub add_to_queue {
1.82 albertel 1143: my ($queue,$user_data)=@_;
1.49 albertel 1144: if ($queue eq 'none') { return 'ok'; }
1.14 albertel 1145: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1.82 albertel 1146: if (!$cid || $env{'request.state'} eq 'construct') {
1147: return 'no_queue';
1148: }
1.14 albertel 1149: my $cnum=$env{'course.'.$cid.'.num'};
1150: my $cdom=$env{'course.'.$cid.'.domain'};
1151: my %data;
1.82 albertel 1152: $data{"$symb\0queue\0$uname\@$udom"}=$user_data;
1.83 albertel 1153: return &Apache::lonnet::cput($queue,\%data,$cdom,$cnum);
1.14 albertel 1154: }
1155:
1156: sub show_queue {
1.32 albertel 1157: my ($queue,$with_selects)=@_;
1.14 albertel 1158: my $result;
1159: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1160: my $cnum=$env{'course.'.$cid.'.num'};
1161: my $cdom=$env{'course.'.$cid.'.domain'};
1.59 albertel 1162:
1163: my @chosen_sections=
1164: &Apache::loncommon::get_env_multiple('form.chosensections');
1165: &Apache::grades::init_perm();
1166: my ($classlist,$section,$fullname)=&Apache::grades::getclasslist(\@chosen_sections,);
1167: &Apache::grades::reset_perm();
1.63 albertel 1168: if (!(grep(/^all$/,@chosen_sections))) {
1169: $result.='<p> Showing only sections <tt>'.join(', ',@chosen_sections).
1170: '</tt>.</p> '."\n";
1171: }
1.59 albertel 1172:
1.16 albertel 1173: my $regexp="^$symb\0";
1.30 albertel 1174: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.31 albertel 1175: my ($tmp)=%queue;
1176: if ($tmp=~/^error: 2 /) {
1.33 albertel 1177: return "\n<h3>Current Queue - $queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
1.31 albertel 1178: }
1.103 albertel 1179: my $title=&Apache::lonnet::gettitle($symb);
1180: $result.="\n<h3>Current Queue - $title $queue </h3><table border='1'><tr>";
1181: if ($with_selects) { $result.="<th>Status</th><th></th>"; }
1182: $result.="<th>user</th><th>data</th></tr>";
1.14 albertel 1183: foreach my $key (sort(keys(%queue))) {
1.59 albertel 1184: my ($symb,$uname,$udom) = &decode_queue_key($key);
1185: if (!defined($classlist->{$uname.':'.$udom})) { next; }
1.32 albertel 1186: if ($key=~/locked$/ && !$with_selects) {
1.103 albertel 1187: $result.="<tr><td>$uname</td>";
1188: $result.='<td>'.$queue{$key}.'</td></tr>';
1.32 albertel 1189: } elsif ($key=~/timestamp$/ && !$with_selects) {
1.103 albertel 1190: $result.="<tr><td></td>";
1191: $result.='<td>'.
1.16 albertel 1192: &Apache::lonlocal::locallocaltime($queue{$key})."</td></tr>";
1.32 albertel 1193: } elsif ($key!~/(timestamp|locked)$/) {
1194: $result.="<tr>";
1.35 albertel 1195: my $slot=$queue{$key}->[0];
1196: my %slot_data=&Apache::lonnet::get_slot($slot);
1.32 albertel 1197: if ($with_selects) {
1198: my $ekey=&Apache::lonnet::escape($key);
1.103 albertel 1199: my ($action,$description,$status)=('select',&mt('Select'));
1.32 albertel 1200: if (exists($queue{"$key\0locked"})) {
1201: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1.103 albertel 1202: $status=&mt('Locked by <tt>[_1]</tt>',$queue{"$key\0locked"});
1.32 albertel 1203: if ($me eq $queue{"$key\0locked"}) {
1204: ($action,$description)=('resume',&mt('Resume'));
1205: } else {
1206: ($action,$description)=('unlock',&mt('Unlock'));
1207: }
1208: }
1.62 albertel 1209: my $seclist;
1210: foreach my $sec (@chosen_sections) {
1211: $seclist.='<input type="hidden" name="chosensections"
1212: value="'.$sec.'" />';
1213: }
1.35 albertel 1214: if (time > $slot_data{'endtime'}) {
1215: $result.=(<<FORM);
1.103 albertel 1216: <td>$status</td>
1.32 albertel 1217: <td>
1.103 albertel 1218: <form style="display: inline" method="POST">
1.32 albertel 1219: <input type="hidden" name="gradingkey" value="$ekey" />
1220: <input type="hidden" name="queue" value="$queue" />
1221: <input type="hidden" name="gradingaction" value="$action" />
1222: <input type="hidden" name="webgrade" value="no" />
1.33 albertel 1223: <input type="hidden" name="queuemode" value="selected" />
1.32 albertel 1224: <input type="submit" name="submit" value="$description" />
1.62 albertel 1225: $seclist
1.32 albertel 1226: </form>
1227: </td>
1228: FORM
1.35 albertel 1229:
1230: } else {
1231: $result.='<td>'.&mt("In Progress").'</td>'
1232: }
1.32 albertel 1233: }
1.104 albertel 1234: $result.= "<td>".$fullname->{$uname.':'.$udom}.
1235: " <tt>($uname\@$udom)</tt> </td>";
1.103 albertel 1236: $result.='<td>Slot: '.$slot.' End time: '.
1.20 albertel 1237: &Apache::lonlocal::locallocaltime($slot_data{'endtime'}).
1238: "</td></tr>";
1.16 albertel 1239: }
1.14 albertel 1240: }
1.15 albertel 1241: $result.="</table><hr />\n";
1.14 albertel 1242: return $result;
1243: }
1244:
1.34 albertel 1245: sub get_queue_counts {
1246: my ($queue)=@_;
1247: my $result;
1248: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1249: my $cnum=$env{'course.'.$cid.'.num'};
1250: my $cdom=$env{'course.'.$cid.'.domain'};
1251: my $regexp="^$symb\0";
1252: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1253: my ($tmp)=%queue;
1254: if ($tmp=~/^error: 2 /) {
1255: return (0,0,0);
1256: }
1257: my ($entries,$ready_to_grade,$locks)=(0,0,0);
1.96 albertel 1258: my %slot_cache;
1.34 albertel 1259: foreach my $key (sort(keys(%queue))) {
1260: if ($key=~/locked$/) {
1261: $locks++;
1262: } elsif ($key=~/timestamp$/) {
1263: #ignore
1264: } elsif ($key!~/(timestamp|locked)$/) {
1265: my ($symb,$uname,$udom) = &decode_queue_key($key);
1266: $entries++;
1267: my $slot=$queue{$key}->[0];
1.96 albertel 1268: if (!exists($slot_cache{$slot})) {
1269: my %slot_data=&Apache::lonnet::get_slot($slot);
1270: $slot_cache{$slot} = \%slot_data;
1271: }
1272: if (time > $slot_cache{$slot}{'endtime'}) {
1.34 albertel 1273: $ready_to_grade++;
1274: }
1275: }
1276: }
1277: return ($entries,$ready_to_grade,$locks);
1278: }
1279:
1.49 albertel 1280: sub encode_queue_key {
1281: my ($symb,$udom,$uname)=@_;
1282: return "$symb\0queue\0$uname\@$udom";
1283: }
1284:
1.14 albertel 1285: sub decode_queue_key {
1286: my ($key)=@_;
1287: my ($symb,undef,$user) = split("\0",$key);
1288: my ($uname,$udom) = split('@',$user);
1289: return ($symb,$uname,$udom);
1290: }
1291:
1292: sub queue_key_locked {
1.30 albertel 1293: my ($queue,$key,$cdom,$cnum)=@_;
1.33 albertel 1294: if (!defined($cdom) || !defined($cnum)) {
1295: my (undef,$cid)=&Apache::lonxml::whichuser();
1296: $cnum=$env{'course.'.$cid.'.num'};
1297: $cdom=$env{'course.'.$cid.'.domain'};
1298: }
1.14 albertel 1299: my ($key_locked,$value)=
1.30 albertel 1300: &Apache::lonnet::get($queue,["$key\0locked"],$cdom,$cnum);
1.14 albertel 1301: if ($key_locked eq "$key\0locked") {
1302: return $value;
1303: }
1304: return undef;
1305: }
1306:
1307: sub pick_from_queue_data {
1.30 albertel 1308: my ($queue,$check_section,$queuedata,$cdom,$cnum)=@_;
1.98 albertel 1309: my @possible; # will hold queue entries that are valid to be selected
1.30 albertel 1310: foreach my $key (keys(%$queuedata)) {
1.68 albertel 1311: if ($key =~ /\0locked$/) { next; }
1312: if ($key =~ /\0timestamp$/) { next; }
1.14 albertel 1313: my ($symb,$uname,$udom)=&decode_queue_key($key);
1314: if ($check_section) {
1315: my $section=&Apache::lonnet::getsection($uname,$udom);
1.17 albertel 1316: if ($section eq $check_section) {
1.33 albertel 1317: &Apache::lonxml::debug("my sec");
1.15 albertel 1318: next;
1319: }
1.14 albertel 1320: }
1.30 albertel 1321: my $slot=$queuedata->{$key}[0];
1.14 albertel 1322: my %slot_data=&Apache::lonnet::get_slot($slot);
1.15 albertel 1323: if ($slot_data{'endtime'} > time) {
1.33 albertel 1324: &Apache::lonxml::debug("not time");
1.15 albertel 1325: next;
1326: }
1.98 albertel 1327: if (exists($queuedata->{"$key\0locked"})) {
1.33 albertel 1328: &Apache::lonxml::debug("someone already has um.");
1.15 albertel 1329: next;
1330: }
1.98 albertel 1331: push(@possible,[$key,$slot_data{'endtime'}]);
1332: }
1333: if (@possible) {
1334: # sort entries in order by slot end time
1335: @possible = sort { $a->[1] <=> $b->[1] } @possible;
1336: # pick one of the first ten entries
1337: my $max=($#possible < 10) ? $#possible : 10;
1338: return $possible[int(rand($max))][0];
1.14 albertel 1339: }
1340: return undef;
1341: }
1342:
1.15 albertel 1343: sub find_mid_grade {
1.30 albertel 1344: my ($queue,$symb,$cdom,$cnum)=@_;
1.16 albertel 1345: my $todo=&Apache::lonnet::unescape($env{'form.gradingkey'});
1.15 albertel 1346: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1347: if ($todo) {
1.30 albertel 1348: my $who=&queue_key_locked($queue,$todo,$cdom,$cnum);
1.15 albertel 1349: if ($who eq $me) { return $todo; }
1350: }
1351: my $regexp="^$symb\0.*\0locked\$";
1.30 albertel 1352: my %locks=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.15 albertel 1353: foreach my $key (keys(%locks)) {
1354: my $who=$locks{$key};
1355: if ($who eq $me) {
1356: $todo=$key;
1357: $todo=~s/\0locked$//;
1358: return $todo;
1359: }
1360: }
1361: return undef;
1362: }
1363:
1.32 albertel 1364: sub lock_key {
1365: my ($queue,$todo)=@_;
1366: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1367: my (undef,$cid)=&Apache::lonxml::whichuser();
1368: my $cnum=$env{'course.'.$cid.'.num'};
1369: my $cdom=$env{'course.'.$cid.'.domain'};
1370: my $success=&Apache::lonnet::newput($queue,{"$todo\0locked"=> $me},
1371: $cdom,$cnum);
1.33 albertel 1372: &Apache::lonxml::debug("success $success $todo");
1.32 albertel 1373: if ($success eq 'ok') {
1374: return 1;
1375: }
1376: return 0;
1377: }
1378:
1.86 albertel 1379: sub get_queue_symb_status {
1.85 albertel 1380: my ($queue,$symb,$cdom,$cnum) = @_;
1381: if (!defined($cdom) || !defined($cnum)) {
1382: my (undef,$cid)=&Apache::lonxml::whichuser();
1383: $cnum=$env{'course.'.$cid.'.num'};
1384: $cdom=$env{'course.'.$cid.'.domain'};
1385: }
1386: my $regexp="^$symb\0";
1387: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1388: my ($tmp)=%queue;
1389: if ($tmp=~/^error: 2 /) { return; }
1390: my @users;
1391: foreach my $key (sort(keys(%queue))) {
1392: next if ($key=~/locked$/);
1393: next if ($key=~/timestamp$/);
1394: my ($symb,$uname,$udom) = &decode_queue_key($key);
1395: push(@users,"$uname:$udom");
1396: }
1397: return @users;
1398: }
1399:
1.14 albertel 1400: sub get_from_queue {
1.30 albertel 1401: my ($queue)=@_;
1.14 albertel 1402: my $result;
1403: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1404: my $cnum=$env{'course.'.$cid.'.num'};
1405: my $cdom=$env{'course.'.$cid.'.domain'};
1.32 albertel 1406: my $todo=&find_mid_grade($queue,$symb,$cdom,$cnum);
1.33 albertel 1407: &Apache::lonxml::debug("found ".join(':',&decode_queue_key($todo)));
1.16 albertel 1408: if ($todo) { return $todo; }
1.95 albertel 1409: my $attempts=0;
1.14 albertel 1410: while (1) {
1.95 albertel 1411: if ($attempts > 2) {
1412: # tried twice to get a queue entry, giving up
1413: return (undef,'unable');
1414: }
1.14 albertel 1415: my $starttime=time;
1.83 albertel 1416: &Apache::lonnet::cput($queue,{"$symb\0timestamp"=>$starttime},
1417: $cdom,$cnum);
1.33 albertel 1418: &Apache::lonxml::debug("$starttime");
1.14 albertel 1419: my $regexp="^$symb\0queue\0";
1.97 albertel 1420: my $range= ($attempts < 1 ) ? '0-100' : '0-400';
1421:
1.98 albertel 1422: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.33 albertel 1423: #make a pass looking for a user _not_ in my section
1.14 albertel 1424: if ($env{'request.course.sec'}) {
1.33 albertel 1425: &Apache::lonxml::debug("sce");
1.30 albertel 1426: $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
1427: \%queue,$cdom,$cnum);
1.33 albertel 1428: &Apache::lonxml::debug("sce $todo");
1.14 albertel 1429: }
1.33 albertel 1430: # no one _not_ in our section so look for any user that is
1431: # ready for grading
1.14 albertel 1432: if (!$todo) {
1.33 albertel 1433: &Apache::lonxml::debug("no sce");
1.98 albertel 1434: $todo=&pick_from_queue_data($queue,undef,\%queue,$cdom,$cnum);
1.33 albertel 1435: &Apache::lonxml::debug("no sce $todo");
1.14 albertel 1436: }
1437: # no user to grade
1438: if (!$todo) { last; }
1.33 albertel 1439: &Apache::lonxml::debug("got $todo");
1.14 albertel 1440: # otherwise found someone so lets try to lock them
1.32 albertel 1441: # unless someone else already picked them
1.95 albertel 1442: if (!&lock_key($queue,$todo)) {
1443: $attempts++;
1444: next;
1445: }
1.14 albertel 1446: my (undef,$endtime)=
1.30 albertel 1447: &Apache::lonnet::get($queue,["$symb\0timestamp"],
1.14 albertel 1448: $cdom,$cnum);
1.33 albertel 1449: &Apache::lonxml::debug("emd $endtime");
1.14 albertel 1450: # someone else already modified the queue,
1451: # perhaps our picked user wass already fully graded between
1452: # when we picked him and when we locked his record? so lets
1453: # double check.
1454: if ($endtime != $starttime) {
1455: my ($key,$value)=
1.30 albertel 1456: &Apache::lonnet::get($queue,["$todo"],
1.14 albertel 1457: $cdom,$cnum);
1.33 albertel 1458: &Apache::lonxml::debug("check $key .. $value");
1.14 albertel 1459: if ($key eq $todo && ref($value)) {
1460: } else {
1.30 albertel 1461: &Apache::lonnet::del($queue,["$todo\0locked"],
1.14 albertel 1462: $cdom,$cnum);
1.33 albertel 1463: &Apache::lonxml::debug("del");
1.95 albertel 1464: $attempts++;
1.14 albertel 1465: next;
1466: }
1467: }
1.33 albertel 1468: &Apache::lonxml::debug("last $todo");
1.14 albertel 1469: last;
1470: }
1471: return $todo;
1472: }
1473:
1.49 albertel 1474: sub select_user {
1475: my ($symb,$cid)=&Apache::lonxml::whichuser();
1476:
1.59 albertel 1477: my @chosen_sections=
1478: &Apache::loncommon::get_env_multiple('form.chosensections');
1.49 albertel 1479: &Apache::grades::init_perm();
1.59 albertel 1480: my ($classlist,$section,$fullname)=&Apache::grades::getclasslist(\@chosen_sections,);
1.49 albertel 1481: &Apache::grades::reset_perm();
1.63 albertel 1482:
1483: my $result;
1484: if (!(grep(/^all$/,@chosen_sections))) {
1485: $result.='<p> Showing only sections <tt>'.join(', ',@chosen_sections).
1486: '</tt>.</p> '."\n";
1487: }
1488: $result.='<table border="1">';
1.49 albertel 1489:
1490: foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
1491: my ($uname,$udom) = split(/:/,$student);
1.59 albertel 1492:
1.84 albertel 1493: my $cnum=$env{'course.'.$cid.'.num'};
1494: my $cdom=$env{'course.'.$cid.'.domain'};
1.88 albertel 1495: my %status = &get_student_status($symb,$cdom,$cnum,$udom,$uname,
1496: 'Task');
1.49 albertel 1497: my $queue = 'none';
1.58 albertel 1498: my $cannot_grade;
1499: if ($status{'reviewqueue'} =~ /^(in_progress|enqueue)$/) {
1.49 albertel 1500: $queue = 'reviewqueue';
1.58 albertel 1501: if ($status{'reviewqueue'} eq 'in_progress') {
1502: $cannot_grade=1;
1503: }
1504: } elsif ($status{'gradingqueue'} =~ /^(in_progress|enqueue)$/) {
1.49 albertel 1505: $queue = 'gradingqueue';
1.58 albertel 1506: if ($status{'gradingqueue'} eq 'in_progress') {
1507: $cannot_grade=1;
1508: }
1.49 albertel 1509: }
1510: my $todo =
1511: &Apache::lonnet::escape(&encode_queue_key($symb,$udom,$uname));
1.58 albertel 1512: if ($cannot_grade) {
1513: $result.='<tr><td> </td><td>'.$fullname->{$student}.
1514: '</td><td>';
1515: } else {
1.62 albertel 1516: my $seclist;
1517: foreach my $sec (@chosen_sections) {
1518: $seclist.='<input type="hidden" name="chosensections"
1519: value="'.$sec.'" />';
1520: }
1.102 albertel 1521: my $studentdis = $student;
1522: $studentdis =~ tr/:/@/;
1.58 albertel 1523: $result.=<<RESULT;
1.49 albertel 1524: <tr>
1525: <td>
1.102 albertel 1526: <form style="display: inline" method="POST">
1.49 albertel 1527: <input type="hidden" name="gradingkey" value="$todo" />
1528: <input type="hidden" name="queue" value="$queue" />
1529: <input type="hidden" name="webgrade" value="no" />
1.52 albertel 1530: <input type="hidden" name="regrade" value="yes" />
1.62 albertel 1531: <input type="submit" name="submit" value="Regrade" />
1532: $seclist
1.49 albertel 1533: </form>
1.102 albertel 1534: <td>$fullname->{$student} <tt>($studentdis)</tt></td>
1.49 albertel 1535: <td>
1536: RESULT
1.58 albertel 1537: }
1.49 albertel 1538: if ($status{'status'} eq 'pass') {
1539: $result .= '<font color="green">'.&mt('Passed').'</font>';
1540: } elsif ($status{'status'} eq 'fail') {
1541: $result .= '<font color="red">'.&mt('Failed').'</font>';
1542: } elsif ($status{'status'} eq 'review') {
1543: $result .= '<font color="blue">'.&mt('Under Review').'</font>';
1544: } elsif ($status{'status'} eq 'ungraded') {
1545: $result .= &mt('Ungraded');
1546: } elsif ($status{'status'} ne '') {
1547: $result .= '<font color="orange">'.&mt('Unknown Status').'</font>';
1548: } else {
1549: $result.=" ";
1550: }
1551: if ($status{'version'}) {
1552: $result .= ' '.&mt('Version').' '.$status{'version'};
1553: }
1.101 albertel 1554: if ($status{'grader'}) {
1555: $result .= ' '.&mt('(Graded by [_1])',$status{'grader'}).' ';
1556: }
1.49 albertel 1557: $result.= '</td><td>';
1558: if ($status{'reviewqueue'} eq 'enqueued') {
1559: $result .= &mt('Awaiting Review');
1560: } elsif ($status{'reviewqueue'} eq 'locked') {
1561: $result .= &mt('Under Review');
1.58 albertel 1562: } elsif ($status{'reviewqueue'} eq 'in_progress') {
1563: $result .= &mt('Still being worked on.');
1.49 albertel 1564: } elsif ($status{'gradingqueue'} eq 'enqueued') {
1565: $result .= &mt('Awaiting Grading');
1566: } elsif ($status{'gradingqueue'} eq 'locked') {
1567: $result .= &mt('Being Graded');
1.58 albertel 1568: } elsif ($status{'gradingqueue'} eq 'in_progress') {
1569: $result .= &mt('Still being worked on.');
1.49 albertel 1570: } else {
1571: $result.=" ";
1572: }
1573: $result.= '</td></tr>';
1574: }
1575: $result.='</table>';
1576: return $result;
1577: }
1578:
1579: sub get_student_status {
1.86 albertel 1580: my ($symb,$cdom,$cnum,$udom,$uname,$type)=@_;
1581:
1582: my %status;
1583:
1584: if ($type eq 'Task') {
1585: my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
1.49 albertel 1586: $udom,$uname);
1.89 albertel 1587: $status{'status'}=$record{'resource.0.status'};
1588: $status{'version'}=$record{'resource.0.version'};
1589: $status{'grader'}=$record{'resource.0.regrader'};
1.86 albertel 1590: }
1591: $status{'reviewqueue'}=
1592: &check_queue_for_key($cdom,$cnum,'reviewqueue',
1593: &encode_queue_key($symb,$udom,$uname));
1594: $status{'gradingqueue'}=
1595: &check_queue_for_key($cdom,$cnum,'gradingqueue',
1596: &encode_queue_key($symb,$udom,$uname));
1.49 albertel 1597: return %status;
1598: }
1599:
1.1 albertel 1600: sub start_ClosingParagraph {
1601: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1602: my $result;
1603: if ($target eq 'web') {
1.13 albertel 1604: } elsif ($target eq 'webgrade') {
1605: &Apache::lonxml::startredirection();
1.1 albertel 1606: }
1607: return $result;
1608: }
1609:
1610: sub end_ClosingParagraph {
1611: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1612: my $result;
1613: if ($target eq 'web') {
1.13 albertel 1614: } elsif ($target eq 'webgrade') {
1615: &Apache::lonxml::endredirection();
1.1 albertel 1616: }
1617: return $result;
1618: }
1619:
1.19 albertel 1620: sub get_id {
1621: my ($parstack,$safeeval)=@_;
1622: my $id=&Apache::lonxml::get_param('id',$parstack,$safeeval);
1623: if (!$id) { $id=$Apache::lonxml::curdepth; }
1624: return $id;
1625: }
1626:
1.1 albertel 1627: my %dimension;
1628: sub start_Dimension {
1629: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1630: undef(%dimension);
1.19 albertel 1631: my $dim_id=&get_id($parstack,$safeeval);
1.9 albertel 1632: $Apache::bridgetask::dimension=$dim_id;
1633: push(@Apache::bridgetask::dimensionlist,$dim_id);
1634: undef(@Apache::bridgetask::instance);
1.20 albertel 1635: $Apache::bridgetask::dimensionmandatory{$dim_id}=
1636: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.54 albertel 1637: &Apache::lonxml::startredirection();
1638: return &internal_location($dim_id);
1.1 albertel 1639: }
1640:
1.13 albertel 1641: sub get_instance {
1.75 albertel 1642: my ($dim)=@_;
1643: my $rand_alg=&Apache::lonnet::get_rand_alg();
1644: if (!$rand_alg || $rand_alg eq '32bit' || $rand_alg eq '64bit' ||
1645: $rand_alg eq '64bit2' || $rand_alg eq '64bit3' ||
1646: $rand_alg eq '64bit4' ) {
1647: &Apache::response::pushrandomnumber();
1648: my @order=&Math::Random::random_permutation(@{$dimension{'instances'}});
1649: my $num=@order;
1650: my $version=&get_version();
1651: my $which=($version-1)%$num;
1652: return $order[$which];
1653: } else {
1654: my ($version,$previous) = &get_version();
1655: my $instance =
1656: $Apache::lonhomework::history{"resource.$version.0.$dim.instance"};
1657: if (defined($instance)) { return $instance; }
1658:
1659: &Apache::response::pushrandomnumber();
1660: my @instances = @{$dimension{'instances'}};
1661: # remove disabled instances
1662: for (my $i=0; $i < $#instances; $i++) {
1663: if ($dimension{$instances[$i].'.disabled'}) {
1664: splice(@instances,$i,1);
1665: $i--;
1666: }
1667: }
1668: @instances = &Math::Random::random_permutation(@instances);
1669: $instance = $instances[($version-1)%scalar(@instances)];
1670: $Apache::lonhomework::results{"resource.$version.0.$dim.instance"} =
1671: $instance;
1.79 albertel 1672: $Apache::lonhomework::results{'INTERNAL_store'} = 1;
1.75 albertel 1673: &Apache::response::poprandomnumber();
1674: return $instance;
1675: }
1.13 albertel 1676: }
1677:
1.18 albertel 1678: {
1679: my $last_link;
1680: sub end_Dimension {
1681: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.54 albertel 1682: my $result=&Apache::lonxml::endredirection();
1.25 albertel 1683: my $dim=&get_id($parstack,$safeeval);
1.75 albertel 1684: my $instance=&get_instance($dim);
1.25 albertel 1685: my $version=&get_version();
1.18 albertel 1686: if ($target eq 'web') {
1.47 albertel 1687: @Apache::scripttag::parser_env = @_;
1688: $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
1.76 albertel 1689: my @instances = $instance;
1690: if (&Apache::response::showallfoils()) {
1691: @instances = @{$dimension{'instances'}};
1692: }
1693: foreach my $instance (@instances) {
1694: @Apache::scripttag::parser_env = @_;
1695: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
1.89 albertel 1696: if ($Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass' ||
1697: $Apache::lonhomework::history{"resource.$version.0.status"} eq 'fail') {
1.76 albertel 1698:
1.89 albertel 1699: my $dim_status=$Apache::lonhomework::history{"resource.$version.0.$dim.status"};
1.76 albertel 1700: my $mandatory='Mandatory';
1701: if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') {
1702: $mandatory='Optional';
1703: }
1704: my $dim_info="<div class='$dim_status'>\n";
1705: if ($dim_status eq 'pass') {
1706: $dim_info.='<h3>Question : you passed this '.$mandatory.' question</h3>';
1.54 albertel 1707: }
1.76 albertel 1708: if ($dim_status eq 'fail') {
1709: $dim_info.='<h3>Question : you did not pass this '.$mandatory.' question</h3>';
1.53 albertel 1710: }
1.76 albertel 1711: my $man_count=0;
1712: my $man_passed=0;
1713: my $opt_count=0;
1714: my $opt_passed=0;
1715: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1716: if ($dimension{$instance.'.criteria.'.$id.'.mandatory'}
1717: eq 'N') {
1718: $opt_count++;
1.89 albertel 1719: if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') {
1.76 albertel 1720: $opt_passed++;
1721: }
1722: } else {
1723: $man_count++;
1.89 albertel 1724: if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') {
1.76 albertel 1725: $man_passed++;
1726: }
1727: }
1.22 albertel 1728: }
1.76 albertel 1729: if ($man_passed eq $man_count) { $man_passed='all'; }
1730: my $opt_req=$dimension{$instance.'.optionalrequired'};
1731: if ($opt_req !~ /\S/) { $opt_req='0'; }
1732: $dim_info.="\n<p>".&mt('You passed [_1] of the [_2] mandatory components and [_3] of the [_4] optional components, of which you were required to pass [_5].',$man_passed,$man_count,$opt_passed,$opt_count,$opt_req)."</p>\n</div>";
1733:
1734: my $internal_location=&internal_location($dim);
1735: $result=~s/\Q$internal_location\E/$dim_info/;
1736:
1737: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.89 albertel 1738: my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"};
1739: my $comment=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"};
1.76 albertel 1740: my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
1741: if ($mandatory) {
1742: $mandatory='Mandatory';
1743: } else {
1744: $mandatory='Optional';
1745: }
1746: if ($status eq 'fail') {
1747: } elsif ($status eq 'pass') {
1748: } else {
1749: &Apache::lonxml::error("Student viewing a graded bridgetask was shown a status of $status");
1750: }
1751: my $status_display=$status;
1752: $status_display=~s/^([a-z])/uc($1)/e;
1753: @Apache::scripttag::parser_env = @_;
1754: $result.='<div class="'.$status.'"><h4>'.$mandatory.
1755: ' Criteria</h4><p>';
1756: @Apache::scripttag::parser_env = @_;
1757: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
1758: $result.='</p><p class="grade">'.$status_display.'</p>';
1.89 albertel 1759: if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}) {
1.100 albertel 1760: $result.='<p class="comment">'.&mt('Comment: [_1]',$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}).'</p>';
1.76 albertel 1761: }
1762: $result.='</div>';
1.22 albertel 1763: }
1764: }
1765: }
1.18 albertel 1766: } elsif ($target eq 'webgrade') {
1.47 albertel 1767: # in case of any side effects that we need
1768: @Apache::scripttag::parser_env = @_;
1769: &Apache::scripttag::xmlparse($dimension{'intro'});
1770: @Apache::scripttag::parser_env = @_;
1771: &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
1.18 albertel 1772: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1773: my $link='criteria_'.$instance.'_'.$id;
1.89 albertel 1774: my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"};
1.111 ! albertel 1775: $result.='<div id="'.$link.'">'."\n".
! 1776: '<a name="'.$link.'" />'."\n".
! 1777: '<a name="next_'.$last_link.'" />'."\n".
! 1778: '<div class="criteriatext">'."\n";
1.47 albertel 1779: @Apache::scripttag::parser_env = @_;
1780: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
1.111 ! albertel 1781: $result.='</div>'."\n".
1.18 albertel 1782: #$dimension{$instance.'.criteria.'.$id}.
1.111 ! albertel 1783: '<div class="grade">'."\n".
! 1784: '<label class="ungraded"><input type="radio" name="HWVAL_'.$link.'" value="ungraded" '.($status eq 'ungraded' || !$status ? 'checked="checked"':'').' />'.&mt('Ungraded').'</label>'."\n".
! 1785: '<label class="fail"><input type="radio" name="HWVAL_'.$link.'" value="fail" '.($status eq 'fail' ? 'checked="checked"':'').' />'.&mt('Fail').'</label>'."\n".
! 1786: '<label class="pass"><input type="radio" name="HWVAL_'.$link.'" value="pass" '.($status eq 'pass' ? 'checked="checked"':'').' />'.&mt('Pass').'</label>'."\n".
! 1787: '<label class="review"><input type="radio" name="HWVAL_'.$link.'" value="review" '.($status eq 'review' ? 'checked="checked"':'').' />'.&mt('Review').'</label>'."\n".
! 1788: '</div>'."\n".
! 1789: '<label class="comment">'.&mt('Additional Comment for Student').'</label>'."\n".
! 1790: '<textarea class="comment_area" name="HWVAL_comment_'.$link.'">'.&HTML::Entities::encode($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"}).'</textarea>'."\n".
! 1791: '</label>'."\n".
! 1792: '<ul class="navbuttons">'."\n".
! 1793: '<li><a href="#'.$last_link.'">Prev</a></li>'."\n".
! 1794: '<li><a href="#next_'.$link.'">Next</a></li>'."\n".
! 1795: '</ul>'."\n".
! 1796: '</div>'."\n";
1.18 albertel 1797: $last_link=$link;
1798: }
1.22 albertel 1799: } elsif ($target eq 'grade' && $env{'form.webgrade'}) {
1.19 albertel 1800: my $optional_passed=0;
1.20 albertel 1801: my $mandatory_failed=0;
1802: my $ungraded=0;
1803: my $review=0;
1.19 albertel 1804: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.89 albertel 1805: my $status=$Apache::lonhomework::results{"resource.$version.0.$dim.$instance.$id.status"}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id};
1806: $Apache::lonhomework::results{"resource.$version.0.$dim.$instance.$id.comment"}=$env{'form.HWVAL_comment_criteria_'.$instance.'_'.$id};
1.20 albertel 1807: my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
1808: if ($status eq 'pass') {
1809: if (!$mandatory) { $optional_passed++; }
1810: } elsif ($status eq 'fail') {
1811: if ($mandatory) { $mandatory_failed++; }
1.21 albertel 1812: } elsif ($status eq 'review') {
1813: $review++;
1.20 albertel 1814: } elsif ($status eq 'ungraded') {
1815: $ungraded++;
1.21 albertel 1816: } else {
1.47 albertel 1817: $ungraded++;
1.19 albertel 1818: }
1819: }
1.20 albertel 1820: if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
1821: $mandatory_failed++;
1822: }
1.21 albertel 1823: &Apache::lonxml::debug("all instance ".join(':',@{$dimension{$instance.'.criterias'}})." results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
1.20 albertel 1824: if ($review) {
1.89 albertel 1825: $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
1.22 albertel 1826: 'review';
1.20 albertel 1827: } elsif ($ungraded) {
1.89 albertel 1828: $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
1.22 albertel 1829: 'ungraded';
1.20 albertel 1830: } elsif ($mandatory_failed) {
1.89 albertel 1831: $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
1.22 albertel 1832: 'fail';
1.20 albertel 1833: } else {
1.91 albertel 1834: $Apache::lonhomework::results{"resource.$version.0.$dim.status"}=
1.22 albertel 1835: 'pass';
1.20 albertel 1836: }
1.69 albertel 1837: } else {
1838: # any other targets no output
1839: undef($result);
1.13 albertel 1840: }
1.18 albertel 1841: return $result;
1.1 albertel 1842: }
1843: }
1844:
1845: sub start_IntroParagraph {
1.87 albertel 1846: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.1 albertel 1847: my $result;
1.13 albertel 1848: if ($target eq 'web' || $target eq 'webgrade') {
1.47 albertel 1849: if ($tagstack->[-2] eq 'Dimension') {
1.87 albertel 1850: $dimension{'intro'}=&Apache::lonxml::get_all_text('/introparagraph',$parser,$style);
1.47 albertel 1851:
1852: } elsif ($target eq 'webgrade') {
1.87 albertel 1853: &Apache::lonxml::get_all_text('/introparagraph',$parser,$style);
1.1 albertel 1854: }
1.47 albertel 1855:
1.1 albertel 1856: }
1857: return $result;
1858: }
1859:
1860: sub end_IntroParagraph {
1861: }
1862:
1863: sub start_Instance {
1864: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.19 albertel 1865: my $id=&get_id($parstack,$safeeval);
1866: push(@{$dimension{'instances'}},$id);
1867: push(@Apache::bridgetask::instance,$id);
1868: push(@Apache::bridgetask::instancelist,$id);
1.20 albertel 1869: $dimension{$id.'.optionalrequired'}=
1.19 albertel 1870: &Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval);
1.75 albertel 1871: my $disabled = &Apache::lonxml::get_param('Disabled',$parstack,$safeeval);
1872: if (lc($disabled) eq 'yes') {
1873: $dimension{$id.'.disabled'}='1';
1874: }
1.1 albertel 1875: return '';
1876: }
1877:
1878: sub end_Instance {
1879: }
1880:
1881: sub start_InstanceText {
1.87 albertel 1882: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.47 albertel 1883: my $instance_id=$Apache::bridgetask::instance[-1];
1.87 albertel 1884: my $text=&Apache::lonxml::get_all_text('/instancetext',$parser,$style);
1.13 albertel 1885: if ($target eq 'web' || $target eq 'webgrade') {
1.47 albertel 1886: $dimension{$instance_id.'.text'}=$text;
1.1 albertel 1887: }
1888: return '';
1889: }
1890:
1891: sub end_InstanceText {
1892: return '';
1893: }
1894:
1895: sub start_Criteria {
1.87 albertel 1896: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.9 albertel 1897: my $instance_id=$Apache::bridgetask::instance[-1];
1.87 albertel 1898: my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser,$style);
1.21 albertel 1899: if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
1.19 albertel 1900: my $id=&get_id($parstack,$safeeval);
1.1 albertel 1901: $dimension{$instance_id.'.criteria.'.$id}=$criteria;
1.19 albertel 1902: $dimension{$instance_id.'.criteria.'.$id.'.mandatory'}=
1903: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.1 albertel 1904: push(@{$dimension{$instance_id.'.criterias'}},$id);
1905: }
1906: return '';
1907: }
1908:
1.47 albertel 1909: sub end_Criteria {
1910: }
1911:
1.4 albertel 1912: sub proctor_validation_screen {
1913: my ($slot) = @_;
1914: my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
1.5 albertel 1915: my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg');
1.44 albertel 1916: my $name=&Apache::loncommon::plainname($user,$domain);
1917:
1.4 albertel 1918: my $msg;
1.11 albertel 1919: if ($env{'form.proctorpassword'}) {
1.4 albertel 1920: $msg='<p><font color="red">'.&mt("Failed to authenticate the proctor.")
1921: .'</font></p>';
1922: }
1.47 albertel 1923: if (!$env{'form.proctordomain'}) { $env{'form.proctordomain'}=$domain; }
1.4 albertel 1924: my $result= (<<ENDCHECKOUT);
1925: <h2>Proctor Validation</h2>
1926: <p>Your room's proctor needs to validate your access to this resource.</p>
1927: $msg
1.11 albertel 1928: <form name="checkout" method="POST" action="$env{'request.uri'}">
1.4 albertel 1929: <input type="hidden" name="validate" value="yes" />
1930: <input type="hidden" name="submitted" value="yes" />
1931: <table>
1.44 albertel 1932: <tr><td>Proctor's Username:</td><td><input type="string" name="proctorname" value="$env{'form.proctorname'}" /></td></tr>
1.4 albertel 1933: <tr><td>Password:</td><td><input type="password" name="proctorpassword" value="" /></td></tr>
1.46 albertel 1934: <tr><td>Proctor's Domain:</td><td><input type="string" name="proctordomain" value="$env{'form.proctordomain'}" /></td></tr>
1.4 albertel 1935: </table>
1936: <input type="submit" name="checkoutbutton" value="Validate" /><br />
1.44 albertel 1937: <table border="1">
1938: <tr><td>
1939: <table>
1940: <tr><td colspan="2">Student who should be logged in is:</td></tr>
1941: <tr><td>Name:</td><td>$name</td></tr>
1.45 albertel 1942: <tr><td>Student ID:</td><td>$env{'environment.id'}</td></tr>
1.44 albertel 1943: <tr><td>Usename</td><td>$user\@$domain</td></tr>
1944: <tr><td colspan="2"><img src="$url" /></td></tr>
1945: </table>
1946: </tr></td>
1947: </table>
1.4 albertel 1948: </form>
1949: ENDCHECKOUT
1950: return $result;
1951: }
1952:
1.1 albertel 1953: 1;
1954: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>