Annotation of loncom/homework/bridgetask.pm, revision 1.31
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # definition of tags that give a structure to a document
3: #
1.31 ! albertel 4: # $Id: bridgetask.pm,v 1.30 2005/05/24 19:33:28 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;
39: use Time::HiRes qw( gettimeofday tv_interval );
1.9 albertel 40:
1.1 albertel 41: BEGIN {
42: &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Instance','InstanceText','Criteria','ClosingParagraph'));
43: }
44:
1.9 albertel 45: sub initialize_bridgetask {
46: # id of current Dimension, 0 means that no dimension is current
47: # (inside <Task> only)
48: $Apache::bridgetask::dimension='';
49: # list of all Dimension ids seen
50: @Apache::bridgetask::dimensionlist=();
1.20 albertel 51: # mandatory attribute of all Dimensions seen
52: %Apache::bridgetask::dimensionmandatory=();
1.9 albertel 53: # list of all current Instance ids
54: @Apache::bridgetask::instance=();
55: # list of all Instance ids seen in this problem
56: @Apache::bridgetask::instancelist=();
1.15 albertel 57: # key of queud user data that we are currently grading
58: $Apache::bridgetask::queue_key='';
1.9 albertel 59: }
60:
1.4 albertel 61: sub proctor_check_auth {
1.22 albertel 62: my ($slot_name,$slot)=@_;
1.11 albertel 63: my $user=$env{'form.proctorname'};
64: my $domain=$env{'form.proctordomain'};
1.4 albertel 65:
66: my @allowed=split(",",$slot->{'proctor'});
67: foreach my $possible (@allowed) {
68: my ($puser,$pdom)=(split('@',$possible));
69: if ($puser eq $user && $pdom eq $domain) {
1.11 albertel 70: my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
1.4 albertel 71: if ($authhost ne 'no_host') {
1.23 albertel 72: my $version=
73: $Apache::lonhomework::results{'resource.version'}=
1.27 albertel 74: ++$Apache::lonhomework::history{'resource.version'};
1.23 albertel 75: $Apache::lonhomework::results{"resource.$version.checkedin"}=
1.4 albertel 76: $user.'@'.$domain;
1.23 albertel 77: $Apache::lonhomework::results{"resource.$version.checkedin.slot"}=
1.22 albertel 78: $slot_name;
1.28 albertel 79: foreach my $key (keys(%Apache::lonhomework::history)) {
80: if ($key=~/^resource\.0\./) {
81: $Apache::lonhomework::results{$key}='';
82: }
83: }
1.4 albertel 84: return 1;
85: }
86: }
87: }
88: return 0;
89: }
90:
1.25 albertel 91: sub get_version {
1.29 albertel 92: my ($version,$previous);
1.25 albertel 93: if ($env{'form.previousversion'} &&
94: defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) {
1.29 albertel 95: $version=$env{'form.previousversion'};
96: $previous=1;
97: } else {
98: $version=$Apache::lonhomework::history{'resource.version'};
99: $previous=0;
100: }
101: if (wantarray) {
102: return ($version,$previous);
1.25 albertel 103: }
1.29 albertel 104: return $version;
1.25 albertel 105: }
106:
1.8 albertel 107: sub add_previous_version_button {
1.25 albertel 108: my ($status)=@_;
1.8 albertel 109: my $result;
1.29 albertel 110: if ($Apache::lonhomework::history{'resource.version'} eq '') {
1.25 albertel 111: return '';
112: }
1.29 albertel 113: if ($Apache::lonhomework::history{'resource.version'} < 2 &&
114: $status ne 'NEEDS_CHECKIN') {
1.25 albertel 115: return '';
116: }
1.29 albertel 117: my $version=&get_version();
118: if ($env{'form.previousversion'} ne '' &&
119: $env{'form.previousversion'} eq $version) {
120: $result.="<h3>".&mt("Showing previous version [_1]",$version).
121: "</h3>\n";
122: }
123: my @to_show;
124: foreach my $test_version (1..$Apache::lonhomework::history{'resource.version'}) {
125: if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.status'})) {
126: push(@to_show,$test_version);
127: }
128: }
129: my $list='<option>'.
130: join("</option>\n<option>",@to_show).
131: "</option>\n";
132: $result.='<form name="getprevious" method="POST" action="';
133: my $uri=$env{'request.uri'};
134: if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
135: $result.=$uri.'">'.
136: &mt(' Show a previously done version: [_1]','<select onchange="this.form.submit()" name="previousversion">
137: <option>'.&mt('Pick one').'</option>
138: '.$list.'
139: </select>')."</form>";
1.8 albertel 140: return $result;
141: }
142:
1.13 albertel 143: sub add_grading_button {
1.29 albertel 144: my $result=' <input type="submit" name="gradeasubmission" value="'.
1.13 albertel 145: &mt("Get a submission to grade").'" />';
146: $result.='<input type="hidden" name="grade_target" value="webgrade" />';
147: return $result;
148: }
149:
1.22 albertel 150: sub add_request_another_attempt_button {
1.25 albertel 151: my $result;
152: $result.=' <input type="submit" name="requestattempt" value="'.
153: &mt("Request another attempt").'" />';
154: return $result;
1.22 albertel 155: }
156:
1.30 albertel 157: sub preserve_grade_info {
158: my $result;
159: # if we are viewing someone else preserve that info
160: if (defined $env{'form.grade_symb'}) {
161: foreach my $field ('symb','courseid','domain','username') {
162: $result .= '<input type="hidden" name="grade_'.$field.
163: '" value="'.$env{"form.grade_$field"}.'" />'."\n";
164: }
165: }
166: return $result;
167: }
168:
1.1 albertel 169: sub start_Task {
170: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
171:
1.4 albertel 172: my ($status,$accessmsg,$slot);
1.16 albertel 173: if ($target ne 'webgrade') {
174: &Apache::structuretags::initialize_storage();
175: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
176: }
177:
1.4 albertel 178: $Apache::lonhomework::parsing_a_task=1;
1.1 albertel 179: #should get back a <html> or the neccesary stuff to start XML/MathML
180: my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
181: &Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
1.16 albertel 182:
1.8 albertel 183: if ($target eq 'web') {
1.13 albertel 184: if ($Apache::lonhomework::modifygrades) {
185: $body_tag_start.='<form name="gradesubmission" method="POST" action="';
186: my $uri=$env{'request.uri'};
187: if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
188: $body_tag_start.=$uri.'">'.&add_grading_button()."</form>";
189: }
1.8 albertel 190: }
1.21 albertel 191: if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
1.1 albertel 192: $target eq 'tex') {
1.29 albertel 193: my ($version,$previous)=&get_version();
1.14 albertel 194: ($status,$accessmsg,my $slot_name,$slot) =
1.4 albertel 195: &Apache::lonhomework::check_task_access('0');
1.9 albertel 196: push(@Apache::inputtags::status,$status);
1.14 albertel 197: $Apache::inputtags::slot_name=$slot_name;
1.1 albertel 198: my $expression='$external::datestatus="'.$status.'";';
1.23 albertel 199: $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.solved"}.'";';
1.1 albertel 200: &Apache::run::run($expression,$safeeval);
201: &Apache::lonxml::debug("Got $status");
1.25 albertel 202: $body_tag_start.=&add_previous_version_button($status);
1.29 albertel 203: if (!$previous && (
204: ( $status eq 'CLOSED' ) ||
205: ( $status eq 'BANNED') ||
206: ( $status eq 'UNAVAILABLE') ||
207: ( $status eq 'NOT_IN_A_SLOT') ||
208: ( $status eq 'NEEDS_CHECKIN') ||
209: ( $status eq 'WAITING_FOR_GRADE') ||
210: ( $status eq 'INVALID_ACCESS') )) {
1.1 albertel 211: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
212: if ( $target eq "web" ) {
1.4 albertel 213: $result.= $head_tag_start.'</head>'.$body_tag_start;
214: my $msg;
1.1 albertel 215: if ($status eq 'UNAVAILABLE') {
216: $msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>';
1.3 albertel 217: } elsif ($status eq 'NOT_IN_A_SLOT') {
218: $msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>';
1.4 albertel 219: } elsif ($status eq 'NEEDS_CHECKIN') {
220: $msg.='<h1>'.&mt('You need the Proctor to validate you.').
221: '</h1>'.&proctor_validation_screen($slot);
1.22 albertel 222: } elsif ($status eq 'WAITING_FOR_GRADE') {
223: $msg.='<h1>'.&mt('Your submission is in the grading queue.').'</h1>';
1.1 albertel 224: } elsif ($status ne 'NOT_YET_VIEWED') {
225: $msg.='<h1>'.&mt('Not open to be viewed').'</h1>';
226: }
227: if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
228: $msg.='The problem '.$accessmsg;
229: }
230: $result.=$msg.'<br />';
231: } elsif ($target eq 'tex') {
232: $result.='\begin{document}\noindent \vskip 1 mm \begin{minipage}{\textwidth}\vskip 0 mm';
233: if ($status eq 'UNAVAILABLE') {
234: $result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
235: } else {
236: $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
237: }
1.22 albertel 238: } elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
1.4 albertel 239: if ($status eq 'NEEDS_CHECKIN') {
1.22 albertel 240: if (&proctor_check_auth($slot_name,$slot)) {
1.4 albertel 241: #FIXME immeadiatly add this to the grading queue
242: # with slot->{'endtime'} for when grading can
243: # begin on this resource
1.22 albertel 244: # FIXME I think the above is done by default,
245: # need to check that
246: # failure doesn't do this.
1.4 albertel 247: }
248: }
1.1 albertel 249: }
250: } elsif ($target eq 'web') {
251: my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
252: $result.="$head_tag_start<title>$name</title></head>
253: $body_tag_start \n $form_tag_start".
254: '<input type="hidden" name="submitted" value="yes" />';
1.30 albertel 255: $result.=&preserve_grade_info();
1.29 albertel 256: my ($version,$previous)=&get_version();
1.25 albertel 257: if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
1.22 albertel 258: $result.='<h1><font color="red">'.&mt('Did not pass').'</font></h1>';
1.29 albertel 259: if (!$previous) {
260: $result.=&add_request_another_attempt_button();
261: }
1.22 albertel 262: }
1.25 albertel 263: if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
1.22 albertel 264: $result.='<h1><font color="green">'.&mt('Passed').'</font></h1>';
265: }
1.1 albertel 266: }
1.21 albertel 267: } elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
268: $target eq 'webgrade') {
269: if ($target eq 'webgrade') {
270: $result.=$head_tag_start.$body_tag_start.$form_tag_start;
271: $result.='<input type="hidden" name="webgrade" value="yes" />';
1.31 ! albertel 272: $result.='<br />Review'.&show_queue('reviewqueue');
1.30 albertel 273: $result.='<br />Before'.&show_queue('gradingqueue');
274: }
275: my $todo;
276: # don't get something new from the queue if they hit the stop button
277: if (!($env{'form.stop'} && $target eq 'webgrade')) {
278: $todo=&get_from_queue('gradingqueue');
1.21 albertel 279: }
1.15 albertel 280: if ($todo) {
1.16 albertel 281: &setup_env_for_other_user($todo,$safeeval);
1.15 albertel 282: my ($symb,$uname,$udom)=&decode_queue_key($todo);
1.16 albertel 283: $result.="\n".'<table><tr><td>Found '.
284: &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'</td></tr></table>';
1.15 albertel 285: $result.='<input type="hidden" name="gradingkey" value="'.
1.16 albertel 286: &Apache::lonnet::escape($todo).'" />';
1.15 albertel 287: $Apache::bridgetask::queue_key=$todo;
1.16 albertel 288: &Apache::structuretags::initialize_storage();
289: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
1.30 albertel 290: if ($target eq 'webgrade') {
291: $result.='<br />After'.&show_queue('gradingqueue');
292: $result.="\n".'<table width="100%" style="width:100%" border="1">';
293: }
1.15 albertel 294: } else {
1.21 albertel 295: if ($target eq 'webgrade') {
1.30 albertel 296: $result.="\n".'<table><tr><td><b>';
297: if ($env{'form.stop'}) {
298: $result.=&mt("Stopped grading.");
299: } else {
300: $result.=&mt("No user to be graded.");
301: }
302: $result.='</b></td></tr></table>';
1.21 albertel 303: }
1.15 albertel 304: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
305: }
1.1 albertel 306: } else {
307: # page_start returned a starting result, delete it if we don't need it
308: $result = '';
309: }
310: return $result;
311: }
312:
313: sub end_Task {
314: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
315: my $result='';
316: my $status=$Apache::inputtags::status['-1'];
1.29 albertel 317: my ($version,$previous)=&get_version();
1.1 albertel 318: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
1.15 albertel 319: $target eq 'tex') {
1.1 albertel 320: if (
1.11 albertel 321: (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
1.1 albertel 322: ($target eq 'answer') || ($target eq 'tex')
323: ) {
324: if ($target eq 'web') {
1.29 albertel 325: if ($status eq 'CAN_ANSWER' && !$previous) {
1.15 albertel 326: $result.="\n".'<table border="1">'.
1.28 albertel 327: &Apache::inputtags::file_selector("$version.0",
328: "bridgetask","*",
1.9 albertel 329: 'portfolioonly').
330: "</table>";
331: $result.=&Apache::inputtags::gradestatus('0');
332: }
1.13 albertel 333: }
334: if ($target eq 'web' || $target eq 'webgrade') {
1.1 albertel 335: $result.=&Apache::lonxml::xmlend().'</html>';
336: }
337: }
1.29 albertel 338: if ($target eq 'grade' && !$env{'form.webgrade'} && !$previous) {
1.12 albertel 339: my $award='SUBMITTED';
1.28 albertel 340: &Apache::essayresponse::file_submission("$version.0",'bridgetask',
1.20 albertel 341: 'portfiles',\$award);
1.14 albertel 342: if ($award eq 'SUBMITTED' &&
1.28 albertel 343: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}) {
344: $Apache::lonhomework::results{"resource.0.tries"}=
345: $Apache::lonhomework::results{"resource.$version.0.tries"}=
346: 1+$Apache::lonhomework::history{"resource.$version.0.tries"};
347:
348: $Apache::lonhomework::results{"resource.0.award"}=
349: $Apache::lonhomework::results{"resource.$version.0.award"}=
350: $award;
1.10 albertel 351: }
1.4 albertel 352: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
353: &Apache::structuretags::finalize_storage();
1.14 albertel 354: if ($award eq 'SUBMITTED') {
1.31 ! albertel 355: &add_to_queue('gradingqueue',$Apache::inputtags::slot_name);
1.14 albertel 356: }
1.1 albertel 357: }
1.20 albertel 358: if ($target eq 'grade' && $env{'form.webgrade'}) {
359: my $optional_required=
360: &Apache::lonxml::get_param('OptionalRequired',$parstack,
361: $safeeval);
362: my $optional_passed=0;
363: my $mandatory_failed=0;
364: my $ungraded=0;
365: my $review=0;
1.21 albertel 366: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
1.20 albertel 367: foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
368: my $status=
1.25 albertel 369: $Apache::lonhomework::results{"resource.$version.$dim_id.status"};
1.20 albertel 370: my $mandatory=
371: ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
372: if ($status eq 'pass') {
373: if (!$mandatory) { $optional_passed++; }
374: } elsif ($status eq 'fail') {
375: if ($mandatory) { $mandatory_failed++; }
376: } elsif ($status eq 'ungraded') {
377: $ungraded++;
378: } elsif ($status eq 'review') {
379: $review++;
380: }
381: }
382: if ($optional_passed < $optional_required) {
383: $mandatory_failed++;
384: }
1.21 albertel 385: &Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
386: $Apache::lonhomework::results{'resource.grader'}=
1.20 albertel 387: $env{'user.name'}.'@'.$env{'user.domain'};
388: if ($review) {
1.25 albertel 389: $Apache::lonhomework::results{"resource.$version.status"}='review';
1.31 ! albertel 390: &move_between_queues('gradingqueue','reviewqueue');
1.20 albertel 391: } elsif ($ungraded) {
1.25 albertel 392: $Apache::lonhomework::results{"resource.$version.status"}='ungraded';
1.30 albertel 393: &check_queue_unlock('gradingqueue');
1.20 albertel 394: } elsif ($mandatory_failed) {
1.25 albertel 395: $Apache::lonhomework::results{"resource.$version.status"}='fail';
396: $Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
397: $Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
398: $Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
1.30 albertel 399: &remove_from_queue('gradingqueue');
1.20 albertel 400: } else {
1.25 albertel 401: $Apache::lonhomework::results{"resource.$version.status"}='pass';
402: $Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
403: $Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
404: $Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
1.31 ! albertel 405: &remove_from_queue('grading_queue');
1.20 albertel 406: }
1.26 albertel 407: $Apache::lonhomework::results{"resource.status"}=
408: $Apache::lonhomework::results{"resource.$version.status"};
1.28 albertel 409: if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) {
1.26 albertel 410: $Apache::lonhomework::results{"resource.0.award"}=
411: $Apache::lonhomework::results{"resource.$version.award"};
412: $Apache::lonhomework::results{"resource.0.awarded"}=
413: $Apache::lonhomework::results{"resource.$version.awarded"};
414: $Apache::lonhomework::results{"resource.0.solved"}=
415: $Apache::lonhomework::results{"resource.$version.solved"};
1.25 albertel 416: }
1.21 albertel 417: &Apache::structuretags::finalize_storage();
1.20 albertel 418: }
1.15 albertel 419: } elsif ($target eq 'webgrade') {
1.18 albertel 420: $result.="</table>\n<hr />";
1.20 albertel 421: #$result.='<input type="submit" name="next" value="'.
422: # &mt('Save & Next').'" /> ';
423: #$result.='<input type="submit" name="end" value="'.
424: # &mt('Save & Stop Grading').'" /> ';
425: #$result.='<input type="submit" name="throwaway" value="'.
426: # &mt('Throw Away & Stop Grading').'" /> ';
427: #$result.='<input type="submit" name="save" value="'.
428: # &mt('Save Partial Grade and Continue Grading').'" /> ';
1.15 albertel 429: $result.='</form>'.&Apache::loncommon::endbodytag().'</html>';
1.1 albertel 430: } elsif ($target eq 'meta') {
1.2 albertel 431: $result.='<parameter part="0" package="Task"></parameter>'."\n";
1.1 albertel 432: #$result.=&Apache::response::meta_part_order();
433: #$result.=&Apache::response::meta_response_order();
434: }
1.4 albertel 435: undef($Apache::lonhomework::parsing_a_task);
1.1 albertel 436: return $result;
437: }
438:
1.31 ! albertel 439: sub move_between_queues {
! 440: my ($src_queue,$dest_queue)=@_;
! 441: my $cur_data=&get_queue_data($src_queue);
! 442: if (!$cur_data) { return 'not_exist'; }
! 443: my $result=&add_to_queue($dest_queue,$cur_data->[0]);
! 444: if ($result ne 'ok') {
! 445: return $result;
! 446: }
! 447: &check_queue_unlock($src_queue);
! 448: return &remove_from_queue($src_queue);
1.21 albertel 449: }
450:
451: sub check_queue_unlock {
1.30 albertel 452: my ($queue)=@_;
453: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
454: my $cnum=$env{'course.'.$cid.'.num'};
455: my $cdom=$env{'course.'.$cid.'.domain'};
456: my $key="$symb\0queue\0$uname\@$udom";
457: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
458: my $who=&queue_key_locked($queue,$key,$cdom,$cnum);
459: if ($who eq $me) {
460: &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
461: }
1.21 albertel 462: }
463:
464: sub remove_from_queue {
1.30 albertel 465: my ($queue)=@_;
1.27 albertel 466: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
467: my $cnum=$env{'course.'.$cid.'.num'};
468: my $cdom=$env{'course.'.$cid.'.domain'};
469: my $key="$symb\0queue\0$uname\@$udom";
470: my @keys=($key,"$key\0locked");
1.31 ! albertel 471: return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
1.21 albertel 472: }
473:
1.16 albertel 474: sub setup_env_for_other_user {
475: my ($queue_key,$safeeval)=@_;
476: my ($symb,$uname,$udom)=&decode_queue_key($queue_key);
1.30 albertel 477: &Apache::lonxml::debug("setup_env for $queue_key");
1.16 albertel 478: $env{'form.grade_symb'}=$symb;
479: $env{'form.grade_domain'}=$udom;
480: $env{'form.grade_username'}=$uname;
481: $env{'form.grade_courseid'}=$env{'request.course.id'};
482: &Apache::lonxml::initialize_rndseed($safeeval);
483: }
484:
1.31 ! albertel 485: sub get_queue_data {
! 486: my ($queue)=@_;
! 487: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
! 488: my $cnum=$env{'course.'.$cid.'.num'};
! 489: my $cdom=$env{'course.'.$cid.'.domain'};
! 490: my $todo="$symb\0queue\0$uname\@$udom";
! 491: my ($key,$value)=&Apache::lonnet::get($queue,[$todo],$cdom,$cnum);
! 492: if ($key eq $todo && ref($value)) {
! 493: return $value;
! 494: }
! 495: return undef;
! 496: }
! 497:
1.14 albertel 498: sub add_to_queue {
1.31 ! albertel 499: my ($queue,$slot_name)=@_;
1.14 albertel 500: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
501: my $cnum=$env{'course.'.$cid.'.num'};
502: my $cdom=$env{'course.'.$cid.'.domain'};
503: my %data;
1.31 ! albertel 504: $data{"$symb\0queue\0$uname\@$udom"}=[$slot_name];
! 505: return &Apache::lonnet::put($queue,\%data,$cdom,$cnum);
1.14 albertel 506: }
507:
508: sub show_queue {
1.30 albertel 509: my ($queue)=@_;
1.14 albertel 510: my $result;
511: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
512: my $cnum=$env{'course.'.$cid.'.num'};
513: my $cdom=$env{'course.'.$cid.'.domain'};
1.16 albertel 514: my $regexp="^$symb\0";
1.30 albertel 515: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.31 ! albertel 516: my ($tmp)=%queue;
! 517: if ($tmp=~/^error: 2 /) {
! 518: return "\n<h3>Current Queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
! 519: }
1.27 albertel 520: $result.="\n<h3>Current Queue</h3><table border='1'><tr><th>resource</th>".
1.20 albertel 521: "<th>user</th><th>type</th><th>data</th></tr>";
1.14 albertel 522: foreach my $key (sort(keys(%queue))) {
1.16 albertel 523: if ($key=~/locked$/) {
524: my ($symb,$uname,$udom) = &decode_queue_key($key);
525: my $title=&Apache::lonnet::gettitle($symb);
1.27 albertel 526: $result.="<tr><td>$title</td><td>$uname</td>";
1.16 albertel 527: $result.='<td>lock</td><td>'.$queue{$key}.'</td></tr>';
528: } elsif ($key=~/timestamp$/) {
529: my ($symb,undef) = split("\0",$key);
530: my $title=&Apache::lonnet::gettitle($symb);
1.27 albertel 531: $result.="<tr><td>$title</td><td></td>";
1.16 albertel 532: $result.='<td>last queue modification time</td><td>'.
533: &Apache::lonlocal::locallocaltime($queue{$key})."</td></tr>";
534: } else {
535: my ($symb,$uname,$udom) = &decode_queue_key($key);
536: my $title=&Apache::lonnet::gettitle($symb);
1.27 albertel 537: $result.="<tr><td>$title</td><td>$uname</td>";
1.16 albertel 538: my $slot=$queue{$key}->[0];
539: my %slot_data=&Apache::lonnet::get_slot($slot);
1.27 albertel 540: $result.='<td>queue entry</td><td>Slot: '.$slot.' End time: '.
1.20 albertel 541: &Apache::lonlocal::locallocaltime($slot_data{'endtime'}).
542: "</td></tr>";
1.16 albertel 543: }
1.14 albertel 544: }
1.15 albertel 545: $result.="</table><hr />\n";
1.14 albertel 546: return $result;
547: }
548:
549: sub decode_queue_key {
550: my ($key)=@_;
551: my ($symb,undef,$user) = split("\0",$key);
552: my ($uname,$udom) = split('@',$user);
553: return ($symb,$uname,$udom);
554: }
555:
556: sub queue_key_locked {
1.30 albertel 557: my ($queue,$key,$cdom,$cnum)=@_;
1.14 albertel 558: my ($key_locked,$value)=
1.30 albertel 559: &Apache::lonnet::get($queue,["$key\0locked"],$cdom,$cnum);
1.14 albertel 560: if ($key_locked eq "$key\0locked") {
561: return $value;
562: }
563: return undef;
564: }
565:
566: sub pick_from_queue_data {
1.30 albertel 567: my ($queue,$check_section,$queuedata,$cdom,$cnum)=@_;
568: foreach my $key (keys(%$queuedata)) {
1.14 albertel 569: my ($symb,$uname,$udom)=&decode_queue_key($key);
570: if ($check_section) {
571: my $section=&Apache::lonnet::getsection($uname,$udom);
1.17 albertel 572: if ($section eq $check_section) {
573: &Apache::lonnet::logthis("my sec");
1.15 albertel 574: next;
575: }
1.14 albertel 576: }
1.30 albertel 577: my $slot=$queuedata->{$key}[0];
1.14 albertel 578: my %slot_data=&Apache::lonnet::get_slot($slot);
1.15 albertel 579: if ($slot_data{'endtime'} > time) {
580: &Apache::lonnet::logthis("not time");
581: next;
582: }
1.30 albertel 583: if (&queue_key_locked($queue,$key,$cdom,$cnum)) {
1.15 albertel 584: &Apache::lonnet::logthis("someone already has um.");
585: next;
586: }
1.14 albertel 587: return $key;
588: }
589: return undef;
590: }
591:
1.15 albertel 592: sub find_mid_grade {
1.30 albertel 593: my ($queue,$symb,$cdom,$cnum)=@_;
1.16 albertel 594: my $todo=&Apache::lonnet::unescape($env{'form.gradingkey'});
1.15 albertel 595: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
596: if ($todo) {
1.30 albertel 597: my $who=&queue_key_locked($queue,$todo,$cdom,$cnum);
1.15 albertel 598: if ($who eq $me) { return $todo; }
599: }
600: my $regexp="^$symb\0.*\0locked\$";
1.30 albertel 601: my %locks=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.15 albertel 602: foreach my $key (keys(%locks)) {
603: my $who=$locks{$key};
604: if ($who eq $me) {
605: $todo=$key;
606: $todo=~s/\0locked$//;
607: return $todo;
608: }
609: }
610: return undef;
611: }
612:
1.14 albertel 613: sub get_from_queue {
1.30 albertel 614: my ($queue)=@_;
1.14 albertel 615: my $result;
616: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
617: my $cnum=$env{'course.'.$cid.'.num'};
618: my $cdom=$env{'course.'.$cid.'.domain'};
619: my $todo;
1.15 albertel 620: # FIXME need to find if I am 'mid grading'
1.30 albertel 621: $todo=&find_mid_grade($queue,$symb,$cdom,$cnum);
1.15 albertel 622: &Apache::lonnet::logthis("found ".join(':',&decode_queue_key($todo)));
1.16 albertel 623: if ($todo) { return $todo; }
1.14 albertel 624: while (1) {
625: my $starttime=time;
1.30 albertel 626: &Apache::lonnet::put($queue,{"$symb\0timestamp"=>$starttime},
1.14 albertel 627: $cdom,$cnum);
1.15 albertel 628: &Apache::lonnet::logthis("$starttime");
1.14 albertel 629: my $regexp="^$symb\0queue\0";
1.30 albertel 630: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.14 albertel 631: #make a pass looking for a user in my section
632: if ($env{'request.course.sec'}) {
1.15 albertel 633: &Apache::lonnet::logthis("sce");
1.30 albertel 634: $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
635: \%queue,$cdom,$cnum);
1.15 albertel 636: &Apache::lonnet::logthis("sce $todo");
1.14 albertel 637: }
638: # no one in our section so look for any user that is ready for grading
639: if (!$todo) {
1.15 albertel 640: &Apache::lonnet::logthis("no sce");
1.31 ! albertel 641: $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
! 642: \%queue,$cdom,$cnum);
1.15 albertel 643: &Apache::lonnet::logthis("no sce $todo");
1.14 albertel 644: }
645: # no user to grade
646: if (!$todo) { last; }
1.15 albertel 647: &Apache::lonnet::logthis("got $todo");
1.14 albertel 648: # otherwise found someone so lets try to lock them
1.30 albertel 649: my $success=&Apache::lonnet::newput($queue,
1.14 albertel 650: {"$todo\0locked"=>
651: $env{'user.name'}.'@'.$env{'user.domain'}},
652: $cdom,$cnum);
653: # someone else already picked them
1.15 albertel 654: &Apache::lonnet::logthis("success $todo");
1.14 albertel 655: if ($success ne 'ok') { next; }
656: my (undef,$endtime)=
1.30 albertel 657: &Apache::lonnet::get($queue,["$symb\0timestamp"],
1.14 albertel 658: $cdom,$cnum);
1.15 albertel 659: &Apache::lonnet::logthis("emd $endtime");
1.14 albertel 660: # someone else already modified the queue,
661: # perhaps our picked user wass already fully graded between
662: # when we picked him and when we locked his record? so lets
663: # double check.
664: if ($endtime != $starttime) {
665: my ($key,$value)=
1.30 albertel 666: &Apache::lonnet::get($queue,["$todo"],
1.14 albertel 667: $cdom,$cnum);
1.15 albertel 668: &Apache::lonnet::logthis("check $key .. $value");
1.14 albertel 669: if ($key eq $todo && ref($value)) {
670: } else {
1.30 albertel 671: &Apache::lonnet::del($queue,["$todo\0locked"],
1.14 albertel 672: $cdom,$cnum);
1.15 albertel 673: &Apache::lonnet::logthis("del");
1.14 albertel 674: next;
675: }
676: }
1.15 albertel 677: &Apache::lonnet::logthis("last $todo");
1.14 albertel 678: last;
679: }
680: return $todo;
681: }
682:
1.1 albertel 683: sub start_ClosingParagraph {
684: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
685: my $result;
686: if ($target eq 'web') {
1.13 albertel 687: } elsif ($target eq 'webgrade') {
688: &Apache::lonxml::startredirection();
1.1 albertel 689: }
690: return $result;
691: }
692:
693: sub end_ClosingParagraph {
694: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
695: my $result;
696: if ($target eq 'web') {
1.13 albertel 697: } elsif ($target eq 'webgrade') {
698: &Apache::lonxml::endredirection();
1.1 albertel 699: }
700: return $result;
701: }
702:
1.19 albertel 703: sub get_id {
704: my ($parstack,$safeeval)=@_;
705: my $id=&Apache::lonxml::get_param('id',$parstack,$safeeval);
706: if (!$id) { $id=$Apache::lonxml::curdepth; }
707: return $id;
708: }
709:
1.1 albertel 710: my %dimension;
711: sub start_Dimension {
712: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
713: undef(%dimension);
1.19 albertel 714: my $dim_id=&get_id($parstack,$safeeval);
1.9 albertel 715: $Apache::bridgetask::dimension=$dim_id;
716: push(@Apache::bridgetask::dimensionlist,$dim_id);
717: undef(@Apache::bridgetask::instance);
1.20 albertel 718: $Apache::bridgetask::dimensionmandatory{$dim_id}=
719: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.1 albertel 720: return '';
721: }
722:
1.13 albertel 723: sub get_instance {
724: #FIXME just grabbing the first one for now, need
725: #to randomly pick one until all have been seen
726: #then start repicking
727: &Apache::response::pushrandomnumber();
728: my @order=&Math::Random::random_permutation(@{$dimension{'instances'}});
1.29 albertel 729: my $num=@order;
730: my $version=&get_version();
731: my $which=($version-1)%$num;
732: return $order[$which];
1.13 albertel 733: }
734:
1.18 albertel 735: {
736: my $last_link;
737: sub end_Dimension {
738: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
739: my $result;
1.25 albertel 740: my $dim=&get_id($parstack,$safeeval);
1.19 albertel 741: my $instance=&get_instance();
1.25 albertel 742: my $version=&get_version();
1.18 albertel 743: if ($target eq 'web') {
744: $result=$dimension{'intro'}.$dimension{$instance.'.text'};
1.26 albertel 745: if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' ||
746: $Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
1.22 albertel 747: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.25 albertel 748: my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
749: my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"};
1.22 albertel 750: $result.='<table border="1"><tr><td>';
751: if ($status eq 'fail') {
752: $result.='<font color="red">'.&mt('Did not pass').'</font>';
753: } elsif ($status eq 'pass') {
754: $result.='<font color="green">'.&mt('Passed').'</font>';
755: } else {
756: &Apache::lonxml::error("Student viewing a graded bridgetask was show a status of $status");
757: }
758: $result.='</td></tr><tr><td>';
1.25 albertel 759: if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
760: $result.=&mt('Comment from grader: ').$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'</td></tr><tr><td>';
1.22 albertel 761: }
762: $result.=$dimension{$instance.'.criteria.'.$id}.
763: '</td></tr></table>';
764: }
765: }
1.18 albertel 766: } elsif ($target eq 'webgrade') {
767: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
768: my $link='criteria_'.$instance.'_'.$id;
1.25 albertel 769: my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
1.19 albertel 770: $result.='<tr><td width="100%" valign="top">'.
1.18 albertel 771: '<a name="'.$link.'" />'.
772: '<a name="next_'.$last_link.'" />'.
773: '<br /><textarea enabled="false" style="width:100%" rows="8" width="25" wrap="hard">'.$dimension{$instance.'.criteria.'.$id}.'</textarea>'.
774: #$dimension{$instance.'.criteria.'.$id}.
775: '</td>'.
1.19 albertel 776: '<td><nobr>Additional Comment for Student</nobr> <br />'.
1.25 albertel 777: '<textarea style="width:100%" rows="8" width="25" wrap="hard" name="HWVAL_comment_'.$link.'">'.&HTML::Entities::encode($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}).'</textarea>'.
1.18 albertel 778: '</td>'.
779: '<td>'.
1.30 albertel 780: '<nobr><label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" '.($status eq 'ungraded' || !$status ? 'checked="checked"':'').'/>'.&mt('Ungraded').'</label></nobr><br />'.
781: '<label><input type="radio" name="HWVAL_'.$link.'" value="pass" '.($status eq 'pass' ? 'checked="checked"':'').' />'.&mt('Pass').'</label><br />'.
782: '<label><input type="radio" name="HWVAL_'.$link.'" value="fail" '.($status eq 'fail' ? 'checked="checked"':'').' />'.&mt('Fail').'</label><br />'.
783: '<label><input type="radio" name="HWVAL_'.$link.'" value="review" '.($status eq 'review' ? 'checked="checked"':'').' />'.&mt('Review').'</label><br />'.
1.18 albertel 784: '</td>'.
785: '<td>'.
786: '<a href="#'.$last_link.'">Prev</a><br />'.
1.20 albertel 787: '<a href="#next_'.$link.'">Next</a><br /><br /><br />'.
788: '<input type="submit" name="next" value="'.
789: &mt('Done').'" /> '.
1.30 albertel 790: '<input type="submit" name="stop" value="'.
791: &mt('Stop').'" /> '.
1.18 albertel 792: '</td></tr>';
1.22 albertel 793: $result.='<tr><td colspan="4">';
794: my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
795: my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio';
1.23 albertel 796: foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.bridgetask.portfiles"})) {
1.22 albertel 797: my $file=$file_url.$partial_file;
798: &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
799: $result.='<a href="'.$file.'" target="lonGRDs"><img src="'.
800: &Apache::loncommon::icon($file).'" border=0"> '.$file.
801: '</a>';
802: }
803: $result.='</td></tr>';
1.18 albertel 804: $last_link=$link;
805: }
1.22 albertel 806: } elsif ($target eq 'grade' && $env{'form.webgrade'}) {
1.19 albertel 807: my $optional_passed=0;
1.20 albertel 808: my $mandatory_failed=0;
809: my $ungraded=0;
810: my $review=0;
1.19 albertel 811: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.25 albertel 812: my $status=$Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.status"}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id};
813: $Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.comment"}=$env{'form.HWVAL_comment_criteria_'.$instance.'_'.$id};
1.20 albertel 814: my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
815: if ($status eq 'pass') {
816: if (!$mandatory) { $optional_passed++; }
817: } elsif ($status eq 'fail') {
818: if ($mandatory) { $mandatory_failed++; }
1.21 albertel 819: } elsif ($status eq 'review') {
820: $review++;
1.20 albertel 821: } elsif ($status eq 'ungraded') {
822: $ungraded++;
1.21 albertel 823: } else {
1.22 albertel 824: &Apache::lonxml::error("got weird status --$status--");
1.19 albertel 825: }
826: }
1.20 albertel 827: if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
828: $mandatory_failed++;
829: }
1.21 albertel 830: &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 831: if ($review) {
1.25 albertel 832: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 833: 'review';
1.20 albertel 834: } elsif ($ungraded) {
1.25 albertel 835: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 836: 'ungraded';
1.20 albertel 837: } elsif ($mandatory_failed) {
1.25 albertel 838: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 839: 'fail';
1.20 albertel 840: } else {
1.25 albertel 841: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 842: 'pass';
1.20 albertel 843: }
1.13 albertel 844: }
1.18 albertel 845: return $result;
1.1 albertel 846: }
847: }
848:
849: sub start_IntroParagraph {
850: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
851: my $result;
1.13 albertel 852: if ($target eq 'web' || $target eq 'webgrade') {
853: if ($tagstack->[-2] eq 'Dimension' || $target eq 'webgrade') {
1.1 albertel 854: &Apache::lonxml::startredirection();
855: }
856: }
857: return $result;
858: }
859:
860: sub end_IntroParagraph {
861: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
862: my $result;
1.13 albertel 863: if ($target eq 'web' || $target eq 'webgrade') {
864: if ($tagstack->[-2] eq 'Dimension' || $target eq 'webgrade') {
1.1 albertel 865: $dimension{'intro'}=&Apache::lonxml::endredirection();
866: }
867: }
868: return $result;
869: }
870:
871: sub start_Instance {
872: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.19 albertel 873: my $id=&get_id($parstack,$safeeval);
874: push(@{$dimension{'instances'}},$id);
875: push(@Apache::bridgetask::instance,$id);
876: push(@Apache::bridgetask::instancelist,$id);
1.20 albertel 877: $dimension{$id.'.optionalrequired'}=
1.19 albertel 878: &Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval);
1.1 albertel 879: return '';
880: }
881:
882: sub end_Instance {
883: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
884: return '';
885: }
886:
887: sub start_InstanceText {
888: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.13 albertel 889: if ($target eq 'web' || $target eq 'webgrade') {
1.1 albertel 890: &Apache::lonxml::startredirection();
891: }
892: return '';
893: }
894:
895: sub end_InstanceText {
896: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.9 albertel 897: my $instance_id=$Apache::bridgetask::instance[-1];
1.13 albertel 898: if ($target eq 'web' || $target eq 'webgrade') {
1.1 albertel 899: $dimension{$instance_id.'.text'}=&Apache::lonxml::endredirection();
900: }
901: return '';
902: }
903:
904: sub start_Criteria {
905: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.21 albertel 906: if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
1.1 albertel 907: &Apache::lonxml::startredirection();
908: }
909: return '';
910: }
911:
912: sub end_Criteria {
913: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.9 albertel 914: my $instance_id=$Apache::bridgetask::instance[-1];
1.21 albertel 915: if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
1.1 albertel 916: my $criteria=&Apache::lonxml::endredirection();
1.19 albertel 917: my $id=&get_id($parstack,$safeeval);
1.1 albertel 918: $dimension{$instance_id.'.criteria.'.$id}=$criteria;
1.19 albertel 919: $dimension{$instance_id.'.criteria.'.$id.'.mandatory'}=
920: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.1 albertel 921: push(@{$dimension{$instance_id.'.criterias'}},$id);
922: }
923: return '';
924: }
925:
1.4 albertel 926: sub proctor_validation_screen {
927: my ($slot) = @_;
928: my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
1.5 albertel 929: my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg');
1.11 albertel 930: $user=$env{'form.proctorname'};
931: if ($env{'form.proctordomain'}) { $domain=$env{'form.proctordomain'}; }
1.4 albertel 932: my $msg;
1.11 albertel 933: if ($env{'form.proctorpassword'}) {
1.4 albertel 934: $msg='<p><font color="red">'.&mt("Failed to authenticate the proctor.")
935: .'</font></p>';
936: }
937: my $result= (<<ENDCHECKOUT);
938: <h2>Proctor Validation</h2>
939: <p>Your room's proctor needs to validate your access to this resource.</p>
940: $msg
1.11 albertel 941: <form name="checkout" method="POST" action="$env{'request.uri'}">
1.4 albertel 942: <input type="hidden" name="validate" value="yes" />
943: <input type="hidden" name="submitted" value="yes" />
944: <table>
945: <tr><td>Proctor's Username:</td><td><input type="string" name="proctorname" value="$user" /></td></tr>
946: <tr><td>Password:</td><td><input type="password" name="proctorpassword" value="" /></td></tr>
1.6 albertel 947: <tr><td>Proctor's Domain:</td><td><input type="string" name="proctordomain" value="$domain" /></td></tr>
1.4 albertel 948: </table>
949: <input type="submit" name="checkoutbutton" value="Validate" /><br />
950: Student who should be logged in is:<br />
1.5 albertel 951: <img src="$url" /><br />
1.4 albertel 952: </form>
953: ENDCHECKOUT
954: return $result;
955: }
956:
1.1 albertel 957: 1;
958: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>