Annotation of loncom/homework/bridgetask.pm, revision 1.25

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>