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

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

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