Annotation of loncom/homework/bridgetask.pm, revision 1.56
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # definition of tags that give a structure to a document
3: #
1.56 ! albertel 4: # $Id: bridgetask.pm,v 1.55 2005/09/29 19:18:37 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.22 albertel 63: my ($slot_name,$slot)=@_;
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.11 albertel 71: my $authhost=&Apache::lonnet::authenticate($puser,$env{'form.proctorpassword'},$pdom);
1.4 albertel 72: if ($authhost ne 'no_host') {
1.23 albertel 73: my $version=
74: $Apache::lonhomework::results{'resource.version'}=
1.27 albertel 75: ++$Apache::lonhomework::history{'resource.version'};
1.23 albertel 76: $Apache::lonhomework::results{"resource.$version.checkedin"}=
1.4 albertel 77: $user.'@'.$domain;
1.23 albertel 78: $Apache::lonhomework::results{"resource.$version.checkedin.slot"}=
1.22 albertel 79: $slot_name;
1.28 albertel 80: foreach my $key (keys(%Apache::lonhomework::history)) {
81: if ($key=~/^resource\.0\./) {
82: $Apache::lonhomework::results{$key}='';
83: }
84: }
1.4 albertel 85: return 1;
86: }
87: }
88: }
89: return 0;
90: }
91:
1.25 albertel 92: sub get_version {
1.29 albertel 93: my ($version,$previous);
1.25 albertel 94: if ($env{'form.previousversion'} &&
1.36 albertel 95: $env{'form.previousversion'} ne 'current' &&
1.25 albertel 96: defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) {
1.29 albertel 97: $version=$env{'form.previousversion'};
98: $previous=1;
99: } else {
100: $version=$Apache::lonhomework::history{'resource.version'};
101: $previous=0;
102: }
103: if (wantarray) {
104: return ($version,$previous);
1.25 albertel 105: }
1.29 albertel 106: return $version;
1.25 albertel 107: }
108:
1.8 albertel 109: sub add_previous_version_button {
1.25 albertel 110: my ($status)=@_;
1.8 albertel 111: my $result;
1.29 albertel 112: if ($Apache::lonhomework::history{'resource.version'} eq '') {
1.25 albertel 113: return '';
114: }
1.29 albertel 115: if ($Apache::lonhomework::history{'resource.version'} < 2 &&
116: $status ne 'NEEDS_CHECKIN') {
1.25 albertel 117: return '';
118: }
1.29 albertel 119: my $version=&get_version();
120: if ($env{'form.previousversion'} ne '' &&
121: $env{'form.previousversion'} eq $version) {
122: $result.="<h3>".&mt("Showing previous version [_1]",$version).
123: "</h3>\n";
124: }
125: my @to_show;
126: foreach my $test_version (1..$Apache::lonhomework::history{'resource.version'}) {
127: if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.status'})) {
128: push(@to_show,$test_version);
129: }
130: }
131: my $list='<option>'.
132: join("</option>\n<option>",@to_show).
133: "</option>\n";
1.36 albertel 134: $list.='<option value="current">'.&mt('Current').'</option>';
1.29 albertel 135: $result.='<form name="getprevious" method="POST" action="';
136: my $uri=$env{'request.uri'};
137: if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
138: $result.=$uri.'">'.
139: &mt(' Show a previously done version: [_1]','<select onchange="this.form.submit()" name="previousversion">
140: <option>'.&mt('Pick one').'</option>
141: '.$list.'
142: </select>')."</form>";
1.8 albertel 143: return $result;
144: }
145:
1.13 albertel 146: sub add_grading_button {
1.29 albertel 147: my $result=' <input type="submit" name="gradeasubmission" value="'.
1.13 albertel 148: &mt("Get a submission to grade").'" />';
149: $result.='<input type="hidden" name="grade_target" value="webgrade" />';
1.40 albertel 150: if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
1.34 albertel 151: my ($entries,$ready,$locks)=&get_queue_counts('gradingqueue');
152: $result.='<p>'.&mt("Grading Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
153:
154: $result.=' <input type="submit" name="reviewagrading" value="'.
155: &mt("Select an entry from the grading queue").'" /> </p>'."\n";
156:
157: ($entries,$ready,$locks)=&get_queue_counts('reviewqueue');
158: $result.='<p>'.&mt("Review Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
1.32 albertel 159: $result.=' <input type="submit" name="reviewasubmission" value="'.
1.34 albertel 160: &mt("Select an entry from the review queue").'" /> </p>'."\n";
1.49 albertel 161: $result.=' <input type="submit" name="regradeasubmission" value="'.
162: &mt("Select a user to regrade.").'" /> </p>'."\n";
1.32 albertel 163: }
1.13 albertel 164: return $result;
165: }
166:
1.22 albertel 167: sub add_request_another_attempt_button {
1.38 albertel 168: my ($text)=@_;
169: if (!$text) { $text="Request another attempt"; }
1.25 albertel 170: my $result;
1.36 albertel 171: my $symb=&Apache::lonnet::symbread();
1.37 albertel 172: my ($slot_name,$slot)=&Apache::slotrequest::check_for_reservation($symb);
1.38 albertel 173: my $action='get_reservation';
1.37 albertel 174: if ($slot_name) {
1.38 albertel 175: $text="Change reservation.";
176: $action='change_reservation';
1.37 albertel 177: my $description=&Apache::slotrequest::get_description($slot_name,
178: $slot);
179: $result.=(<<STUFF);
180: <p> Will be next available: $description </p>
181: STUFF
182: }
1.38 albertel 183:
184: if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); }
185: $symb=&Apache::lonnet::escape($symb);
186: $result.='<form method="POST" action="/adm/slotrequest">'.
187: '<input type="hidden" name="symb" value="'.$symb.'" />'.
188: '<input type="hidden" name="command" value="'.$action.'" />'.
189: '<input type="submit" name="requestattempt" value="'.
190: &mt($text).'" />'.
191: '</form>';
1.25 albertel 192: return $result;
1.22 albertel 193: }
194:
1.30 albertel 195: sub preserve_grade_info {
196: my $result;
197: # if we are viewing someone else preserve that info
198: if (defined $env{'form.grade_symb'}) {
199: foreach my $field ('symb','courseid','domain','username') {
200: $result .= '<input type="hidden" name="grade_'.$field.
201: '" value="'.$env{"form.grade_$field"}.'" />'."\n";
202: }
203: }
204: return $result;
205: }
206:
1.53 albertel 207: sub style {
208: return (<<STYLE);
209: <style type="text/css">
210: .fail, .pass, .neutral {
211: position: relative;
212: margin : 5px;
213: margin-bottom :10px;
214: padding : 4px;
215: padding-left : 75px;
216: border : thin solid;
217: font-weight : bolder;
218: font-size: smaller;
219: font-family: Arial;
220: background-color : rgb(255,240,225);
221: }
222:
223: .fail h4, .pass h4 {
224: position:absolute;
225: left: -4px;
226: top: -8px;
227: padding:2px;
228: margin:0;
229: background-color : rgb(255,240,225);
230: border : thin solid;
231: }
232:
233: .fail {
234: color: red;
235: }
236:
237: .pass {
238: color : green;
239: }
240:
241: .neutral {
242: color : blue;
243: }
244:
245: .question {
246: border : thin solid black;
247: padding : 4px;
248: margin-bottom : 1em;
249: }
250:
251: .grade {
252: font-size: x-large;
253: font-family: Arial;
254: position:absolute;
255: left: 5px;
256: top: -5px;
257: width: 70px;
258: }
259:
260: div#feedback h1 {
261: color : inherit;
262: }
263: </style>
264: STYLE
265:
266: }
267:
1.54 albertel 268: sub show_task {
269: my ($status,$previous)=@_;
270: if (!$previous && (
271: ( $status eq 'CLOSED' ) ||
272: ( $status eq 'BANNED') ||
273: ( $status eq 'UNAVAILABLE') ||
274: ( $status eq 'NOT_IN_A_SLOT') ||
275: ( $status eq 'NEEDS_CHECKIN') ||
276: ( $status eq 'WAITING_FOR_GRADE') ||
277: ( $status eq 'INVALID_ACCESS') )) {
278: return 0;
279: }
280: return 1;
281: }
282:
283: sub internal_location {
284: my ($id)=@_;
285: return '<!-- LONCAPA_INTERNAL_ADD_TASK_STATUS'.$id.' -->';
286: }
287:
1.1 albertel 288: sub start_Task {
289: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
290:
1.4 albertel 291: my ($status,$accessmsg,$slot);
1.16 albertel 292: if ($target ne 'webgrade') {
293: &Apache::structuretags::initialize_storage();
294: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
295: }
296:
1.4 albertel 297: $Apache::lonhomework::parsing_a_task=1;
1.1 albertel 298: #should get back a <html> or the neccesary stuff to start XML/MathML
299: my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
300: &Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
1.16 albertel 301:
1.8 albertel 302: if ($target eq 'web') {
1.13 albertel 303: if ($Apache::lonhomework::modifygrades) {
304: $body_tag_start.='<form name="gradesubmission" method="POST" action="';
305: my $uri=$env{'request.uri'};
306: if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
307: $body_tag_start.=$uri.'">'.&add_grading_button()."</form>";
1.38 albertel 308: my $symb=&Apache::lonnet::symbread();
1.40 albertel 309: if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
310: $body_tag_start.='<form method="POST" action="/adm/slotrequest">'.
311: '<input type="hidden" name="symb" value="'.$symb.'" />'.
312: '<input type="hidden" name="command" value="showslots" />'.
313: '<input type="submit" name="requestattempt" value="'.
314: &mt('Show Slot list').'" />'.
315: '</form>';
316: }
1.13 albertel 317: }
1.8 albertel 318: }
1.21 albertel 319: if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
1.1 albertel 320: $target eq 'tex') {
1.29 albertel 321: my ($version,$previous)=&get_version();
1.14 albertel 322: ($status,$accessmsg,my $slot_name,$slot) =
1.4 albertel 323: &Apache::lonhomework::check_task_access('0');
1.9 albertel 324: push(@Apache::inputtags::status,$status);
1.14 albertel 325: $Apache::inputtags::slot_name=$slot_name;
1.1 albertel 326: my $expression='$external::datestatus="'.$status.'";';
1.23 albertel 327: $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$version.solved"}.'";';
1.1 albertel 328: &Apache::run::run($expression,$safeeval);
329: &Apache::lonxml::debug("Got $status");
1.25 albertel 330: $body_tag_start.=&add_previous_version_button($status);
1.54 albertel 331: if (!&show_task($status,$previous)) {
1.1 albertel 332: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
333: if ( $target eq "web" ) {
1.4 albertel 334: $result.= $head_tag_start.'</head>'.$body_tag_start;
335: my $msg;
1.1 albertel 336: if ($status eq 'UNAVAILABLE') {
337: $msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>';
1.3 albertel 338: } elsif ($status eq 'NOT_IN_A_SLOT') {
339: $msg.='<h1>'.&mt('You are not currently signed up to work at this time and/or place.').'</h1>';
1.38 albertel 340: $msg.=&add_request_another_attempt_button("Sign up for time to work.");
1.4 albertel 341: } elsif ($status eq 'NEEDS_CHECKIN') {
342: $msg.='<h1>'.&mt('You need the Proctor to validate you.').
343: '</h1>'.&proctor_validation_screen($slot);
1.22 albertel 344: } elsif ($status eq 'WAITING_FOR_GRADE') {
345: $msg.='<h1>'.&mt('Your submission is in the grading queue.').'</h1>';
1.1 albertel 346: } elsif ($status ne 'NOT_YET_VIEWED') {
347: $msg.='<h1>'.&mt('Not open to be viewed').'</h1>';
348: }
349: if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
350: $msg.='The problem '.$accessmsg;
351: }
352: $result.=$msg.'<br />';
353: } elsif ($target eq 'tex') {
354: $result.='\begin{document}\noindent \vskip 1 mm \begin{minipage}{\textwidth}\vskip 0 mm';
355: if ($status eq 'UNAVAILABLE') {
356: $result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
357: } else {
358: $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
359: }
1.22 albertel 360: } elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
1.4 albertel 361: if ($status eq 'NEEDS_CHECKIN') {
1.41 albertel 362: &proctor_check_auth($slot_name,$slot);
1.4 albertel 363: }
1.1 albertel 364: }
365: } elsif ($target eq 'web') {
366: my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
367: $result.="$head_tag_start<title>$name</title></head>
1.53 albertel 368: $body_tag_start \n".&style();
1.36 albertel 369:
370: $result.=$form_tag_start.
371: '<input type="hidden" name="submitted" value="yes" />';
372: $result.=&preserve_grade_info();
1.54 albertel 373: $result.=&internal_location();
374: &Apache::lonxml::startredirection();
1.1 albertel 375: }
1.21 albertel 376: } elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
377: $target eq 'webgrade') {
1.32 albertel 378: my $webgrade='yes';
1.21 albertel 379: if ($target eq 'webgrade') {
1.32 albertel 380: $result.=$head_tag_start.$body_tag_start;
1.49 albertel 381: #$result.='<br />Review'.&show_queue('reviewqueue');
382: #$result.='<br />Grade'.&show_queue('gradingqueue');
1.30 albertel 383: }
1.33 albertel 384: # FIXME Blast! still need to reorg this, need to reshow the
385: # queue being reviewed once done with the grade pass...
386: # Hrrm, vaildation pass should perhaps say 'not_locked'
387: # perhaps do a search if there is a key that is mine and if
388: # there isn't reshow the queue....
389: my ($todo,$status_code)=&get_key_todo($target);
390:
391: if ($todo) {
392: &setup_env_for_other_user($todo,$safeeval);
393: my ($symb,$uname,$udom)=&decode_queue_key($todo);
394: $result.="\n".'<table><tr><td>Found '.
395: &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'</td></tr></table>';
396: $form_tag_start.=
397: '<input type="hidden" name="gradingkey" value="'.
398: &Apache::lonnet::escape($todo).'" />';
399: $Apache::bridgetask::queue_key=$todo;
400: &Apache::structuretags::initialize_storage();
401: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
402: if ($target eq 'webgrade') {
1.49 albertel 403: #$result.='<br />After -'.&show_queue($env{'form.queue'});
1.33 albertel 404: $result.="\n".'<table width="100%" style="width:100%" border="1">';
405: if ($status_code eq 'selected') {
406: $form_tag_start.=
407: '<input type="hidden" name="queuemode" value="selected" />';
408: }
409: }
1.15 albertel 410: } else {
1.33 albertel 411: if ($target eq 'webgrade') {
412: $result.="\n";
413: if ($status_code eq 'stop') {
414: $result.='<b>'.&mt("Stopped grading.").'</b>';
415: } elsif ($status_code eq 'lock_failed') {
416: $result.='<b>'.&mt("Failed to lock the request record.").'</b>';
417: } elsif ($status_code eq 'unlock') {
418: $result.='<b>'.&mt("Unlocked the requested record.").'</b>';
419: $result.=&show_queue($env{'form.queue'},1);
420: } elsif ($status_code eq 'show_list') {
421: $result.=&show_queue($env{'form.queue'},1);
1.49 albertel 422: } elsif ($status_code eq 'select_user') {
423: $result.=&select_user();
1.33 albertel 424: } else {
425: $result.='<b>'.&mt("No user to be graded.").'</b>';
1.32 albertel 426: }
1.21 albertel 427: }
1.33 albertel 428: $webgrade='no';
429: my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
1.32 albertel 430: }
431: if ($target eq 'webgrade' && defined($env{'form.queue'})) {
432: $result.=$form_tag_start;
433: $result.='<input type="hidden" name="webgrade" value="'.
434: $webgrade.'" />';
435: $result.='<input type="hidden" name="queue" value="'.
436: $env{'form.queue'}.'" />';
1.52 albertel 437: if ($env{'form.regrade'}) {
438: $result.='<input type="hidden" name="regrade" value="'.
439: $env{'form.regrade'}.'" />';
440: }
1.15 albertel 441: }
1.1 albertel 442: } else {
443: # page_start returned a starting result, delete it if we don't need it
444: $result = '';
445: }
446: return $result;
447: }
448:
1.32 albertel 449: sub get_key_todo {
450: my ($target)=@_;
451: my $todo;
1.33 albertel 452:
453: if (defined($env{'form.reviewasubmission'})) {
1.54 albertel 454: &Apache::lonxml::debug("review a submission....");
1.33 albertel 455: $env{'form.queue'}='reviewqueue';
456: return (undef,'show_list');
457: }
458:
459: if (defined($env{'form.reviewagrading'})) {
460: &Apache::lonxml::debug("review a grading....");
461: $env{'form.queue'}='gradingqueue';
462: return (undef,'show_list');
463: }
464:
1.49 albertel 465: if (defined($env{'form.regradeasubmission'})) {
466: &Apache::lonxml::debug("regrade a grading....");
467: $env{'form.queue'}='none';
468: return (undef,'select_user');
469: }
470:
1.32 albertel 471: my $queue=$env{'form.queue'};
1.33 albertel 472:
1.32 albertel 473: if (!defined($queue)) {
474: $env{'form.queue'}=$queue='gradingqueue';
475: }
1.33 albertel 476:
1.32 albertel 477: my $gradingkey=&Apache::lonnet::unescape($env{'form.gradingkey'});
1.33 albertel 478:
1.49 albertel 479: if ($env{'form.queue'} eq 'none') {
480: if (defined($env{'form.gradingkey'})) {
481: if ($target eq 'webgrade') {
482: if ($env{'form.stop'}) {
483: return (undef,'stop');
484: } elsif ($env{'form.next'}) {
485: return (undef,'show_list');
486: }
487: }
488: return ($gradingkey,'selected');
489: } else {
490: return (undef,'show_list');
491: }
492: }
1.32 albertel 493: if (defined($env{'form.queue'}) && defined($env{'form.gradingkey'})
1.33 albertel 494: && !defined($env{'form.gradingaction'})
495: && $env{'form.queuemode'} eq 'selected') {
496:
497: my $who=&queue_key_locked($queue,$gradingkey);
498: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
499: if ($who eq $me) {
500: &Apache::lonxml::debug("Found a key was given to me");
501: return ($gradingkey,'selected');
502: } else {
503: return (undef,'show_list');
504: }
505:
506: }
507:
508: if ($target eq 'webgrade' && $env{'form.queuemode'} eq 'selected') {
509: if ($env{'form.gradingaction'} eq 'resume') {
510: delete($env{'form.gradingaction'});
511: &Apache::lonxml::debug("Resuming a key");
1.32 albertel 512: return ($gradingkey);
1.33 albertel 513: } elsif ($env{'form.gradingaction'} eq 'unlock') {
514: &Apache::lonxml::debug("Unlocking a key ".
515: &check_queue_unlock($queue,$gradingkey,1));
516: return (undef,'unlock');
517: } elsif ($env{'form.gradingaction'} eq 'select') {
518: &Apache::lonxml::debug("Locking a key");
519: if (&lock_key($queue,$gradingkey)) {
520: &Apache::lonxml::debug("Success $queue");
521: return ($gradingkey);
522: }
523: &Apache::lonxml::debug("Failed $queue");
524: return (undef,'lock_failed');
1.32 albertel 525: }
526: }
1.33 albertel 527:
528: if ($env{'form.queuemode'} ne 'selected') {
529: # don't get something new from the queue if they hit the stop button
530: if (!($env{'form.stop'} && $target eq 'webgrade')
531: && !$env{'form.gradingaction'}) {
532: &Apache::lonxml::debug("Getting anew $queue");
533: return (&get_from_queue($queue));
534: } else {
535: return (undef,'stop');
536: }
1.32 albertel 537: }
1.33 albertel 538: return (undef,undef)
1.32 albertel 539: }
540:
1.1 albertel 541: sub end_Task {
542: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
543: my $result='';
544: my $status=$Apache::inputtags::status['-1'];
1.29 albertel 545: my ($version,$previous)=&get_version();
1.1 albertel 546: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
1.15 albertel 547: $target eq 'tex') {
1.1 albertel 548: if (
1.11 albertel 549: (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
1.1 albertel 550: ($target eq 'answer') || ($target eq 'tex')
551: ) {
552: if ($target eq 'web') {
1.54 albertel 553: if (&show_task($status,$previous)) {
554: $result.=&Apache::lonxml::endredirection();
555: }
1.29 albertel 556: if ($status eq 'CAN_ANSWER' && !$previous) {
1.15 albertel 557: $result.="\n".'<table border="1">'.
1.28 albertel 558: &Apache::inputtags::file_selector("$version.0",
559: "bridgetask","*",
1.46 albertel 560: 'portfolioonly',
561: '
562: <h2>'.&mt('Submit Portfolio Files for Grading').'</h2>
563: <p>'.&mt('Indicate the files from your portfolio to be evaluated in grading this task.').'</p>').
1.9 albertel 564: "</table>";
565: $result.=&Apache::inputtags::gradestatus('0');
566: }
1.56 ! albertel 567: if (&show_task($status,$previous) &&
! 568: $Apache::lonhomework::history{"resource.$version.status"} =~ /^(pass|fail)$/) {
1.54 albertel 569: my $bt_status=$Apache::lonhomework::history{"resource.$version.status"};
570: my $title=&Apache::lonnet::gettitle();
571: my %slot=&Apache::lonnet::get_slot($Apache::inputtags::slot_name);
1.55 albertel 572: my $start_time=
573: &Apache::lonlocal::locallocaltime($slot{'starttime'});
1.54 albertel 574:
575: my $status;
576: $status.="\n<div class='$bt_status'>\n";
577:
578: if ($bt_status eq 'pass') {
579: $status.='<h2>You passed the '.$title.' given on '.
1.55 albertel 580: $start_time.'.</h2>';
1.54 albertel 581: }
582: if ($bt_status eq 'fail') {
583: $status.='<h2>You did not pass the '.$title.' given on '.
1.55 albertel 584: $start_time.'.</h2>';
1.54 albertel 585: if (!$previous) {
586: $status.=&add_request_another_attempt_button();
587: }
588: }
589: my $man_count=0;
590: my $opt_count=0;
591: my $opt_passed=0;
592: foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
593: if ($Apache::bridgetask::dimensionmandatory{$dim_id}
594: eq 'N') {
595: $opt_count++;
596: if ($Apache::lonhomework::history{"resource.$version.$dim_id.status"} eq 'pass') {
597: $opt_passed++;
598: }
599: } else {
600: $man_count++;
601: }
602: }
603: my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
604: $parstack,$safeeval);
605: if ($opt_req !~ /\S/) { $opt_req='0'; }
606: $status.="\n<p>".&mt('You needed to pass all of the [_1] mandatory components and [_2] of the [_3] optional components on the bridge task.',$man_count,$opt_req,$opt_count)."</p></div>\n";
607:
608: my $internal_location=&internal_location();
609: $result=~s/\Q$internal_location\E/$status/;
610: }
1.13 albertel 611: }
612: if ($target eq 'web' || $target eq 'webgrade') {
1.1 albertel 613: $result.=&Apache::lonxml::xmlend().'</html>';
614: }
615: }
1.29 albertel 616: if ($target eq 'grade' && !$env{'form.webgrade'} && !$previous) {
1.12 albertel 617: my $award='SUBMITTED';
1.28 albertel 618: &Apache::essayresponse::file_submission("$version.0",'bridgetask',
1.20 albertel 619: 'portfiles',\$award);
1.14 albertel 620: if ($award eq 'SUBMITTED' &&
1.28 albertel 621: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}) {
622: $Apache::lonhomework::results{"resource.0.tries"}=
623: $Apache::lonhomework::results{"resource.$version.0.tries"}=
624: 1+$Apache::lonhomework::history{"resource.$version.0.tries"};
625:
626: $Apache::lonhomework::results{"resource.0.award"}=
627: $Apache::lonhomework::results{"resource.$version.0.award"}=
628: $award;
1.51 albertel 629: $Apache::lonhomework::results{"resource.0.submission"}=
630: $Apache::lonhomework::results{"resource.$version.0.submission"}='';
1.10 albertel 631: }
1.4 albertel 632: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
633: &Apache::structuretags::finalize_storage();
1.14 albertel 634: if ($award eq 'SUBMITTED') {
1.31 albertel 635: &add_to_queue('gradingqueue',$Apache::inputtags::slot_name);
1.14 albertel 636: }
1.1 albertel 637: }
1.32 albertel 638: if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
1.20 albertel 639: my $optional_required=
640: &Apache::lonxml::get_param('OptionalRequired',$parstack,
641: $safeeval);
642: my $optional_passed=0;
643: my $mandatory_failed=0;
644: my $ungraded=0;
645: my $review=0;
1.21 albertel 646: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
1.20 albertel 647: foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
648: my $status=
1.25 albertel 649: $Apache::lonhomework::results{"resource.$version.$dim_id.status"};
1.20 albertel 650: my $mandatory=
651: ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
652: if ($status eq 'pass') {
653: if (!$mandatory) { $optional_passed++; }
654: } elsif ($status eq 'fail') {
655: if ($mandatory) { $mandatory_failed++; }
656: } elsif ($status eq 'ungraded') {
657: $ungraded++;
658: } elsif ($status eq 'review') {
659: $review++;
1.49 albertel 660: } else {
661: $ungraded++;
662: }
1.20 albertel 663: }
664: if ($optional_passed < $optional_required) {
665: $mandatory_failed++;
666: }
1.21 albertel 667: &Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
668: $Apache::lonhomework::results{'resource.grader'}=
1.20 albertel 669: $env{'user.name'}.'@'.$env{'user.domain'};
670: if ($review) {
1.25 albertel 671: $Apache::lonhomework::results{"resource.$version.status"}='review';
1.33 albertel 672: if ($env{'form.queue'} eq 'reviewqueue') {
673: &check_queue_unlock($env{'form.queue'});
674: &Apache::lonxml::debug(" still needs review not changing status.");
675: } else {
1.49 albertel 676: &move_between_queues($env{'form.queue'},'reviewqueue');
1.33 albertel 677: }
1.20 albertel 678: } elsif ($ungraded) {
1.25 albertel 679: $Apache::lonhomework::results{"resource.$version.status"}='ungraded';
1.49 albertel 680: if ($env{'form.queue'} eq 'reviewqueue' ||
681: $env{'form.queue'} eq 'none' ) {
1.33 albertel 682: &Apache::lonxml::debug("moving back.");
1.49 albertel 683: &move_between_queues($env{'form.queue'},'gradingqueue');
1.33 albertel 684: } else {
685: &check_queue_unlock($env{'form.queue'});
686: }
1.20 albertel 687: } elsif ($mandatory_failed) {
1.25 albertel 688: $Apache::lonhomework::results{"resource.$version.status"}='fail';
689: $Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
690: $Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
691: $Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
1.39 albertel 692: &remove_from_queue($env{'form.queue'});
693:
694: my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
1.52 albertel 695:
696: if ($env{'form.regrade'} ne 'yes') {
697: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
698: $Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
699: &Apache::grades::version_portfiles(
700: \%Apache::lonhomework::results,
701: ["$version.0.bridgetask"],$courseid,
702: $symb,$udom,$uname,
703: ["$version.0.bridgetask"]);
704: }
1.20 albertel 705: } else {
1.25 albertel 706: $Apache::lonhomework::results{"resource.$version.status"}='pass';
707: $Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
708: $Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
709: $Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
1.32 albertel 710: &remove_from_queue($env{'form.queue'});
1.39 albertel 711:
712: my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
1.52 albertel 713: if ($env{'form.regrade'} ne 'yes') {
714: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
715: $Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
716: &Apache::grades::version_portfiles(
717: \%Apache::lonhomework::results,
718: ["$version.0.bridgetask"],$courseid,
719: $symb,$udom,$uname,
720: ["$version.0.bridgetask"]);
721: }
1.20 albertel 722: }
1.26 albertel 723: $Apache::lonhomework::results{"resource.status"}=
724: $Apache::lonhomework::results{"resource.$version.status"};
1.28 albertel 725: if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) {
1.26 albertel 726: $Apache::lonhomework::results{"resource.0.award"}=
1.50 albertel 727: $Apache::lonhomework::results{"resource.$version.0.award"};
1.26 albertel 728: $Apache::lonhomework::results{"resource.0.awarded"}=
1.50 albertel 729: $Apache::lonhomework::results{"resource.$version.0.awarded"};
1.26 albertel 730: $Apache::lonhomework::results{"resource.0.solved"}=
1.50 albertel 731: $Apache::lonhomework::results{"resource.$version.0.solved"};
1.25 albertel 732: }
1.21 albertel 733: &Apache::structuretags::finalize_storage();
1.20 albertel 734: }
1.15 albertel 735: } elsif ($target eq 'webgrade') {
1.18 albertel 736: $result.="</table>\n<hr />";
1.20 albertel 737: #$result.='<input type="submit" name="next" value="'.
738: # &mt('Save & Next').'" /> ';
739: #$result.='<input type="submit" name="end" value="'.
740: # &mt('Save & Stop Grading').'" /> ';
741: #$result.='<input type="submit" name="throwaway" value="'.
742: # &mt('Throw Away & Stop Grading').'" /> ';
743: #$result.='<input type="submit" name="save" value="'.
744: # &mt('Save Partial Grade and Continue Grading').'" /> ';
1.15 albertel 745: $result.='</form>'.&Apache::loncommon::endbodytag().'</html>';
1.1 albertel 746: } elsif ($target eq 'meta') {
1.2 albertel 747: $result.='<parameter part="0" package="Task"></parameter>'."\n";
1.1 albertel 748: #$result.=&Apache::response::meta_part_order();
749: #$result.=&Apache::response::meta_response_order();
750: }
1.4 albertel 751: undef($Apache::lonhomework::parsing_a_task);
1.1 albertel 752: return $result;
753: }
754:
1.31 albertel 755: sub move_between_queues {
756: my ($src_queue,$dest_queue)=@_;
1.49 albertel 757: my $cur_data;
758: if ($src_queue ne 'none') {
759: $cur_data=&get_queue_data($src_queue);
760: if (!$cur_data) { return 'not_exist'; }
761: } else {
762: $cur_data = ['none'];
763: }
1.31 albertel 764: my $result=&add_to_queue($dest_queue,$cur_data->[0]);
765: if ($result ne 'ok') {
766: return $result;
767: }
768: &check_queue_unlock($src_queue);
769: return &remove_from_queue($src_queue);
1.21 albertel 770: }
771:
772: sub check_queue_unlock {
1.32 albertel 773: my ($queue,$key,$allow_not_me)=@_;
1.49 albertel 774: if ($queue eq 'none') { return 'ok'; }
1.30 albertel 775: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1.32 albertel 776: if (!defined($key)) {
777: $key="$symb\0queue\0$uname\@$udom";
778: }
1.30 albertel 779: my $cnum=$env{'course.'.$cid.'.num'};
780: my $cdom=$env{'course.'.$cid.'.domain'};
781: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
782: my $who=&queue_key_locked($queue,$key,$cdom,$cnum);
783: if ($who eq $me) {
1.32 albertel 784: return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
785: } elsif ($allow_not_me) {
1.33 albertel 786: &Apache::lonxml::debug("unlocking $who by $me");
1.32 albertel 787: return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
1.30 albertel 788: }
1.32 albertel 789: return 'not_owner';
1.21 albertel 790: }
791:
792: sub remove_from_queue {
1.30 albertel 793: my ($queue)=@_;
1.49 albertel 794: if ($queue eq 'none') { return 'ok'; }
1.27 albertel 795: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
796: my $cnum=$env{'course.'.$cid.'.num'};
797: my $cdom=$env{'course.'.$cid.'.domain'};
798: my $key="$symb\0queue\0$uname\@$udom";
799: my @keys=($key,"$key\0locked");
1.31 albertel 800: return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
1.21 albertel 801: }
802:
1.16 albertel 803: sub setup_env_for_other_user {
804: my ($queue_key,$safeeval)=@_;
805: my ($symb,$uname,$udom)=&decode_queue_key($queue_key);
1.30 albertel 806: &Apache::lonxml::debug("setup_env for $queue_key");
1.16 albertel 807: $env{'form.grade_symb'}=$symb;
808: $env{'form.grade_domain'}=$udom;
809: $env{'form.grade_username'}=$uname;
810: $env{'form.grade_courseid'}=$env{'request.course.id'};
811: &Apache::lonxml::initialize_rndseed($safeeval);
812: }
813:
1.31 albertel 814: sub get_queue_data {
815: my ($queue)=@_;
816: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
817: my $cnum=$env{'course.'.$cid.'.num'};
818: my $cdom=$env{'course.'.$cid.'.domain'};
819: my $todo="$symb\0queue\0$uname\@$udom";
820: my ($key,$value)=&Apache::lonnet::get($queue,[$todo],$cdom,$cnum);
821: if ($key eq $todo && ref($value)) {
822: return $value;
823: }
824: return undef;
825: }
826:
1.49 albertel 827: sub check_queue_for_key {
828: my ($cid,$queue,$todo)=@_;
829: my $cnum=$env{'course.'.$cid.'.num'};
830: my $cdom=$env{'course.'.$cid.'.domain'};
831: my %results=
832: &Apache::lonnet::get($queue,[$todo,"$todo\0locked"],$cdom,$cnum);
833:
834: if (exists($results{$todo}) && ref($results{$todo})) {
835: if (defined($results{"$todo\0locked"})) {
836: return 'locked';
837: }
838: return 'enqueued';
839: }
840: return undef;
841: }
842:
1.14 albertel 843: sub add_to_queue {
1.31 albertel 844: my ($queue,$slot_name)=@_;
1.49 albertel 845: if ($queue eq 'none') { return 'ok'; }
1.14 albertel 846: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
847: my $cnum=$env{'course.'.$cid.'.num'};
848: my $cdom=$env{'course.'.$cid.'.domain'};
849: my %data;
1.31 albertel 850: $data{"$symb\0queue\0$uname\@$udom"}=[$slot_name];
851: return &Apache::lonnet::put($queue,\%data,$cdom,$cnum);
1.14 albertel 852: }
853:
854: sub show_queue {
1.32 albertel 855: my ($queue,$with_selects)=@_;
1.14 albertel 856: my $result;
857: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
858: my $cnum=$env{'course.'.$cid.'.num'};
859: my $cdom=$env{'course.'.$cid.'.domain'};
1.16 albertel 860: my $regexp="^$symb\0";
1.30 albertel 861: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.31 albertel 862: my ($tmp)=%queue;
863: if ($tmp=~/^error: 2 /) {
1.33 albertel 864: return "\n<h3>Current Queue - $queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
1.31 albertel 865: }
1.33 albertel 866: $result.="\n<h3>Current Queue - $queue </h3><table border='1'><tr>";
1.32 albertel 867: if ($with_selects) { $result.="<th></th>"; }
868: $result.="<th>resource</th><th>user</th><th>type</th><th>data</th></tr>";
1.14 albertel 869: foreach my $key (sort(keys(%queue))) {
1.32 albertel 870: if ($key=~/locked$/ && !$with_selects) {
1.16 albertel 871: my ($symb,$uname,$udom) = &decode_queue_key($key);
872: my $title=&Apache::lonnet::gettitle($symb);
1.27 albertel 873: $result.="<tr><td>$title</td><td>$uname</td>";
1.16 albertel 874: $result.='<td>lock</td><td>'.$queue{$key}.'</td></tr>';
1.32 albertel 875: } elsif ($key=~/timestamp$/ && !$with_selects) {
1.16 albertel 876: my ($symb,undef) = split("\0",$key);
877: my $title=&Apache::lonnet::gettitle($symb);
1.27 albertel 878: $result.="<tr><td>$title</td><td></td>";
1.16 albertel 879: $result.='<td>last queue modification time</td><td>'.
880: &Apache::lonlocal::locallocaltime($queue{$key})."</td></tr>";
1.32 albertel 881: } elsif ($key!~/(timestamp|locked)$/) {
1.16 albertel 882: my ($symb,$uname,$udom) = &decode_queue_key($key);
883: my $title=&Apache::lonnet::gettitle($symb);
1.32 albertel 884: $result.="<tr>";
1.35 albertel 885: my $slot=$queue{$key}->[0];
886: my %slot_data=&Apache::lonnet::get_slot($slot);
1.32 albertel 887: if ($with_selects) {
888: my $ekey=&Apache::lonnet::escape($key);
889: my ($action,$description)=('select',&mt('Select'));
890: if (exists($queue{"$key\0locked"})) {
891: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
892: if ($me eq $queue{"$key\0locked"}) {
893: ($action,$description)=('resume',&mt('Resume'));
894: } else {
895: ($action,$description)=('unlock',&mt('Unlock'));
896: }
897: }
1.35 albertel 898: if (time > $slot_data{'endtime'}) {
899: $result.=(<<FORM);
1.32 albertel 900: <td>
901: <form method="POST">
902: <input type="hidden" name="gradingkey" value="$ekey" />
903: <input type="hidden" name="queue" value="$queue" />
904: <input type="hidden" name="gradingaction" value="$action" />
905: <input type="hidden" name="webgrade" value="no" />
1.33 albertel 906: <input type="hidden" name="queuemode" value="selected" />
1.32 albertel 907: <input type="submit" name="submit" value="$description" />
908: </form>
909: </td>
910: FORM
1.35 albertel 911:
912: } else {
913: $result.='<td>'.&mt("In Progress").'</td>'
914: }
1.32 albertel 915: }
916: $result.="<td>$title</td><td>$uname</td>";
1.27 albertel 917: $result.='<td>queue entry</td><td>Slot: '.$slot.' End time: '.
1.20 albertel 918: &Apache::lonlocal::locallocaltime($slot_data{'endtime'}).
919: "</td></tr>";
1.16 albertel 920: }
1.14 albertel 921: }
1.15 albertel 922: $result.="</table><hr />\n";
1.14 albertel 923: return $result;
924: }
925:
1.34 albertel 926: sub get_queue_counts {
927: my ($queue)=@_;
928: my $result;
929: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
930: my $cnum=$env{'course.'.$cid.'.num'};
931: my $cdom=$env{'course.'.$cid.'.domain'};
932: my $regexp="^$symb\0";
933: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
934: my ($tmp)=%queue;
935: if ($tmp=~/^error: 2 /) {
936: return (0,0,0);
937: }
938: my ($entries,$ready_to_grade,$locks)=(0,0,0);
939: foreach my $key (sort(keys(%queue))) {
940: if ($key=~/locked$/) {
941: $locks++;
942: } elsif ($key=~/timestamp$/) {
943: #ignore
944: } elsif ($key!~/(timestamp|locked)$/) {
945: my ($symb,$uname,$udom) = &decode_queue_key($key);
946: $entries++;
947: my $slot=$queue{$key}->[0];
948: my %slot_data=&Apache::lonnet::get_slot($slot);
949: if (time > $slot_data{'endtime'}) {
950: $ready_to_grade++;
951: }
952: }
953: }
954: return ($entries,$ready_to_grade,$locks);
955: }
956:
1.49 albertel 957: sub encode_queue_key {
958: my ($symb,$udom,$uname)=@_;
959: return "$symb\0queue\0$uname\@$udom";
960: }
961:
1.14 albertel 962: sub decode_queue_key {
963: my ($key)=@_;
964: my ($symb,undef,$user) = split("\0",$key);
965: my ($uname,$udom) = split('@',$user);
966: return ($symb,$uname,$udom);
967: }
968:
969: sub queue_key_locked {
1.30 albertel 970: my ($queue,$key,$cdom,$cnum)=@_;
1.33 albertel 971: if (!defined($cdom) || !defined($cnum)) {
972: my (undef,$cid)=&Apache::lonxml::whichuser();
973: $cnum=$env{'course.'.$cid.'.num'};
974: $cdom=$env{'course.'.$cid.'.domain'};
975: }
1.14 albertel 976: my ($key_locked,$value)=
1.30 albertel 977: &Apache::lonnet::get($queue,["$key\0locked"],$cdom,$cnum);
1.14 albertel 978: if ($key_locked eq "$key\0locked") {
979: return $value;
980: }
981: return undef;
982: }
983:
984: sub pick_from_queue_data {
1.30 albertel 985: my ($queue,$check_section,$queuedata,$cdom,$cnum)=@_;
986: foreach my $key (keys(%$queuedata)) {
1.14 albertel 987: my ($symb,$uname,$udom)=&decode_queue_key($key);
988: if ($check_section) {
989: my $section=&Apache::lonnet::getsection($uname,$udom);
1.17 albertel 990: if ($section eq $check_section) {
1.33 albertel 991: &Apache::lonxml::debug("my sec");
1.15 albertel 992: next;
993: }
1.14 albertel 994: }
1.30 albertel 995: my $slot=$queuedata->{$key}[0];
1.14 albertel 996: my %slot_data=&Apache::lonnet::get_slot($slot);
1.15 albertel 997: if ($slot_data{'endtime'} > time) {
1.33 albertel 998: &Apache::lonxml::debug("not time");
1.15 albertel 999: next;
1000: }
1.30 albertel 1001: if (&queue_key_locked($queue,$key,$cdom,$cnum)) {
1.33 albertel 1002: &Apache::lonxml::debug("someone already has um.");
1.15 albertel 1003: next;
1004: }
1.14 albertel 1005: return $key;
1006: }
1007: return undef;
1008: }
1009:
1.15 albertel 1010: sub find_mid_grade {
1.30 albertel 1011: my ($queue,$symb,$cdom,$cnum)=@_;
1.16 albertel 1012: my $todo=&Apache::lonnet::unescape($env{'form.gradingkey'});
1.15 albertel 1013: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1014: if ($todo) {
1.30 albertel 1015: my $who=&queue_key_locked($queue,$todo,$cdom,$cnum);
1.15 albertel 1016: if ($who eq $me) { return $todo; }
1017: }
1018: my $regexp="^$symb\0.*\0locked\$";
1.30 albertel 1019: my %locks=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.15 albertel 1020: foreach my $key (keys(%locks)) {
1021: my $who=$locks{$key};
1022: if ($who eq $me) {
1023: $todo=$key;
1024: $todo=~s/\0locked$//;
1025: return $todo;
1026: }
1027: }
1028: return undef;
1029: }
1030:
1.32 albertel 1031: sub lock_key {
1032: my ($queue,$todo)=@_;
1033: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1034: my (undef,$cid)=&Apache::lonxml::whichuser();
1035: my $cnum=$env{'course.'.$cid.'.num'};
1036: my $cdom=$env{'course.'.$cid.'.domain'};
1037: my $success=&Apache::lonnet::newput($queue,{"$todo\0locked"=> $me},
1038: $cdom,$cnum);
1.33 albertel 1039: &Apache::lonxml::debug("success $success $todo");
1.32 albertel 1040: if ($success eq 'ok') {
1041: return 1;
1042: }
1043: return 0;
1044: }
1045:
1.14 albertel 1046: sub get_from_queue {
1.30 albertel 1047: my ($queue)=@_;
1.14 albertel 1048: my $result;
1049: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1050: my $cnum=$env{'course.'.$cid.'.num'};
1051: my $cdom=$env{'course.'.$cid.'.domain'};
1.32 albertel 1052: my $todo=&find_mid_grade($queue,$symb,$cdom,$cnum);
1.33 albertel 1053: &Apache::lonxml::debug("found ".join(':',&decode_queue_key($todo)));
1.16 albertel 1054: if ($todo) { return $todo; }
1.14 albertel 1055: while (1) {
1056: my $starttime=time;
1.30 albertel 1057: &Apache::lonnet::put($queue,{"$symb\0timestamp"=>$starttime},
1.14 albertel 1058: $cdom,$cnum);
1.33 albertel 1059: &Apache::lonxml::debug("$starttime");
1.14 albertel 1060: my $regexp="^$symb\0queue\0";
1.30 albertel 1061: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.33 albertel 1062: #make a pass looking for a user _not_ in my section
1.14 albertel 1063: if ($env{'request.course.sec'}) {
1.33 albertel 1064: &Apache::lonxml::debug("sce");
1.30 albertel 1065: $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
1066: \%queue,$cdom,$cnum);
1.33 albertel 1067: &Apache::lonxml::debug("sce $todo");
1.14 albertel 1068: }
1.33 albertel 1069: # no one _not_ in our section so look for any user that is
1070: # ready for grading
1.14 albertel 1071: if (!$todo) {
1.33 albertel 1072: &Apache::lonxml::debug("no sce");
1.31 albertel 1073: $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
1074: \%queue,$cdom,$cnum);
1.33 albertel 1075: &Apache::lonxml::debug("no sce $todo");
1.14 albertel 1076: }
1077: # no user to grade
1078: if (!$todo) { last; }
1.33 albertel 1079: &Apache::lonxml::debug("got $todo");
1.14 albertel 1080: # otherwise found someone so lets try to lock them
1.32 albertel 1081: # unless someone else already picked them
1082: if (!&lock_key($queue,$todo)) { next; }
1.14 albertel 1083: my (undef,$endtime)=
1.30 albertel 1084: &Apache::lonnet::get($queue,["$symb\0timestamp"],
1.14 albertel 1085: $cdom,$cnum);
1.33 albertel 1086: &Apache::lonxml::debug("emd $endtime");
1.14 albertel 1087: # someone else already modified the queue,
1088: # perhaps our picked user wass already fully graded between
1089: # when we picked him and when we locked his record? so lets
1090: # double check.
1091: if ($endtime != $starttime) {
1092: my ($key,$value)=
1.30 albertel 1093: &Apache::lonnet::get($queue,["$todo"],
1.14 albertel 1094: $cdom,$cnum);
1.33 albertel 1095: &Apache::lonxml::debug("check $key .. $value");
1.14 albertel 1096: if ($key eq $todo && ref($value)) {
1097: } else {
1.30 albertel 1098: &Apache::lonnet::del($queue,["$todo\0locked"],
1.14 albertel 1099: $cdom,$cnum);
1.33 albertel 1100: &Apache::lonxml::debug("del");
1.14 albertel 1101: next;
1102: }
1103: }
1.33 albertel 1104: &Apache::lonxml::debug("last $todo");
1.14 albertel 1105: last;
1106: }
1107: return $todo;
1108: }
1109:
1.49 albertel 1110: sub select_user {
1111: my ($symb,$cid)=&Apache::lonxml::whichuser();
1112: my $result.='<table border="1">';
1113:
1114: &Apache::grades::init_perm();
1115: my ($classlist,$section,$fullname)=&Apache::grades::getclasslist('all',);
1116: &Apache::grades::reset_perm();
1117:
1118: foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
1119: my ($uname,$udom) = split(/:/,$student);
1120: my %status = &get_student_status($symb,$cid,$udom,$uname);
1121: my $queue = 'none';
1122: if ($status{'reviewqueue'} eq 'enqueued') {
1123: $queue = 'reviewqueue';
1124: } elsif ($status{'gradingqueue'} eq 'enqueued') {
1125: $queue = 'gradingqueue';
1126: }
1127: my $todo =
1128: &Apache::lonnet::escape(&encode_queue_key($symb,$udom,$uname));
1129: $result.=<<RESULT;
1130: <tr>
1131: <td>
1132: <form method="POST">
1133: <input type="hidden" name="gradingkey" value="$todo" />
1134: <input type="hidden" name="queue" value="$queue" />
1135: <input type="hidden" name="webgrade" value="no" />
1.52 albertel 1136: <input type="hidden" name="regrade" value="yes" />
1.49 albertel 1137: <input type="submit" name="submit" value="Regrade" />
1138: </form>
1139: <td>$fullname->{$student}</td>
1140: <td>
1141: RESULT
1142:
1143: if ($status{'status'} eq 'pass') {
1144: $result .= '<font color="green">'.&mt('Passed').'</font>';
1145: } elsif ($status{'status'} eq 'fail') {
1146: $result .= '<font color="red">'.&mt('Failed').'</font>';
1147: } elsif ($status{'status'} eq 'review') {
1148: $result .= '<font color="blue">'.&mt('Under Review').'</font>';
1149: } elsif ($status{'status'} eq 'ungraded') {
1150: $result .= &mt('Ungraded');
1151: } elsif ($status{'status'} ne '') {
1152: $result .= '<font color="orange">'.&mt('Unknown Status').'</font>';
1153: } else {
1154: $result.=" ";
1155: }
1156: if ($status{'version'}) {
1157: $result .= ' '.&mt('Version').' '.$status{'version'};
1158: }
1159: $result.= '</td><td>';
1160: if ($status{'reviewqueue'} eq 'enqueued') {
1161: $result .= &mt('Awaiting Review');
1162: } elsif ($status{'reviewqueue'} eq 'locked') {
1163: $result .= &mt('Under Review');
1164: } elsif ($status{'gradingqueue'} eq 'enqueued') {
1165: $result .= &mt('Awaiting Grading');
1166: } elsif ($status{'gradingqueue'} eq 'locked') {
1167: $result .= &mt('Being Graded');
1168: } else {
1169: $result.=" ";
1170: }
1171: $result.= '</td></tr>';
1172: }
1173: $result.='</table>';
1174: return $result;
1175: }
1176:
1177: sub get_student_status {
1178: my ($symb,$cid,$udom,$uname)=@_;
1179: my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
1180: $udom,$uname);
1181: my %status;
1182: $status{'status'}=$record{'resource.status'};
1183: $status{'version'}=$record{'resource.version'};
1184: $status{'grader'}=$record{'resource.grader'};
1185: $status{'reviewqueue'}=&check_queue_for_key($cid,'reviewqueue',
1186: &encode_queue_key($symb,$udom,$uname));
1187: $status{'gradingqueue'}=&check_queue_for_key($cid,'gradingqueue',
1188: &encode_queue_key($symb,$udom,$uname));
1189: return %status;
1190: }
1191:
1.1 albertel 1192: sub start_ClosingParagraph {
1193: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1194: my $result;
1195: if ($target eq 'web') {
1.13 albertel 1196: } elsif ($target eq 'webgrade') {
1197: &Apache::lonxml::startredirection();
1.1 albertel 1198: }
1199: return $result;
1200: }
1201:
1202: sub end_ClosingParagraph {
1203: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1204: my $result;
1205: if ($target eq 'web') {
1.13 albertel 1206: } elsif ($target eq 'webgrade') {
1207: &Apache::lonxml::endredirection();
1.1 albertel 1208: }
1209: return $result;
1210: }
1211:
1.19 albertel 1212: sub get_id {
1213: my ($parstack,$safeeval)=@_;
1214: my $id=&Apache::lonxml::get_param('id',$parstack,$safeeval);
1215: if (!$id) { $id=$Apache::lonxml::curdepth; }
1216: return $id;
1217: }
1218:
1.1 albertel 1219: my %dimension;
1220: sub start_Dimension {
1221: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1222: undef(%dimension);
1.19 albertel 1223: my $dim_id=&get_id($parstack,$safeeval);
1.9 albertel 1224: $Apache::bridgetask::dimension=$dim_id;
1225: push(@Apache::bridgetask::dimensionlist,$dim_id);
1226: undef(@Apache::bridgetask::instance);
1.20 albertel 1227: $Apache::bridgetask::dimensionmandatory{$dim_id}=
1228: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.54 albertel 1229: &Apache::lonxml::startredirection();
1230: return &internal_location($dim_id);
1.1 albertel 1231: }
1232:
1.13 albertel 1233: sub get_instance {
1234: &Apache::response::pushrandomnumber();
1235: my @order=&Math::Random::random_permutation(@{$dimension{'instances'}});
1.29 albertel 1236: my $num=@order;
1237: my $version=&get_version();
1238: my $which=($version-1)%$num;
1239: return $order[$which];
1.13 albertel 1240: }
1241:
1.18 albertel 1242: {
1243: my $last_link;
1244: sub end_Dimension {
1245: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.54 albertel 1246: my $result=&Apache::lonxml::endredirection();
1.25 albertel 1247: my $dim=&get_id($parstack,$safeeval);
1.19 albertel 1248: my $instance=&get_instance();
1.25 albertel 1249: my $version=&get_version();
1.18 albertel 1250: if ($target eq 'web') {
1.47 albertel 1251: @Apache::scripttag::parser_env = @_;
1252: $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
1253: @Apache::scripttag::parser_env = @_;
1254: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
1.26 albertel 1255: if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' ||
1256: $Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
1.54 albertel 1257:
1258: my $dim_status=$Apache::lonhomework::history{"resource.$version.$dim.status"};
1259: my $mandatory='Mandatory';
1260: if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') {
1261: $mandatory='Optional';
1262: }
1263: my $dim_info="<div class='$dim_status'>\n";
1264: if ($dim_status eq 'pass') {
1265: $dim_info.='<h3>Question : you passed this '.$mandatory.' question</h3>';
1266: }
1267: if ($dim_status eq 'fail') {
1268: $dim_info.='<h3>Question : you did not pass this '.$mandatory.' question</h3>';
1269: }
1270: my $man_count=0;
1271: my $opt_count=0;
1272: my $opt_passed=0;
1273: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1274: if ($dimension{$instance.'.criteria.'.$id.'.mandatory'}
1275: eq 'N') {
1276: $opt_count++;
1277: if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
1278: $opt_passed++;
1279: }
1280: } else {
1281: $man_count++;
1282: }
1283: }
1284: my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
1285: $parstack,$safeeval);
1286: if ($opt_req !~ /\S/) { $opt_req='0'; }
1287: $dim_info.="\n<p>".&mt('You passed all of the mandatory components and [_1] of the [_2] optional components, of which you were required to pass [_3].',$opt_passed,$opt_count,$opt_req)."</p>\n</div>";
1288:
1289: my $internal_location=&internal_location($dim);
1290: $result=~s/\Q$internal_location\E/$dim_info/;
1291:
1.22 albertel 1292: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.25 albertel 1293: my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
1294: my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"};
1.53 albertel 1295: my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
1296: if ($mandatory) {
1297: $mandatory='Mandatory';
1298: } else {
1299: $mandatory='Optional';
1300: }
1.22 albertel 1301: if ($status eq 'fail') {
1302: } elsif ($status eq 'pass') {
1303: } else {
1.49 albertel 1304: &Apache::lonxml::error("Student viewing a graded bridgetask was shown a status of $status");
1.22 albertel 1305: }
1.53 albertel 1306: my $status_display=$status;
1307: $status_display=~s/^([a-z])/uc($1)/e;
1.54 albertel 1308: @Apache::scripttag::parser_env = @_;
1.53 albertel 1309: $result.='<div class="'.$status.'"><h4>'.$mandatory.
1.54 albertel 1310: ' Criteria</h4><p>';
1311: @Apache::scripttag::parser_env = @_;
1312: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
1313: $result.='</p><p class="grade">'.$status_display.'</p>';
1.25 albertel 1314: if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
1.53 albertel 1315: $result.='<p class="comment">'.$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'</p>';
1.22 albertel 1316: }
1.53 albertel 1317: $result.='</div>';
1.22 albertel 1318: }
1319: }
1.18 albertel 1320: } elsif ($target eq 'webgrade') {
1.47 albertel 1321: # in case of any side effects that we need
1322: @Apache::scripttag::parser_env = @_;
1323: &Apache::scripttag::xmlparse($dimension{'intro'});
1324: @Apache::scripttag::parser_env = @_;
1325: &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
1.18 albertel 1326: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1327: my $link='criteria_'.$instance.'_'.$id;
1.25 albertel 1328: my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
1.19 albertel 1329: $result.='<tr><td width="100%" valign="top">'.
1.18 albertel 1330: '<a name="'.$link.'" />'.
1331: '<a name="next_'.$last_link.'" />'.
1.47 albertel 1332: '<br /><textarea enabled="false" style="width:100%" rows="8" width="25" wrap="hard">';
1333: @Apache::scripttag::parser_env = @_;
1334: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
1335: $result.='</textarea>'.
1.18 albertel 1336: #$dimension{$instance.'.criteria.'.$id}.
1337: '</td>'.
1.19 albertel 1338: '<td><nobr>Additional Comment for Student</nobr> <br />'.
1.25 albertel 1339: '<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 1340: '</td>'.
1341: '<td>'.
1.47 albertel 1342: '<nobr><label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" '.($status eq 'ungraded' || !$status ? 'checked="checked"':'').' />'.&mt('Ungraded').'</label></nobr><br />'.
1.30 albertel 1343: '<label><input type="radio" name="HWVAL_'.$link.'" value="pass" '.($status eq 'pass' ? 'checked="checked"':'').' />'.&mt('Pass').'</label><br />'.
1344: '<label><input type="radio" name="HWVAL_'.$link.'" value="fail" '.($status eq 'fail' ? 'checked="checked"':'').' />'.&mt('Fail').'</label><br />'.
1345: '<label><input type="radio" name="HWVAL_'.$link.'" value="review" '.($status eq 'review' ? 'checked="checked"':'').' />'.&mt('Review').'</label><br />'.
1.18 albertel 1346: '</td>'.
1347: '<td>'.
1348: '<a href="#'.$last_link.'">Prev</a><br />'.
1.20 albertel 1349: '<a href="#next_'.$link.'">Next</a><br /><br /><br />'.
1350: '<input type="submit" name="next" value="'.
1351: &mt('Done').'" /> '.
1.30 albertel 1352: '<input type="submit" name="stop" value="'.
1353: &mt('Stop').'" /> '.
1.18 albertel 1354: '</td></tr>';
1.22 albertel 1355: $result.='<tr><td colspan="4">';
1356: my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
1.52 albertel 1357: my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
1.43 albertel 1358: foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"})) {
1.22 albertel 1359: my $file=$file_url.$partial_file;
1.52 albertel 1360: $file=~s|/+|/|g;
1.22 albertel 1361: &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
1.48 albertel 1362: $result.='<nobr><a href="'.$file.'" target="lonGRDs"><img src="'.
1.22 albertel 1363: &Apache::loncommon::icon($file).'" border=0"> '.$file.
1.48 albertel 1364: '</a></nobr> ';
1.22 albertel 1365: }
1366: $result.='</td></tr>';
1.18 albertel 1367: $last_link=$link;
1368: }
1.22 albertel 1369: } elsif ($target eq 'grade' && $env{'form.webgrade'}) {
1.19 albertel 1370: my $optional_passed=0;
1.20 albertel 1371: my $mandatory_failed=0;
1372: my $ungraded=0;
1373: my $review=0;
1.19 albertel 1374: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.25 albertel 1375: my $status=$Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.status"}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id};
1376: $Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.comment"}=$env{'form.HWVAL_comment_criteria_'.$instance.'_'.$id};
1.20 albertel 1377: my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
1378: if ($status eq 'pass') {
1379: if (!$mandatory) { $optional_passed++; }
1380: } elsif ($status eq 'fail') {
1381: if ($mandatory) { $mandatory_failed++; }
1.21 albertel 1382: } elsif ($status eq 'review') {
1383: $review++;
1.20 albertel 1384: } elsif ($status eq 'ungraded') {
1385: $ungraded++;
1.21 albertel 1386: } else {
1.47 albertel 1387: $ungraded++;
1.19 albertel 1388: }
1389: }
1.20 albertel 1390: if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
1391: $mandatory_failed++;
1392: }
1.21 albertel 1393: &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 1394: if ($review) {
1.25 albertel 1395: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1396: 'review';
1.20 albertel 1397: } elsif ($ungraded) {
1.25 albertel 1398: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1399: 'ungraded';
1.20 albertel 1400: } elsif ($mandatory_failed) {
1.25 albertel 1401: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1402: 'fail';
1.20 albertel 1403: } else {
1.25 albertel 1404: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1405: 'pass';
1.20 albertel 1406: }
1.13 albertel 1407: }
1.18 albertel 1408: return $result;
1.1 albertel 1409: }
1410: }
1411:
1412: sub start_IntroParagraph {
1413: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1414: my $result;
1.13 albertel 1415: if ($target eq 'web' || $target eq 'webgrade') {
1.47 albertel 1416: if ($tagstack->[-2] eq 'Dimension') {
1417: $dimension{'intro'}=&Apache::lonxml::get_all_text('/introparagraph',$parser);
1418:
1419: } elsif ($target eq 'webgrade') {
1420: &Apache::lonxml::get_all_text('/introparagraph',$parser);
1.1 albertel 1421: }
1.47 albertel 1422:
1.1 albertel 1423: }
1424: return $result;
1425: }
1426:
1427: sub end_IntroParagraph {
1428: }
1429:
1430: sub start_Instance {
1431: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.19 albertel 1432: my $id=&get_id($parstack,$safeeval);
1433: push(@{$dimension{'instances'}},$id);
1434: push(@Apache::bridgetask::instance,$id);
1435: push(@Apache::bridgetask::instancelist,$id);
1.20 albertel 1436: $dimension{$id.'.optionalrequired'}=
1.19 albertel 1437: &Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval);
1.1 albertel 1438: return '';
1439: }
1440:
1441: sub end_Instance {
1442: }
1443:
1444: sub start_InstanceText {
1445: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.47 albertel 1446: my $instance_id=$Apache::bridgetask::instance[-1];
1447: my $text=&Apache::lonxml::get_all_text('/instancetext',$parser);
1.13 albertel 1448: if ($target eq 'web' || $target eq 'webgrade') {
1.47 albertel 1449: $dimension{$instance_id.'.text'}=$text;
1.1 albertel 1450: }
1451: return '';
1452: }
1453:
1454: sub end_InstanceText {
1455: return '';
1456: }
1457:
1458: sub start_Criteria {
1459: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.9 albertel 1460: my $instance_id=$Apache::bridgetask::instance[-1];
1.47 albertel 1461: my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser);
1.21 albertel 1462: if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
1.19 albertel 1463: my $id=&get_id($parstack,$safeeval);
1.1 albertel 1464: $dimension{$instance_id.'.criteria.'.$id}=$criteria;
1.19 albertel 1465: $dimension{$instance_id.'.criteria.'.$id.'.mandatory'}=
1466: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.1 albertel 1467: push(@{$dimension{$instance_id.'.criterias'}},$id);
1468: }
1469: return '';
1470: }
1471:
1.47 albertel 1472: sub end_Criteria {
1473: }
1474:
1.4 albertel 1475: sub proctor_validation_screen {
1476: my ($slot) = @_;
1477: my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
1.5 albertel 1478: my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg');
1.44 albertel 1479: my $name=&Apache::loncommon::plainname($user,$domain);
1480:
1.4 albertel 1481: my $msg;
1.11 albertel 1482: if ($env{'form.proctorpassword'}) {
1.4 albertel 1483: $msg='<p><font color="red">'.&mt("Failed to authenticate the proctor.")
1484: .'</font></p>';
1485: }
1.47 albertel 1486: if (!$env{'form.proctordomain'}) { $env{'form.proctordomain'}=$domain; }
1.4 albertel 1487: my $result= (<<ENDCHECKOUT);
1488: <h2>Proctor Validation</h2>
1489: <p>Your room's proctor needs to validate your access to this resource.</p>
1490: $msg
1.11 albertel 1491: <form name="checkout" method="POST" action="$env{'request.uri'}">
1.4 albertel 1492: <input type="hidden" name="validate" value="yes" />
1493: <input type="hidden" name="submitted" value="yes" />
1494: <table>
1.44 albertel 1495: <tr><td>Proctor's Username:</td><td><input type="string" name="proctorname" value="$env{'form.proctorname'}" /></td></tr>
1.4 albertel 1496: <tr><td>Password:</td><td><input type="password" name="proctorpassword" value="" /></td></tr>
1.46 albertel 1497: <tr><td>Proctor's Domain:</td><td><input type="string" name="proctordomain" value="$env{'form.proctordomain'}" /></td></tr>
1.4 albertel 1498: </table>
1499: <input type="submit" name="checkoutbutton" value="Validate" /><br />
1.44 albertel 1500: <table border="1">
1501: <tr><td>
1502: <table>
1503: <tr><td colspan="2">Student who should be logged in is:</td></tr>
1504: <tr><td>Name:</td><td>$name</td></tr>
1.45 albertel 1505: <tr><td>Student ID:</td><td>$env{'environment.id'}</td></tr>
1.44 albertel 1506: <tr><td>Usename</td><td>$user\@$domain</td></tr>
1507: <tr><td colspan="2"><img src="$url" /></td></tr>
1508: </table>
1509: </tr></td>
1510: </table>
1.4 albertel 1511: </form>
1512: ENDCHECKOUT
1513: return $result;
1514: }
1515:
1.1 albertel 1516: 1;
1517: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>