Annotation of loncom/homework/bridgetask.pm, revision 1.55
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # definition of tags that give a structure to a document
3: #
1.55 ! albertel 4: # $Id: bridgetask.pm,v 1.54 2005/09/29 19:15:47 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.54 albertel 567: if (&show_task($status,$previous)) {
568: my $bt_status=$Apache::lonhomework::history{"resource.$version.status"};
569: my $title=&Apache::lonnet::gettitle();
570: my %slot=&Apache::lonnet::get_slot($Apache::inputtags::slot_name);
1.55 ! albertel 571: my $start_time=
! 572: &Apache::lonlocal::locallocaltime($slot{'starttime'});
1.54 albertel 573:
574: my $status;
575: $status.="\n<div class='$bt_status'>\n";
576:
577: if ($bt_status eq 'pass') {
578: $status.='<h2>You passed the '.$title.' given on '.
1.55 ! albertel 579: $start_time.'.</h2>';
1.54 albertel 580: }
581: if ($bt_status eq 'fail') {
582: $status.='<h2>You did not pass the '.$title.' given on '.
1.55 ! albertel 583: $start_time.'.</h2>';
1.54 albertel 584: if (!$previous) {
585: $status.=&add_request_another_attempt_button();
586: }
587: }
588: my $man_count=0;
589: my $opt_count=0;
590: my $opt_passed=0;
591: foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
592: if ($Apache::bridgetask::dimensionmandatory{$dim_id}
593: eq 'N') {
594: $opt_count++;
595: if ($Apache::lonhomework::history{"resource.$version.$dim_id.status"} eq 'pass') {
596: $opt_passed++;
597: }
598: } else {
599: $man_count++;
600: }
601: }
602: my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
603: $parstack,$safeeval);
604: if ($opt_req !~ /\S/) { $opt_req='0'; }
605: $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";
606:
607: my $internal_location=&internal_location();
608: $result=~s/\Q$internal_location\E/$status/;
609: }
1.13 albertel 610: }
611: if ($target eq 'web' || $target eq 'webgrade') {
1.1 albertel 612: $result.=&Apache::lonxml::xmlend().'</html>';
613: }
614: }
1.29 albertel 615: if ($target eq 'grade' && !$env{'form.webgrade'} && !$previous) {
1.12 albertel 616: my $award='SUBMITTED';
1.28 albertel 617: &Apache::essayresponse::file_submission("$version.0",'bridgetask',
1.20 albertel 618: 'portfiles',\$award);
1.14 albertel 619: if ($award eq 'SUBMITTED' &&
1.28 albertel 620: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}) {
621: $Apache::lonhomework::results{"resource.0.tries"}=
622: $Apache::lonhomework::results{"resource.$version.0.tries"}=
623: 1+$Apache::lonhomework::history{"resource.$version.0.tries"};
624:
625: $Apache::lonhomework::results{"resource.0.award"}=
626: $Apache::lonhomework::results{"resource.$version.0.award"}=
627: $award;
1.51 albertel 628: $Apache::lonhomework::results{"resource.0.submission"}=
629: $Apache::lonhomework::results{"resource.$version.0.submission"}='';
1.10 albertel 630: }
1.4 albertel 631: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
632: &Apache::structuretags::finalize_storage();
1.14 albertel 633: if ($award eq 'SUBMITTED') {
1.31 albertel 634: &add_to_queue('gradingqueue',$Apache::inputtags::slot_name);
1.14 albertel 635: }
1.1 albertel 636: }
1.32 albertel 637: if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
1.20 albertel 638: my $optional_required=
639: &Apache::lonxml::get_param('OptionalRequired',$parstack,
640: $safeeval);
641: my $optional_passed=0;
642: my $mandatory_failed=0;
643: my $ungraded=0;
644: my $review=0;
1.21 albertel 645: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
1.20 albertel 646: foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
647: my $status=
1.25 albertel 648: $Apache::lonhomework::results{"resource.$version.$dim_id.status"};
1.20 albertel 649: my $mandatory=
650: ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
651: if ($status eq 'pass') {
652: if (!$mandatory) { $optional_passed++; }
653: } elsif ($status eq 'fail') {
654: if ($mandatory) { $mandatory_failed++; }
655: } elsif ($status eq 'ungraded') {
656: $ungraded++;
657: } elsif ($status eq 'review') {
658: $review++;
1.49 albertel 659: } else {
660: $ungraded++;
661: }
1.20 albertel 662: }
663: if ($optional_passed < $optional_required) {
664: $mandatory_failed++;
665: }
1.21 albertel 666: &Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
667: $Apache::lonhomework::results{'resource.grader'}=
1.20 albertel 668: $env{'user.name'}.'@'.$env{'user.domain'};
669: if ($review) {
1.25 albertel 670: $Apache::lonhomework::results{"resource.$version.status"}='review';
1.33 albertel 671: if ($env{'form.queue'} eq 'reviewqueue') {
672: &check_queue_unlock($env{'form.queue'});
673: &Apache::lonxml::debug(" still needs review not changing status.");
674: } else {
1.49 albertel 675: &move_between_queues($env{'form.queue'},'reviewqueue');
1.33 albertel 676: }
1.20 albertel 677: } elsif ($ungraded) {
1.25 albertel 678: $Apache::lonhomework::results{"resource.$version.status"}='ungraded';
1.49 albertel 679: if ($env{'form.queue'} eq 'reviewqueue' ||
680: $env{'form.queue'} eq 'none' ) {
1.33 albertel 681: &Apache::lonxml::debug("moving back.");
1.49 albertel 682: &move_between_queues($env{'form.queue'},'gradingqueue');
1.33 albertel 683: } else {
684: &check_queue_unlock($env{'form.queue'});
685: }
1.20 albertel 686: } elsif ($mandatory_failed) {
1.25 albertel 687: $Apache::lonhomework::results{"resource.$version.status"}='fail';
688: $Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
689: $Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
690: $Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
1.39 albertel 691: &remove_from_queue($env{'form.queue'});
692:
693: my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
1.52 albertel 694:
695: if ($env{'form.regrade'} ne 'yes') {
696: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
697: $Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
698: &Apache::grades::version_portfiles(
699: \%Apache::lonhomework::results,
700: ["$version.0.bridgetask"],$courseid,
701: $symb,$udom,$uname,
702: ["$version.0.bridgetask"]);
703: }
1.20 albertel 704: } else {
1.25 albertel 705: $Apache::lonhomework::results{"resource.$version.status"}='pass';
706: $Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
707: $Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
708: $Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
1.32 albertel 709: &remove_from_queue($env{'form.queue'});
1.39 albertel 710:
711: my ($symb,$courseid,$udom,$uname)=&Apache::lonxml::whichuser();
1.52 albertel 712: if ($env{'form.regrade'} ne 'yes') {
713: $Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"}=
714: $Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"};
715: &Apache::grades::version_portfiles(
716: \%Apache::lonhomework::results,
717: ["$version.0.bridgetask"],$courseid,
718: $symb,$udom,$uname,
719: ["$version.0.bridgetask"]);
720: }
1.20 albertel 721: }
1.26 albertel 722: $Apache::lonhomework::results{"resource.status"}=
723: $Apache::lonhomework::results{"resource.$version.status"};
1.28 albertel 724: if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) {
1.26 albertel 725: $Apache::lonhomework::results{"resource.0.award"}=
1.50 albertel 726: $Apache::lonhomework::results{"resource.$version.0.award"};
1.26 albertel 727: $Apache::lonhomework::results{"resource.0.awarded"}=
1.50 albertel 728: $Apache::lonhomework::results{"resource.$version.0.awarded"};
1.26 albertel 729: $Apache::lonhomework::results{"resource.0.solved"}=
1.50 albertel 730: $Apache::lonhomework::results{"resource.$version.0.solved"};
1.25 albertel 731: }
1.21 albertel 732: &Apache::structuretags::finalize_storage();
1.20 albertel 733: }
1.15 albertel 734: } elsif ($target eq 'webgrade') {
1.18 albertel 735: $result.="</table>\n<hr />";
1.20 albertel 736: #$result.='<input type="submit" name="next" value="'.
737: # &mt('Save & Next').'" /> ';
738: #$result.='<input type="submit" name="end" value="'.
739: # &mt('Save & Stop Grading').'" /> ';
740: #$result.='<input type="submit" name="throwaway" value="'.
741: # &mt('Throw Away & Stop Grading').'" /> ';
742: #$result.='<input type="submit" name="save" value="'.
743: # &mt('Save Partial Grade and Continue Grading').'" /> ';
1.15 albertel 744: $result.='</form>'.&Apache::loncommon::endbodytag().'</html>';
1.1 albertel 745: } elsif ($target eq 'meta') {
1.2 albertel 746: $result.='<parameter part="0" package="Task"></parameter>'."\n";
1.1 albertel 747: #$result.=&Apache::response::meta_part_order();
748: #$result.=&Apache::response::meta_response_order();
749: }
1.4 albertel 750: undef($Apache::lonhomework::parsing_a_task);
1.1 albertel 751: return $result;
752: }
753:
1.31 albertel 754: sub move_between_queues {
755: my ($src_queue,$dest_queue)=@_;
1.49 albertel 756: my $cur_data;
757: if ($src_queue ne 'none') {
758: $cur_data=&get_queue_data($src_queue);
759: if (!$cur_data) { return 'not_exist'; }
760: } else {
761: $cur_data = ['none'];
762: }
1.31 albertel 763: my $result=&add_to_queue($dest_queue,$cur_data->[0]);
764: if ($result ne 'ok') {
765: return $result;
766: }
767: &check_queue_unlock($src_queue);
768: return &remove_from_queue($src_queue);
1.21 albertel 769: }
770:
771: sub check_queue_unlock {
1.32 albertel 772: my ($queue,$key,$allow_not_me)=@_;
1.49 albertel 773: if ($queue eq 'none') { return 'ok'; }
1.30 albertel 774: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1.32 albertel 775: if (!defined($key)) {
776: $key="$symb\0queue\0$uname\@$udom";
777: }
1.30 albertel 778: my $cnum=$env{'course.'.$cid.'.num'};
779: my $cdom=$env{'course.'.$cid.'.domain'};
780: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
781: my $who=&queue_key_locked($queue,$key,$cdom,$cnum);
782: if ($who eq $me) {
1.32 albertel 783: return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
784: } elsif ($allow_not_me) {
1.33 albertel 785: &Apache::lonxml::debug("unlocking $who by $me");
1.32 albertel 786: return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
1.30 albertel 787: }
1.32 albertel 788: return 'not_owner';
1.21 albertel 789: }
790:
791: sub remove_from_queue {
1.30 albertel 792: my ($queue)=@_;
1.49 albertel 793: if ($queue eq 'none') { return 'ok'; }
1.27 albertel 794: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
795: my $cnum=$env{'course.'.$cid.'.num'};
796: my $cdom=$env{'course.'.$cid.'.domain'};
797: my $key="$symb\0queue\0$uname\@$udom";
798: my @keys=($key,"$key\0locked");
1.31 albertel 799: return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
1.21 albertel 800: }
801:
1.16 albertel 802: sub setup_env_for_other_user {
803: my ($queue_key,$safeeval)=@_;
804: my ($symb,$uname,$udom)=&decode_queue_key($queue_key);
1.30 albertel 805: &Apache::lonxml::debug("setup_env for $queue_key");
1.16 albertel 806: $env{'form.grade_symb'}=$symb;
807: $env{'form.grade_domain'}=$udom;
808: $env{'form.grade_username'}=$uname;
809: $env{'form.grade_courseid'}=$env{'request.course.id'};
810: &Apache::lonxml::initialize_rndseed($safeeval);
811: }
812:
1.31 albertel 813: sub get_queue_data {
814: my ($queue)=@_;
815: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
816: my $cnum=$env{'course.'.$cid.'.num'};
817: my $cdom=$env{'course.'.$cid.'.domain'};
818: my $todo="$symb\0queue\0$uname\@$udom";
819: my ($key,$value)=&Apache::lonnet::get($queue,[$todo],$cdom,$cnum);
820: if ($key eq $todo && ref($value)) {
821: return $value;
822: }
823: return undef;
824: }
825:
1.49 albertel 826: sub check_queue_for_key {
827: my ($cid,$queue,$todo)=@_;
828: my $cnum=$env{'course.'.$cid.'.num'};
829: my $cdom=$env{'course.'.$cid.'.domain'};
830: my %results=
831: &Apache::lonnet::get($queue,[$todo,"$todo\0locked"],$cdom,$cnum);
832:
833: if (exists($results{$todo}) && ref($results{$todo})) {
834: if (defined($results{"$todo\0locked"})) {
835: return 'locked';
836: }
837: return 'enqueued';
838: }
839: return undef;
840: }
841:
1.14 albertel 842: sub add_to_queue {
1.31 albertel 843: my ($queue,$slot_name)=@_;
1.49 albertel 844: if ($queue eq 'none') { return 'ok'; }
1.14 albertel 845: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
846: my $cnum=$env{'course.'.$cid.'.num'};
847: my $cdom=$env{'course.'.$cid.'.domain'};
848: my %data;
1.31 albertel 849: $data{"$symb\0queue\0$uname\@$udom"}=[$slot_name];
850: return &Apache::lonnet::put($queue,\%data,$cdom,$cnum);
1.14 albertel 851: }
852:
853: sub show_queue {
1.32 albertel 854: my ($queue,$with_selects)=@_;
1.14 albertel 855: my $result;
856: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
857: my $cnum=$env{'course.'.$cid.'.num'};
858: my $cdom=$env{'course.'.$cid.'.domain'};
1.16 albertel 859: my $regexp="^$symb\0";
1.30 albertel 860: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.31 albertel 861: my ($tmp)=%queue;
862: if ($tmp=~/^error: 2 /) {
1.33 albertel 863: return "\n<h3>Current Queue - $queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
1.31 albertel 864: }
1.33 albertel 865: $result.="\n<h3>Current Queue - $queue </h3><table border='1'><tr>";
1.32 albertel 866: if ($with_selects) { $result.="<th></th>"; }
867: $result.="<th>resource</th><th>user</th><th>type</th><th>data</th></tr>";
1.14 albertel 868: foreach my $key (sort(keys(%queue))) {
1.32 albertel 869: if ($key=~/locked$/ && !$with_selects) {
1.16 albertel 870: my ($symb,$uname,$udom) = &decode_queue_key($key);
871: my $title=&Apache::lonnet::gettitle($symb);
1.27 albertel 872: $result.="<tr><td>$title</td><td>$uname</td>";
1.16 albertel 873: $result.='<td>lock</td><td>'.$queue{$key}.'</td></tr>';
1.32 albertel 874: } elsif ($key=~/timestamp$/ && !$with_selects) {
1.16 albertel 875: my ($symb,undef) = split("\0",$key);
876: my $title=&Apache::lonnet::gettitle($symb);
1.27 albertel 877: $result.="<tr><td>$title</td><td></td>";
1.16 albertel 878: $result.='<td>last queue modification time</td><td>'.
879: &Apache::lonlocal::locallocaltime($queue{$key})."</td></tr>";
1.32 albertel 880: } elsif ($key!~/(timestamp|locked)$/) {
1.16 albertel 881: my ($symb,$uname,$udom) = &decode_queue_key($key);
882: my $title=&Apache::lonnet::gettitle($symb);
1.32 albertel 883: $result.="<tr>";
1.35 albertel 884: my $slot=$queue{$key}->[0];
885: my %slot_data=&Apache::lonnet::get_slot($slot);
1.32 albertel 886: if ($with_selects) {
887: my $ekey=&Apache::lonnet::escape($key);
888: my ($action,$description)=('select',&mt('Select'));
889: if (exists($queue{"$key\0locked"})) {
890: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
891: if ($me eq $queue{"$key\0locked"}) {
892: ($action,$description)=('resume',&mt('Resume'));
893: } else {
894: ($action,$description)=('unlock',&mt('Unlock'));
895: }
896: }
1.35 albertel 897: if (time > $slot_data{'endtime'}) {
898: $result.=(<<FORM);
1.32 albertel 899: <td>
900: <form method="POST">
901: <input type="hidden" name="gradingkey" value="$ekey" />
902: <input type="hidden" name="queue" value="$queue" />
903: <input type="hidden" name="gradingaction" value="$action" />
904: <input type="hidden" name="webgrade" value="no" />
1.33 albertel 905: <input type="hidden" name="queuemode" value="selected" />
1.32 albertel 906: <input type="submit" name="submit" value="$description" />
907: </form>
908: </td>
909: FORM
1.35 albertel 910:
911: } else {
912: $result.='<td>'.&mt("In Progress").'</td>'
913: }
1.32 albertel 914: }
915: $result.="<td>$title</td><td>$uname</td>";
1.27 albertel 916: $result.='<td>queue entry</td><td>Slot: '.$slot.' End time: '.
1.20 albertel 917: &Apache::lonlocal::locallocaltime($slot_data{'endtime'}).
918: "</td></tr>";
1.16 albertel 919: }
1.14 albertel 920: }
1.15 albertel 921: $result.="</table><hr />\n";
1.14 albertel 922: return $result;
923: }
924:
1.34 albertel 925: sub get_queue_counts {
926: my ($queue)=@_;
927: my $result;
928: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
929: my $cnum=$env{'course.'.$cid.'.num'};
930: my $cdom=$env{'course.'.$cid.'.domain'};
931: my $regexp="^$symb\0";
932: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
933: my ($tmp)=%queue;
934: if ($tmp=~/^error: 2 /) {
935: return (0,0,0);
936: }
937: my ($entries,$ready_to_grade,$locks)=(0,0,0);
938: foreach my $key (sort(keys(%queue))) {
939: if ($key=~/locked$/) {
940: $locks++;
941: } elsif ($key=~/timestamp$/) {
942: #ignore
943: } elsif ($key!~/(timestamp|locked)$/) {
944: my ($symb,$uname,$udom) = &decode_queue_key($key);
945: $entries++;
946: my $slot=$queue{$key}->[0];
947: my %slot_data=&Apache::lonnet::get_slot($slot);
948: if (time > $slot_data{'endtime'}) {
949: $ready_to_grade++;
950: }
951: }
952: }
953: return ($entries,$ready_to_grade,$locks);
954: }
955:
1.49 albertel 956: sub encode_queue_key {
957: my ($symb,$udom,$uname)=@_;
958: return "$symb\0queue\0$uname\@$udom";
959: }
960:
1.14 albertel 961: sub decode_queue_key {
962: my ($key)=@_;
963: my ($symb,undef,$user) = split("\0",$key);
964: my ($uname,$udom) = split('@',$user);
965: return ($symb,$uname,$udom);
966: }
967:
968: sub queue_key_locked {
1.30 albertel 969: my ($queue,$key,$cdom,$cnum)=@_;
1.33 albertel 970: if (!defined($cdom) || !defined($cnum)) {
971: my (undef,$cid)=&Apache::lonxml::whichuser();
972: $cnum=$env{'course.'.$cid.'.num'};
973: $cdom=$env{'course.'.$cid.'.domain'};
974: }
1.14 albertel 975: my ($key_locked,$value)=
1.30 albertel 976: &Apache::lonnet::get($queue,["$key\0locked"],$cdom,$cnum);
1.14 albertel 977: if ($key_locked eq "$key\0locked") {
978: return $value;
979: }
980: return undef;
981: }
982:
983: sub pick_from_queue_data {
1.30 albertel 984: my ($queue,$check_section,$queuedata,$cdom,$cnum)=@_;
985: foreach my $key (keys(%$queuedata)) {
1.14 albertel 986: my ($symb,$uname,$udom)=&decode_queue_key($key);
987: if ($check_section) {
988: my $section=&Apache::lonnet::getsection($uname,$udom);
1.17 albertel 989: if ($section eq $check_section) {
1.33 albertel 990: &Apache::lonxml::debug("my sec");
1.15 albertel 991: next;
992: }
1.14 albertel 993: }
1.30 albertel 994: my $slot=$queuedata->{$key}[0];
1.14 albertel 995: my %slot_data=&Apache::lonnet::get_slot($slot);
1.15 albertel 996: if ($slot_data{'endtime'} > time) {
1.33 albertel 997: &Apache::lonxml::debug("not time");
1.15 albertel 998: next;
999: }
1.30 albertel 1000: if (&queue_key_locked($queue,$key,$cdom,$cnum)) {
1.33 albertel 1001: &Apache::lonxml::debug("someone already has um.");
1.15 albertel 1002: next;
1003: }
1.14 albertel 1004: return $key;
1005: }
1006: return undef;
1007: }
1008:
1.15 albertel 1009: sub find_mid_grade {
1.30 albertel 1010: my ($queue,$symb,$cdom,$cnum)=@_;
1.16 albertel 1011: my $todo=&Apache::lonnet::unescape($env{'form.gradingkey'});
1.15 albertel 1012: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1013: if ($todo) {
1.30 albertel 1014: my $who=&queue_key_locked($queue,$todo,$cdom,$cnum);
1.15 albertel 1015: if ($who eq $me) { return $todo; }
1016: }
1017: my $regexp="^$symb\0.*\0locked\$";
1.30 albertel 1018: my %locks=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.15 albertel 1019: foreach my $key (keys(%locks)) {
1020: my $who=$locks{$key};
1021: if ($who eq $me) {
1022: $todo=$key;
1023: $todo=~s/\0locked$//;
1024: return $todo;
1025: }
1026: }
1027: return undef;
1028: }
1029:
1.32 albertel 1030: sub lock_key {
1031: my ($queue,$todo)=@_;
1032: my $me=$env{'user.name'}.'@'.$env{'user.domain'};
1033: my (undef,$cid)=&Apache::lonxml::whichuser();
1034: my $cnum=$env{'course.'.$cid.'.num'};
1035: my $cdom=$env{'course.'.$cid.'.domain'};
1036: my $success=&Apache::lonnet::newput($queue,{"$todo\0locked"=> $me},
1037: $cdom,$cnum);
1.33 albertel 1038: &Apache::lonxml::debug("success $success $todo");
1.32 albertel 1039: if ($success eq 'ok') {
1040: return 1;
1041: }
1042: return 0;
1043: }
1044:
1.14 albertel 1045: sub get_from_queue {
1.30 albertel 1046: my ($queue)=@_;
1.14 albertel 1047: my $result;
1048: my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
1049: my $cnum=$env{'course.'.$cid.'.num'};
1050: my $cdom=$env{'course.'.$cid.'.domain'};
1.32 albertel 1051: my $todo=&find_mid_grade($queue,$symb,$cdom,$cnum);
1.33 albertel 1052: &Apache::lonxml::debug("found ".join(':',&decode_queue_key($todo)));
1.16 albertel 1053: if ($todo) { return $todo; }
1.14 albertel 1054: while (1) {
1055: my $starttime=time;
1.30 albertel 1056: &Apache::lonnet::put($queue,{"$symb\0timestamp"=>$starttime},
1.14 albertel 1057: $cdom,$cnum);
1.33 albertel 1058: &Apache::lonxml::debug("$starttime");
1.14 albertel 1059: my $regexp="^$symb\0queue\0";
1.30 albertel 1060: my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
1.33 albertel 1061: #make a pass looking for a user _not_ in my section
1.14 albertel 1062: if ($env{'request.course.sec'}) {
1.33 albertel 1063: &Apache::lonxml::debug("sce");
1.30 albertel 1064: $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
1065: \%queue,$cdom,$cnum);
1.33 albertel 1066: &Apache::lonxml::debug("sce $todo");
1.14 albertel 1067: }
1.33 albertel 1068: # no one _not_ in our section so look for any user that is
1069: # ready for grading
1.14 albertel 1070: if (!$todo) {
1.33 albertel 1071: &Apache::lonxml::debug("no sce");
1.31 albertel 1072: $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
1073: \%queue,$cdom,$cnum);
1.33 albertel 1074: &Apache::lonxml::debug("no sce $todo");
1.14 albertel 1075: }
1076: # no user to grade
1077: if (!$todo) { last; }
1.33 albertel 1078: &Apache::lonxml::debug("got $todo");
1.14 albertel 1079: # otherwise found someone so lets try to lock them
1.32 albertel 1080: # unless someone else already picked them
1081: if (!&lock_key($queue,$todo)) { next; }
1.14 albertel 1082: my (undef,$endtime)=
1.30 albertel 1083: &Apache::lonnet::get($queue,["$symb\0timestamp"],
1.14 albertel 1084: $cdom,$cnum);
1.33 albertel 1085: &Apache::lonxml::debug("emd $endtime");
1.14 albertel 1086: # someone else already modified the queue,
1087: # perhaps our picked user wass already fully graded between
1088: # when we picked him and when we locked his record? so lets
1089: # double check.
1090: if ($endtime != $starttime) {
1091: my ($key,$value)=
1.30 albertel 1092: &Apache::lonnet::get($queue,["$todo"],
1.14 albertel 1093: $cdom,$cnum);
1.33 albertel 1094: &Apache::lonxml::debug("check $key .. $value");
1.14 albertel 1095: if ($key eq $todo && ref($value)) {
1096: } else {
1.30 albertel 1097: &Apache::lonnet::del($queue,["$todo\0locked"],
1.14 albertel 1098: $cdom,$cnum);
1.33 albertel 1099: &Apache::lonxml::debug("del");
1.14 albertel 1100: next;
1101: }
1102: }
1.33 albertel 1103: &Apache::lonxml::debug("last $todo");
1.14 albertel 1104: last;
1105: }
1106: return $todo;
1107: }
1108:
1.49 albertel 1109: sub select_user {
1110: my ($symb,$cid)=&Apache::lonxml::whichuser();
1111: my $result.='<table border="1">';
1112:
1113: &Apache::grades::init_perm();
1114: my ($classlist,$section,$fullname)=&Apache::grades::getclasslist('all',);
1115: &Apache::grades::reset_perm();
1116:
1117: foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
1118: my ($uname,$udom) = split(/:/,$student);
1119: my %status = &get_student_status($symb,$cid,$udom,$uname);
1120: my $queue = 'none';
1121: if ($status{'reviewqueue'} eq 'enqueued') {
1122: $queue = 'reviewqueue';
1123: } elsif ($status{'gradingqueue'} eq 'enqueued') {
1124: $queue = 'gradingqueue';
1125: }
1126: my $todo =
1127: &Apache::lonnet::escape(&encode_queue_key($symb,$udom,$uname));
1128: $result.=<<RESULT;
1129: <tr>
1130: <td>
1131: <form method="POST">
1132: <input type="hidden" name="gradingkey" value="$todo" />
1133: <input type="hidden" name="queue" value="$queue" />
1134: <input type="hidden" name="webgrade" value="no" />
1.52 albertel 1135: <input type="hidden" name="regrade" value="yes" />
1.49 albertel 1136: <input type="submit" name="submit" value="Regrade" />
1137: </form>
1138: <td>$fullname->{$student}</td>
1139: <td>
1140: RESULT
1141:
1142: if ($status{'status'} eq 'pass') {
1143: $result .= '<font color="green">'.&mt('Passed').'</font>';
1144: } elsif ($status{'status'} eq 'fail') {
1145: $result .= '<font color="red">'.&mt('Failed').'</font>';
1146: } elsif ($status{'status'} eq 'review') {
1147: $result .= '<font color="blue">'.&mt('Under Review').'</font>';
1148: } elsif ($status{'status'} eq 'ungraded') {
1149: $result .= &mt('Ungraded');
1150: } elsif ($status{'status'} ne '') {
1151: $result .= '<font color="orange">'.&mt('Unknown Status').'</font>';
1152: } else {
1153: $result.=" ";
1154: }
1155: if ($status{'version'}) {
1156: $result .= ' '.&mt('Version').' '.$status{'version'};
1157: }
1158: $result.= '</td><td>';
1159: if ($status{'reviewqueue'} eq 'enqueued') {
1160: $result .= &mt('Awaiting Review');
1161: } elsif ($status{'reviewqueue'} eq 'locked') {
1162: $result .= &mt('Under Review');
1163: } elsif ($status{'gradingqueue'} eq 'enqueued') {
1164: $result .= &mt('Awaiting Grading');
1165: } elsif ($status{'gradingqueue'} eq 'locked') {
1166: $result .= &mt('Being Graded');
1167: } else {
1168: $result.=" ";
1169: }
1170: $result.= '</td></tr>';
1171: }
1172: $result.='</table>';
1173: return $result;
1174: }
1175:
1176: sub get_student_status {
1177: my ($symb,$cid,$udom,$uname)=@_;
1178: my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
1179: $udom,$uname);
1180: my %status;
1181: $status{'status'}=$record{'resource.status'};
1182: $status{'version'}=$record{'resource.version'};
1183: $status{'grader'}=$record{'resource.grader'};
1184: $status{'reviewqueue'}=&check_queue_for_key($cid,'reviewqueue',
1185: &encode_queue_key($symb,$udom,$uname));
1186: $status{'gradingqueue'}=&check_queue_for_key($cid,'gradingqueue',
1187: &encode_queue_key($symb,$udom,$uname));
1188: return %status;
1189: }
1190:
1.1 albertel 1191: sub start_ClosingParagraph {
1192: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1193: my $result;
1194: if ($target eq 'web') {
1.13 albertel 1195: } elsif ($target eq 'webgrade') {
1196: &Apache::lonxml::startredirection();
1.1 albertel 1197: }
1198: return $result;
1199: }
1200:
1201: sub end_ClosingParagraph {
1202: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1203: my $result;
1204: if ($target eq 'web') {
1.13 albertel 1205: } elsif ($target eq 'webgrade') {
1206: &Apache::lonxml::endredirection();
1.1 albertel 1207: }
1208: return $result;
1209: }
1210:
1.19 albertel 1211: sub get_id {
1212: my ($parstack,$safeeval)=@_;
1213: my $id=&Apache::lonxml::get_param('id',$parstack,$safeeval);
1214: if (!$id) { $id=$Apache::lonxml::curdepth; }
1215: return $id;
1216: }
1217:
1.1 albertel 1218: my %dimension;
1219: sub start_Dimension {
1220: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1221: undef(%dimension);
1.19 albertel 1222: my $dim_id=&get_id($parstack,$safeeval);
1.9 albertel 1223: $Apache::bridgetask::dimension=$dim_id;
1224: push(@Apache::bridgetask::dimensionlist,$dim_id);
1225: undef(@Apache::bridgetask::instance);
1.20 albertel 1226: $Apache::bridgetask::dimensionmandatory{$dim_id}=
1227: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.54 albertel 1228: &Apache::lonxml::startredirection();
1229: return &internal_location($dim_id);
1.1 albertel 1230: }
1231:
1.13 albertel 1232: sub get_instance {
1233: &Apache::response::pushrandomnumber();
1234: my @order=&Math::Random::random_permutation(@{$dimension{'instances'}});
1.29 albertel 1235: my $num=@order;
1236: my $version=&get_version();
1237: my $which=($version-1)%$num;
1238: return $order[$which];
1.13 albertel 1239: }
1240:
1.18 albertel 1241: {
1242: my $last_link;
1243: sub end_Dimension {
1244: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.54 albertel 1245: my $result=&Apache::lonxml::endredirection();
1.25 albertel 1246: my $dim=&get_id($parstack,$safeeval);
1.19 albertel 1247: my $instance=&get_instance();
1.25 albertel 1248: my $version=&get_version();
1.18 albertel 1249: if ($target eq 'web') {
1.47 albertel 1250: @Apache::scripttag::parser_env = @_;
1251: $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
1252: @Apache::scripttag::parser_env = @_;
1253: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
1.26 albertel 1254: if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' ||
1255: $Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
1.54 albertel 1256:
1257: my $dim_status=$Apache::lonhomework::history{"resource.$version.$dim.status"};
1258: my $mandatory='Mandatory';
1259: if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') {
1260: $mandatory='Optional';
1261: }
1262: my $dim_info="<div class='$dim_status'>\n";
1263: if ($dim_status eq 'pass') {
1264: $dim_info.='<h3>Question : you passed this '.$mandatory.' question</h3>';
1265: }
1266: if ($dim_status eq 'fail') {
1267: $dim_info.='<h3>Question : you did not pass this '.$mandatory.' question</h3>';
1268: }
1269: my $man_count=0;
1270: my $opt_count=0;
1271: my $opt_passed=0;
1272: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1273: if ($dimension{$instance.'.criteria.'.$id.'.mandatory'}
1274: eq 'N') {
1275: $opt_count++;
1276: if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
1277: $opt_passed++;
1278: }
1279: } else {
1280: $man_count++;
1281: }
1282: }
1283: my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
1284: $parstack,$safeeval);
1285: if ($opt_req !~ /\S/) { $opt_req='0'; }
1286: $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>";
1287:
1288: my $internal_location=&internal_location($dim);
1289: $result=~s/\Q$internal_location\E/$dim_info/;
1290:
1.22 albertel 1291: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.25 albertel 1292: my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
1293: my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"};
1.53 albertel 1294: my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
1295: if ($mandatory) {
1296: $mandatory='Mandatory';
1297: } else {
1298: $mandatory='Optional';
1299: }
1.22 albertel 1300: if ($status eq 'fail') {
1301: } elsif ($status eq 'pass') {
1302: } else {
1.49 albertel 1303: &Apache::lonxml::error("Student viewing a graded bridgetask was shown a status of $status");
1.22 albertel 1304: }
1.53 albertel 1305: my $status_display=$status;
1306: $status_display=~s/^([a-z])/uc($1)/e;
1.54 albertel 1307: @Apache::scripttag::parser_env = @_;
1.53 albertel 1308: $result.='<div class="'.$status.'"><h4>'.$mandatory.
1.54 albertel 1309: ' Criteria</h4><p>';
1310: @Apache::scripttag::parser_env = @_;
1311: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
1312: $result.='</p><p class="grade">'.$status_display.'</p>';
1.25 albertel 1313: if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
1.53 albertel 1314: $result.='<p class="comment">'.$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'</p>';
1.22 albertel 1315: }
1.53 albertel 1316: $result.='</div>';
1.22 albertel 1317: }
1318: }
1.18 albertel 1319: } elsif ($target eq 'webgrade') {
1.47 albertel 1320: # in case of any side effects that we need
1321: @Apache::scripttag::parser_env = @_;
1322: &Apache::scripttag::xmlparse($dimension{'intro'});
1323: @Apache::scripttag::parser_env = @_;
1324: &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
1.18 albertel 1325: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1326: my $link='criteria_'.$instance.'_'.$id;
1.25 albertel 1327: my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
1.19 albertel 1328: $result.='<tr><td width="100%" valign="top">'.
1.18 albertel 1329: '<a name="'.$link.'" />'.
1330: '<a name="next_'.$last_link.'" />'.
1.47 albertel 1331: '<br /><textarea enabled="false" style="width:100%" rows="8" width="25" wrap="hard">';
1332: @Apache::scripttag::parser_env = @_;
1333: $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
1334: $result.='</textarea>'.
1.18 albertel 1335: #$dimension{$instance.'.criteria.'.$id}.
1336: '</td>'.
1.19 albertel 1337: '<td><nobr>Additional Comment for Student</nobr> <br />'.
1.25 albertel 1338: '<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 1339: '</td>'.
1340: '<td>'.
1.47 albertel 1341: '<nobr><label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" '.($status eq 'ungraded' || !$status ? 'checked="checked"':'').' />'.&mt('Ungraded').'</label></nobr><br />'.
1.30 albertel 1342: '<label><input type="radio" name="HWVAL_'.$link.'" value="pass" '.($status eq 'pass' ? 'checked="checked"':'').' />'.&mt('Pass').'</label><br />'.
1343: '<label><input type="radio" name="HWVAL_'.$link.'" value="fail" '.($status eq 'fail' ? 'checked="checked"':'').' />'.&mt('Fail').'</label><br />'.
1344: '<label><input type="radio" name="HWVAL_'.$link.'" value="review" '.($status eq 'review' ? 'checked="checked"':'').' />'.&mt('Review').'</label><br />'.
1.18 albertel 1345: '</td>'.
1346: '<td>'.
1347: '<a href="#'.$last_link.'">Prev</a><br />'.
1.20 albertel 1348: '<a href="#next_'.$link.'">Next</a><br /><br /><br />'.
1349: '<input type="submit" name="next" value="'.
1350: &mt('Done').'" /> '.
1.30 albertel 1351: '<input type="submit" name="stop" value="'.
1352: &mt('Stop').'" /> '.
1.18 albertel 1353: '</td></tr>';
1.22 albertel 1354: $result.='<tr><td colspan="4">';
1355: my (undef,undef,$udom,$uname) = &Apache::lonxml::whichuser();
1.52 albertel 1356: my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio/';
1.43 albertel 1357: foreach my $partial_file (split(',',$Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"})) {
1.22 albertel 1358: my $file=$file_url.$partial_file;
1.52 albertel 1359: $file=~s|/+|/|g;
1.22 albertel 1360: &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
1.48 albertel 1361: $result.='<nobr><a href="'.$file.'" target="lonGRDs"><img src="'.
1.22 albertel 1362: &Apache::loncommon::icon($file).'" border=0"> '.$file.
1.48 albertel 1363: '</a></nobr> ';
1.22 albertel 1364: }
1365: $result.='</td></tr>';
1.18 albertel 1366: $last_link=$link;
1367: }
1.22 albertel 1368: } elsif ($target eq 'grade' && $env{'form.webgrade'}) {
1.19 albertel 1369: my $optional_passed=0;
1.20 albertel 1370: my $mandatory_failed=0;
1371: my $ungraded=0;
1372: my $review=0;
1.19 albertel 1373: foreach my $id (@{$dimension{$instance.'.criterias'}}) {
1.25 albertel 1374: my $status=$Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.status"}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id};
1375: $Apache::lonhomework::results{"resource.$version.$dim.$instance.$id.comment"}=$env{'form.HWVAL_comment_criteria_'.$instance.'_'.$id};
1.20 albertel 1376: my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
1377: if ($status eq 'pass') {
1378: if (!$mandatory) { $optional_passed++; }
1379: } elsif ($status eq 'fail') {
1380: if ($mandatory) { $mandatory_failed++; }
1.21 albertel 1381: } elsif ($status eq 'review') {
1382: $review++;
1.20 albertel 1383: } elsif ($status eq 'ungraded') {
1384: $ungraded++;
1.21 albertel 1385: } else {
1.47 albertel 1386: $ungraded++;
1.19 albertel 1387: }
1388: }
1.20 albertel 1389: if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
1390: $mandatory_failed++;
1391: }
1.21 albertel 1392: &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 1393: if ($review) {
1.25 albertel 1394: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1395: 'review';
1.20 albertel 1396: } elsif ($ungraded) {
1.25 albertel 1397: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1398: 'ungraded';
1.20 albertel 1399: } elsif ($mandatory_failed) {
1.25 albertel 1400: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1401: 'fail';
1.20 albertel 1402: } else {
1.25 albertel 1403: $Apache::lonhomework::results{"resource.$version.$dim.status"}=
1.22 albertel 1404: 'pass';
1.20 albertel 1405: }
1.13 albertel 1406: }
1.18 albertel 1407: return $result;
1.1 albertel 1408: }
1409: }
1410:
1411: sub start_IntroParagraph {
1412: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1413: my $result;
1.13 albertel 1414: if ($target eq 'web' || $target eq 'webgrade') {
1.47 albertel 1415: if ($tagstack->[-2] eq 'Dimension') {
1416: $dimension{'intro'}=&Apache::lonxml::get_all_text('/introparagraph',$parser);
1417:
1418: } elsif ($target eq 'webgrade') {
1419: &Apache::lonxml::get_all_text('/introparagraph',$parser);
1.1 albertel 1420: }
1.47 albertel 1421:
1.1 albertel 1422: }
1423: return $result;
1424: }
1425:
1426: sub end_IntroParagraph {
1427: }
1428:
1429: sub start_Instance {
1430: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.19 albertel 1431: my $id=&get_id($parstack,$safeeval);
1432: push(@{$dimension{'instances'}},$id);
1433: push(@Apache::bridgetask::instance,$id);
1434: push(@Apache::bridgetask::instancelist,$id);
1.20 albertel 1435: $dimension{$id.'.optionalrequired'}=
1.19 albertel 1436: &Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval);
1.1 albertel 1437: return '';
1438: }
1439:
1440: sub end_Instance {
1441: }
1442:
1443: sub start_InstanceText {
1444: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.47 albertel 1445: my $instance_id=$Apache::bridgetask::instance[-1];
1446: my $text=&Apache::lonxml::get_all_text('/instancetext',$parser);
1.13 albertel 1447: if ($target eq 'web' || $target eq 'webgrade') {
1.47 albertel 1448: $dimension{$instance_id.'.text'}=$text;
1.1 albertel 1449: }
1450: return '';
1451: }
1452:
1453: sub end_InstanceText {
1454: return '';
1455: }
1456:
1457: sub start_Criteria {
1458: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.9 albertel 1459: my $instance_id=$Apache::bridgetask::instance[-1];
1.47 albertel 1460: my $criteria=&Apache::lonxml::get_all_text('/criteria',$parser);
1.21 albertel 1461: if ($target eq 'web' || $target eq 'webgrade' || $target eq 'grade') {
1.19 albertel 1462: my $id=&get_id($parstack,$safeeval);
1.1 albertel 1463: $dimension{$instance_id.'.criteria.'.$id}=$criteria;
1.19 albertel 1464: $dimension{$instance_id.'.criteria.'.$id.'.mandatory'}=
1465: &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
1.1 albertel 1466: push(@{$dimension{$instance_id.'.criterias'}},$id);
1467: }
1468: return '';
1469: }
1470:
1.47 albertel 1471: sub end_Criteria {
1472: }
1473:
1.4 albertel 1474: sub proctor_validation_screen {
1475: my ($slot) = @_;
1476: my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
1.5 albertel 1477: my $url=&Apache::lonnet::studentphoto($domain,$user,'jpg');
1.44 albertel 1478: my $name=&Apache::loncommon::plainname($user,$domain);
1479:
1.4 albertel 1480: my $msg;
1.11 albertel 1481: if ($env{'form.proctorpassword'}) {
1.4 albertel 1482: $msg='<p><font color="red">'.&mt("Failed to authenticate the proctor.")
1483: .'</font></p>';
1484: }
1.47 albertel 1485: if (!$env{'form.proctordomain'}) { $env{'form.proctordomain'}=$domain; }
1.4 albertel 1486: my $result= (<<ENDCHECKOUT);
1487: <h2>Proctor Validation</h2>
1488: <p>Your room's proctor needs to validate your access to this resource.</p>
1489: $msg
1.11 albertel 1490: <form name="checkout" method="POST" action="$env{'request.uri'}">
1.4 albertel 1491: <input type="hidden" name="validate" value="yes" />
1492: <input type="hidden" name="submitted" value="yes" />
1493: <table>
1.44 albertel 1494: <tr><td>Proctor's Username:</td><td><input type="string" name="proctorname" value="$env{'form.proctorname'}" /></td></tr>
1.4 albertel 1495: <tr><td>Password:</td><td><input type="password" name="proctorpassword" value="" /></td></tr>
1.46 albertel 1496: <tr><td>Proctor's Domain:</td><td><input type="string" name="proctordomain" value="$env{'form.proctordomain'}" /></td></tr>
1.4 albertel 1497: </table>
1498: <input type="submit" name="checkoutbutton" value="Validate" /><br />
1.44 albertel 1499: <table border="1">
1500: <tr><td>
1501: <table>
1502: <tr><td colspan="2">Student who should be logged in is:</td></tr>
1503: <tr><td>Name:</td><td>$name</td></tr>
1.45 albertel 1504: <tr><td>Student ID:</td><td>$env{'environment.id'}</td></tr>
1.44 albertel 1505: <tr><td>Usename</td><td>$user\@$domain</td></tr>
1506: <tr><td colspan="2"><img src="$url" /></td></tr>
1507: </table>
1508: </tr></td>
1509: </table>
1.4 albertel 1510: </form>
1511: ENDCHECKOUT
1512: return $result;
1513: }
1514:
1.1 albertel 1515: 1;
1516: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>