1: # The LearningOnline Network with CAPA
2: # definition of tags that give a structure to a document
3: #
4: # $Id: bridgetask.pm,v 1.18 2005/05/06 20:26:35 albertel Exp $
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 );
40:
41: BEGIN {
42: &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Instance','InstanceText','Criteria','ClosingParagraph'));
43: }
44:
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=();
51: # list of all current Instance ids
52: @Apache::bridgetask::instance=();
53: # list of all Instance ids seen in this problem
54: @Apache::bridgetask::instancelist=();
55: # key of queud user data that we are currently grading
56: $Apache::bridgetask::queue_key='';
57: }
58:
59: sub proctor_check_auth {
60: my ($slot)=@_;
61: my $user=$env{'form.proctorname'};
62: my $domain=$env{'form.proctordomain'};
63:
64: my @allowed=split(",",$slot->{'proctor'});
65: foreach my $possible (@allowed) {
66: my ($puser,$pdom)=(split('@',$possible));
67: if ($puser eq $user && $pdom eq $domain) {
68: my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
69: if ($authhost ne 'no_host') {
70: $Apache::lonhomework::results{'resource.checkedin'}=
71: $user.'@'.$domain;
72: return 1;
73: }
74: }
75: }
76: return 0;
77: }
78:
79: sub add_previous_version_button {
80: my $result;
81: $result.=&mt(' Show a previously done version: [_1]','<select name="previousversion">
82: <option>Pick one</option>
83: </select>');
84: return $result;
85: }
86:
87: sub add_grading_button {
88: my $result;
89: $result.=' <input type="submit" name="gradeasubmission" value="'.
90: &mt("Get a submission to grade").'" />';
91: $result.='<input type="hidden" name="grade_target" value="webgrade" />';
92: return $result;
93: }
94:
95: sub start_Task {
96: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
97:
98: my ($status,$accessmsg,$slot);
99: if ($target ne 'webgrade') {
100: &Apache::structuretags::initialize_storage();
101: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
102: }
103:
104: $Apache::lonhomework::parsing_a_task=1;
105: #should get back a <html> or the neccesary stuff to start XML/MathML
106: my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
107: &Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
108:
109: if ($target eq 'web') {
110: $body_tag_start.=&add_previous_version_button();
111: if ($Apache::lonhomework::modifygrades) {
112: $body_tag_start.='<form name="gradesubmission" method="POST" action="';
113: my $uri=$env{'request.uri'};
114: if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
115: $body_tag_start.=$uri.'">'.&add_grading_button()."</form>";
116: }
117: }
118: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
119: $target eq 'tex') {
120: ($status,$accessmsg,my $slot_name,$slot) =
121: &Apache::lonhomework::check_task_access('0');
122: push(@Apache::inputtags::status,$status);
123: $Apache::inputtags::slot_name=$slot_name;
124: my $expression='$external::datestatus="'.$status.'";';
125: $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
126: &Apache::run::run($expression,$safeeval);
127: &Apache::lonxml::debug("Got $status");
128: if (( $status eq 'CLOSED' ) ||
129: ( $status eq 'BANNED') ||
130: ( $status eq 'UNAVAILABLE') ||
131: ( $status eq 'NOT_IN_A_SLOT') ||
132: ( $status eq 'NEEDS_CHECKIN') ||
133: ( $status eq 'INVALID_ACCESS')) {
134: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
135: if ( $target eq "web" ) {
136: $result.= $head_tag_start.'</head>'.$body_tag_start;
137: my $msg;
138: if ($status eq 'UNAVAILABLE') {
139: $msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>';
140: } elsif ($status eq 'NOT_IN_A_SLOT') {
141: $msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>';
142: } elsif ($status eq 'NEEDS_CHECKIN') {
143: $msg.='<h1>'.&mt('You need the Proctor to validate you.').
144: '</h1>'.&proctor_validation_screen($slot);
145: } elsif ($status ne 'NOT_YET_VIEWED') {
146: $msg.='<h1>'.&mt('Not open to be viewed').'</h1>';
147: }
148: if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
149: $msg.='The problem '.$accessmsg;
150: }
151: $result.=$msg.'<br />';
152: } elsif ($target eq 'tex') {
153: $result.='\begin{document}\noindent \vskip 1 mm \begin{minipage}{\textwidth}\vskip 0 mm';
154: if ($status eq 'UNAVAILABLE') {
155: $result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
156: } else {
157: $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
158: }
159: } elsif ($target eq 'grade') {
160: if ($status eq 'NEEDS_CHECKIN') {
161: if (&proctor_check_auth($slot)) {
162: #FIXME immeadiatly add this to the grading queue
163: # with slot->{'endtime'} for when grading can
164: # begin on this resource
165: }
166: }
167: }
168: } elsif ($target eq 'web') {
169: my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
170: $result.="$head_tag_start<title>$name</title></head>
171: $body_tag_start \n $form_tag_start".
172: '<input type="hidden" name="submitted" value="yes" />';
173: # if we are viewing someone else preserve that info
174: if (defined $env{'form.grade_symb'}) {
175: foreach my $field ('symb','courseid','domain','username') {
176: $result .= '<input type="hidden" name="grade_'.$field.
177: '" value="'.$env{"form.grade_$field"}.'" />'."\n";
178: }
179: }
180: }
181: } elsif ($target eq 'webgrade') {
182: $result.=$head_tag_start.$body_tag_start.$form_tag_start;
183: $result.=
184: '<input type="hidden" name="grade_target" value="webgrade" />';
185: $result.=&show_queue();
186: my $todo=&get_from_queue();
187: if ($todo) {
188: &setup_env_for_other_user($todo,$safeeval);
189: my ($symb,$uname,$udom)=&decode_queue_key($todo);
190: $result.="\n".'<table><tr><td>Found '.
191: &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'</td></tr></table>';
192: $result.='<input type="hidden" name="gradingkey" value="'.
193: &Apache::lonnet::escape($todo).'" />';
194: $Apache::bridgetask::queue_key=$todo;
195: &Apache::structuretags::initialize_storage();
196: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
197: $result.="\n".'<table width="100%" style="width:100%" border="1">';
198: } else {
199: $result.="\n".
200: '<table><tr><td>No user to be graded.</td></tr></table>';
201: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
202: }
203:
204: } else {
205: # page_start returned a starting result, delete it if we don't need it
206: $result = '';
207: }
208: return $result;
209: }
210:
211: sub end_Task {
212: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
213: my $result='';
214: my $status=$Apache::inputtags::status['-1'];
215: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
216: $target eq 'tex') {
217: if (
218: (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
219: ($target eq 'answer') || ($target eq 'tex')
220: ) {
221: if ($target eq 'web') {
222: if ($status eq 'CAN_ANSWER') {
223: $result.="\n".'<table border="1">'.
224: &Apache::inputtags::file_selector('0',"bridgetask","*",
225: 'portfolioonly').
226: "</table>";
227: $result.=&Apache::inputtags::gradestatus('0');
228: }
229: }
230: if ($target eq 'web' || $target eq 'webgrade') {
231: $result.=&Apache::lonxml::xmlend().'</html>';
232: }
233: }
234: if ($target eq 'grade') {
235: my $award='SUBMITTED';
236: &Apache::essayresponse::file_submission('0','bridgetask','portfiles',\$award);
237: if ($award eq 'SUBMITTED' &&
238: $Apache::lonhomework::results{"resource.0.bridgetask.portfiles"}) {
239: $Apache::lonhomework::results{"resource.0.tries"}=
240: 1+$Apache::lonhomework::history{"resource.0.tries"};
241: }
242: $Apache::lonhomework::results{"resource.0.award"}=$award;
243: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
244: &Apache::structuretags::finalize_storage();
245: if ($award eq 'SUBMITTED') {
246: &add_to_queue();
247: }
248: }
249: } elsif ($target eq 'webgrade') {
250: $result.="</table>\n<hr />";
251: $result.='<input type="submit" name="next" value="'.
252: &mt('Save & Next').'" /> ';
253: $result.='<input type="submit" name="end" value="'.
254: &mt('Save & Stop Grading').'" /> ';
255: $result.='<input type="submit" name="end" value="'.
256: &mt('Throw Away & Stop Grading').'" /> ';
257: $result.='</form>'.&Apache::loncommon::endbodytag().'</html>';
258: } elsif ($target eq 'meta') {
259: $result.='<parameter part="0" package="Task"></parameter>'."\n";
260: #$result.=&Apache::response::meta_part_order();
261: #$result.=&Apache::response::meta_response_order();
262: }
263: undef($Apache::lonhomework::parsing_a_task);
264: return $result;
265: }
266:
267: sub setup_env_for_other_user {
268: my ($queue_key,$safeeval)=@_;
269: my ($symb,$uname,$udom)=&decode_queue_key($queue_key);
270: $env{'form.grade_symb'}=$symb;
271: $env{'form.grade_domain'}=$udom;
272: $env{'form.grade_username'}=$uname;
273: $env{'form.grade_courseid'}=$env{'request.course.id'};
274: &Apache::lonxml::initialize_rndseed($safeeval);
275: }
276:
277: sub add_to_queue {
278: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
279: my $cnum=$env{'course.'.$cid.'.num'};
280: my $cdom=$env{'course.'.$cid.'.domain'};
281: my %data;
282: $data{"$symb\0queue\0$uname\@$udom"}=[$Apache::inputtags::slot_name];
283: &Apache::lonnet::put('gradingqueue',\%data,$cdom,$cnum);
284: }
285:
286: sub show_queue {
287: my $result;
288: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
289: my $cnum=$env{'course.'.$cid.'.num'};
290: my $cdom=$env{'course.'.$cid.'.domain'};
291: my $regexp="^$symb\0";
292: my %queue=&Apache::lonnet::dump('gradingqueue',$cdom,$cnum,$regexp);
293: $result.="\n<h3>Current Queue</h3><table><tr><th>resource</th><th>user</th><th>type</th><th>data</th></tr>";
294: foreach my $key (sort(keys(%queue))) {
295: if ($key=~/locked$/) {
296: my ($symb,$uname,$udom) = &decode_queue_key($key);
297: my $title=&Apache::lonnet::gettitle($symb);
298: $result.="<tr><td>$title</td><td>$uname</td><td>";
299: $result.='<td>lock</td><td>'.$queue{$key}.'</td></tr>';
300: } elsif ($key=~/timestamp$/) {
301: my ($symb,undef) = split("\0",$key);
302: my $title=&Apache::lonnet::gettitle($symb);
303: $result.="<tr><td>$title</td><td></td><td>";
304: $result.='<td>last queue modification time</td><td>'.
305: &Apache::lonlocal::locallocaltime($queue{$key})."</td></tr>";
306: } else {
307: my ($symb,$uname,$udom) = &decode_queue_key($key);
308: my $title=&Apache::lonnet::gettitle($symb);
309: $result.="<tr><td>$title</td><td>$uname</td><td>";
310: my $slot=$queue{$key}->[0];
311: my %slot_data=&Apache::lonnet::get_slot($slot);
312: $result.='<td>queue entry</td><td>End time: '.&Apache::lonlocal::locallocaltime($slot_data{'endtime'})."</td></tr>";
313: }
314: }
315: $result.="</table><hr />\n";
316: return $result;
317: }
318:
319: sub decode_queue_key {
320: my ($key)=@_;
321: my ($symb,undef,$user) = split("\0",$key);
322: my ($uname,$udom) = split('@',$user);
323: return ($symb,$uname,$udom);
324: }
325:
326: sub queue_key_locked {
327: my ($key,$cdom,$cnum)=@_;
328: my ($key_locked,$value)=
329: &Apache::lonnet::get('gradingqueue',["$key\0locked"],$cdom,$cnum);
330: if ($key_locked eq "$key\0locked") {
331: return $value;
332: }
333: return undef;
334: }
335:
336: sub pick_from_queue_data {
337: my ($check_section,$queue,$cdom,$cnum)=@_;
338: foreach my $key (keys(%$queue)) {
339: my ($symb,$uname,$udom)=&decode_queue_key($key);
340: if ($check_section) {
341: my $section=&Apache::lonnet::getsection($uname,$udom);
342: if ($section eq $check_section) {
343: &Apache::lonnet::logthis("my sec");
344: next;
345: }
346: }
347: my $slot=$queue->{$key}[0];
348: my %slot_data=&Apache::lonnet::get_slot($slot);
349: if ($slot_data{'endtime'} > time) {
350: &Apache::lonnet::logthis("not time");
351: next;
352: }
353: if (&queue_key_locked($key,$cdom,$cnum)) {
354: &Apache::lonnet::logthis("someone already has um.");
355: next;
356: }
357: return $key;
358: }
359: return undef;
360: }
361:
362: sub find_mid_grade {
363: my ($symb,$cdom,$cnum)=@_;
364: my $todo=&Apache::lonnet::unescape($env{'form.gradingkey'});
365: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
366: if ($todo) {
367: my $who=&queue_key_locked($todo,$cdom,$cnum);
368: if ($who eq $me) { return $todo; }
369: }
370: my $regexp="^$symb\0.*\0locked\$";
371: my %locks=&Apache::lonnet::dump('gradingqueue',$cdom,$cnum,$regexp);
372: foreach my $key (keys(%locks)) {
373: my $who=$locks{$key};
374: if ($who eq $me) {
375: $todo=$key;
376: $todo=~s/\0locked$//;
377: return $todo;
378: }
379: }
380: return undef;
381: }
382:
383: sub get_from_queue {
384: my $result;
385: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
386: my $cnum=$env{'course.'.$cid.'.num'};
387: my $cdom=$env{'course.'.$cid.'.domain'};
388: my $todo;
389: # FIXME need to find if I am 'mid grading'
390: $todo=&find_mid_grade($symb,$cdom,$cnum);
391: &Apache::lonnet::logthis("found ".join(':',&decode_queue_key($todo)));
392: if ($todo) { return $todo; }
393: while (1) {
394: my $starttime=time;
395: &Apache::lonnet::put('gradingqueue',{"$symb\0timestamp"=>$starttime},
396: $cdom,$cnum);
397: &Apache::lonnet::logthis("$starttime");
398: my $regexp="^$symb\0queue\0";
399: my %queue=&Apache::lonnet::dump('gradingqueue',$cdom,$cnum,$regexp);
400: #make a pass looking for a user in my section
401: if ($env{'request.course.sec'}) {
402: &Apache::lonnet::logthis("sce");
403: $todo=&pick_from_queue_data($env{'request.course.sec'},\%queue,
404: $cdom,$cnum);
405: &Apache::lonnet::logthis("sce $todo");
406: }
407: # no one in our section so look for any user that is ready for grading
408: if (!$todo) {
409: &Apache::lonnet::logthis("no sce");
410: $todo=&pick_from_queue_data($env{'request.course.sec'},\%queue,
411: $cdom,$cnum);
412: &Apache::lonnet::logthis("no sce $todo");
413: }
414: # no user to grade
415: if (!$todo) { last; }
416: &Apache::lonnet::logthis("got $todo");
417: # otherwise found someone so lets try to lock them
418: my $success=&Apache::lonnet::newput('gradingqueue',
419: {"$todo\0locked"=>
420: $env{'user.name'}.'@'.$env{'user.domain'}},
421: $cdom,$cnum);
422: # someone else already picked them
423: &Apache::lonnet::logthis("success $todo");
424: if ($success ne 'ok') { next; }
425: my (undef,$endtime)=
426: &Apache::lonnet::get('gradingqueue',["$symb\0timestamp"],
427: $cdom,$cnum);
428: &Apache::lonnet::logthis("emd $endtime");
429: # someone else already modified the queue,
430: # perhaps our picked user wass already fully graded between
431: # when we picked him and when we locked his record? so lets
432: # double check.
433: if ($endtime != $starttime) {
434: my ($key,$value)=
435: &Apache::lonnet::get('gradingqueue',["$todo"],
436: $cdom,$cnum);
437: &Apache::lonnet::logthis("check $key .. $value");
438: if ($key eq $todo && ref($value)) {
439: } else {
440: &Apache::lonnet::del('gradingqueue',["$todo\0locked"],
441: $cdom,$cnum);
442: &Apache::lonnet::logthis("del");
443: next;
444: }
445: }
446: &Apache::lonnet::logthis("last $todo");
447: last;
448: }
449: return $todo;
450: }
451:
452: sub start_ClosingParagraph {
453: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
454: my $result;
455: if ($target eq 'web') {
456: } elsif ($target eq 'webgrade') {
457: &Apache::lonxml::startredirection();
458: }
459: return $result;
460: }
461:
462: sub end_ClosingParagraph {
463: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
464: my $result;
465: if ($target eq 'web') {
466: } elsif ($target eq 'webgrade') {
467: &Apache::lonxml::endredirection();
468: }
469: return $result;
470: }
471:
472: my %dimension;
473: sub start_Dimension {
474: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
475: undef(%dimension);
476: my $dim_id=$Apache::lonxml::curdepth;
477: $Apache::bridgetask::dimension=$dim_id;
478: push(@Apache::bridgetask::dimensionlist,$dim_id);
479: undef(@Apache::bridgetask::instance);
480: return '';
481: }
482:
483: sub get_instance {
484: #FIXME just grabbing the first one for now, need
485: #to randomly pick one until all have been seen
486: #then start repicking
487: &Apache::response::pushrandomnumber();
488: my @order=&Math::Random::random_permutation(@{$dimension{'instances'}});
489: return $order[0];
490: }
491:
492: {
493: my $last_link;
494: sub end_Dimension {
495: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
496: my $result;
497: if ($target eq 'web') {
498: my $instance=&get_instance();
499: $result=$dimension{'intro'}.$dimension{$instance.'.text'};
500: } elsif ($target eq 'webgrade') {
501: my $instance=&get_instance();
502: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
503: my $link='criteria_'.$instance.'_'.$id;
504: $result.='<tr><td valign="top">'.
505: '<a name="'.$link.'" />'.
506: '<a name="next_'.$last_link.'" />'.
507: '<br /><textarea enabled="false" style="width:100%" rows="8" width="25" wrap="hard">'.$dimension{$instance.'.criteria.'.$id}.'</textarea>'.
508: #$dimension{$instance.'.criteria.'.$id}.
509: '</td>'.
510: '<td>Additional Comment for Student <br />'.
511: '<textarea style="width:100%" rows="8" width="25" wrap="hard" name="HWVAL_comment_'.$link.'"></textarea>'.
512: '</td>'.
513: '<td>'.
514: '<label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" />Ungraded</label><br />'.
515: '<label><input type="radio" name="HWVAL_'.$link.'" value="pass" />Pass</label><br />'.
516: '<label><input type="radio" name="HWVAL_'.$link.'" value="fail" />Fail</label><br />'.
517: '<label><input type="radio" name="HWVAL_'.$link.'" value="review" />Review</label><br />'.
518: '</td>'.
519: '<td>'.
520: '<a href="#'.$last_link.'">Prev</a><br />'.
521: '<a href="#next_'.$link.'">Next</a><br />'.
522: '</td></tr>';
523: $last_link=$link;
524: }
525: }
526: return $result;
527: }
528: }
529:
530: sub start_IntroParagraph {
531: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
532: my $result;
533: if ($target eq 'web' || $target eq 'webgrade') {
534: if ($tagstack->[-2] eq 'Dimension' || $target eq 'webgrade') {
535: &Apache::lonxml::startredirection();
536: }
537: }
538: return $result;
539: }
540:
541: sub end_IntroParagraph {
542: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
543: my $result;
544: if ($target eq 'web' || $target eq 'webgrade') {
545: if ($tagstack->[-2] eq 'Dimension' || $target eq 'webgrade') {
546: $dimension{'intro'}=&Apache::lonxml::endredirection();
547: }
548: }
549: return $result;
550: }
551:
552: sub start_Instance {
553: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
554: push(@{$dimension{'instances'}},$Apache::lonxml::curdepth);
555: push(@Apache::bridgetask::instance,$Apache::lonxml::curdepth);
556: push(@Apache::bridgetask::instancelist,$Apache::lonxml::curdepth);
557: return '';
558: }
559:
560: sub end_Instance {
561: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
562: return '';
563: }
564:
565: sub start_InstanceText {
566: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
567: if ($target eq 'web' || $target eq 'webgrade') {
568: &Apache::lonxml::startredirection();
569: }
570: return '';
571: }
572:
573: sub end_InstanceText {
574: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
575: my $instance_id=$Apache::bridgetask::instance[-1];
576: if ($target eq 'web' || $target eq 'webgrade') {
577: $dimension{$instance_id.'.text'}=&Apache::lonxml::endredirection();
578: }
579: return '';
580: }
581:
582: sub start_Criteria {
583: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
584: if ($target eq 'web' || $target eq 'webgrade') {
585: &Apache::lonxml::startredirection();
586: }
587: return '';
588: }
589:
590: sub end_Criteria {
591: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
592: my $instance_id=$Apache::bridgetask::instance[-1];
593: if ($target eq 'web' || $target eq 'webgrade') {
594: my $criteria=&Apache::lonxml::endredirection();
595: my $id=$Apache::lonxml::curdepth;
596: $dimension{$instance_id.'.criteria.'.$id}=$criteria;
597: push(@{$dimension{$instance_id.'.criterias'}},$id);
598: }
599: return '';
600: }
601:
602: sub proctor_validation_screen {
603: my ($slot) = @_;
604: my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
605: my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg');
606: $user=$env{'form.proctorname'};
607: if ($env{'form.proctordomain'}) { $domain=$env{'form.proctordomain'}; }
608: my $msg;
609: if ($env{'form.proctorpassword'}) {
610: $msg='<p><font color="red">'.&mt("Failed to authenticate the proctor.")
611: .'</font></p>';
612: }
613: my $result= (<<ENDCHECKOUT);
614: <h2>Proctor Validation</h2>
615: <p>Your room's proctor needs to validate your access to this resource.</p>
616: $msg
617: <form name="checkout" method="POST" action="$env{'request.uri'}">
618: <input type="hidden" name="validate" value="yes" />
619: <input type="hidden" name="submitted" value="yes" />
620: <table>
621: <tr><td>Proctor's Username:</td><td><input type="string" name="proctorname" value="$user" /></td></tr>
622: <tr><td>Password:</td><td><input type="password" name="proctorpassword" value="" /></td></tr>
623: <tr><td>Proctor's Domain:</td><td><input type="string" name="proctordomain" value="$domain" /></td></tr>
624: </table>
625: <input type="submit" name="checkoutbutton" value="Validate" /><br />
626: Student who should be logged in is:<br />
627: <img src="$url" /><br />
628: </form>
629: ENDCHECKOUT
630: return $result;
631: }
632:
633: 1;
634: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>