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