[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 10 May 2005 16:03:44 -0000
This is a MIME encoded message
--albertel1115741024
Content-Type: text/plain
albertel Tue May 10 12:03:44 2005 EDT
Modified files:
/loncom/homework bridgetask.pm
Log:
- grding code written not yet tested though
--albertel1115741024
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20050510120344.txt"
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.19 loncom/homework/bridgetask.pm:1.20
--- loncom/homework/bridgetask.pm:1.19 Mon May 9 17:55:01 2005
+++ loncom/homework/bridgetask.pm Tue May 10 12:03:44 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.19 2005/05/09 21:55:01 albertel Exp $
+# $Id: bridgetask.pm,v 1.20 2005/05/10 16:03:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -48,6 +48,8 @@
$Apache::bridgetask::dimension='';
# list of all Dimension ids seen
@Apache::bridgetask::dimensionlist=();
+ # mandatory attribute of all Dimensions seen
+ %Apache::bridgetask::dimensionmandatory=();
# list of all current Instance ids
@Apache::bridgetask::instance=();
# list of all Instance ids seen in this problem
@@ -180,8 +182,7 @@
}
} elsif ($target eq 'webgrade') {
$result.=$head_tag_start.$body_tag_start.$form_tag_start;
- $result.=
- '<input type="hidden" name="grade_target" value="webgrade" />';
+ $result.='<input type="hidden" name="webgrade" value="yes" />';
$result.=&show_queue();
my $todo=&get_from_queue();
if ($todo) {
@@ -231,9 +232,10 @@
$result.=&Apache::lonxml::xmlend().'</html>';
}
}
- if ($target eq 'grade') {
+ if ($target eq 'grade' && !$env{'form.webgrade'}) {
my $award='SUBMITTED';
- &Apache::essayresponse::file_submission('0','bridgetask','portfiles',\$award);
+ &Apache::essayresponse::file_submission('0','bridgetask',
+ 'portfiles',\$award);
if ($award eq 'SUBMITTED' &&
$Apache::lonhomework::results{"resource.0.bridgetask.portfiles"}) {
$Apache::lonhomework::results{"resource.0.tries"}=
@@ -246,14 +248,60 @@
&add_to_queue();
}
}
+ if ($target eq 'grade' && $env{'form.webgrade'}) {
+ my $optional_required=
+ &Apache::lonxml::get_param('OptionalRequired',$parstack,
+ $safeeval);
+ my $optional_passed=0;
+ my $mandatory_failed=0;
+ my $ungraded=0;
+ my $review=0;
+ foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
+ my $status=
+ $Apache::lonhomeork::results{"resource.$dim_id.status"};
+ my $mandatory=
+ ($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
+ if ($status eq 'pass') {
+ if (!$mandatory) { $optional_passed++; }
+ } elsif ($status eq 'fail') {
+ if ($mandatory) { $mandatory_failed++; }
+ } elsif ($status eq 'ungraded') {
+ $ungraded++;
+ } elsif ($status eq 'review') {
+ $review++;
+ }
+ }
+ if ($optional_passed < $optional_required) {
+ $mandatory_failed++;
+ }
+ $Apache::lonhomeork::results{'resource.grader'}=
+ $env{'user.name'}.'@'.$env{'user.domain'};
+ if ($review) {
+ $Apache::lonhomeork::results{'resource.status'}='review';
+ &move_to_review_queue();
+ } elsif ($ungraded) {
+ $Apache::lonhomeork::results{'resource.status'}='ungraded';
+ &check_queue_unlock();
+ } elsif ($mandatory_failed) {
+ $Apache::lonhomeork::results{'resource.status'}='fail';
+ $Apache::lonhomework::results{"resource.0.award"}='EXACT_ANS';
+ &remove_from_queue();
+ } else {
+ $Apache::lonhomeork::results{'resource.status'}='pass';
+ $Apache::lonhomework::results{"resource.0.award"}='INCORRECT';
+ &remove_from_queue();
+ }
+ }
} elsif ($target eq 'webgrade') {
$result.="</table>\n<hr />";
- $result.='<input type="submit" name="next" value="'.
- &mt('Save & Next').'" /> ';
- $result.='<input type="submit" name="end" value="'.
- &mt('Save & Stop Grading').'" /> ';
- $result.='<input type="submit" name="end" value="'.
- &mt('Throw Away & Stop Grading').'" /> ';
+ #$result.='<input type="submit" name="next" value="'.
+ # &mt('Save & Next').'" /> ';
+ #$result.='<input type="submit" name="end" value="'.
+ # &mt('Save & Stop Grading').'" /> ';
+ #$result.='<input type="submit" name="throwaway" value="'.
+ # &mt('Throw Away & Stop Grading').'" /> ';
+ #$result.='<input type="submit" name="save" value="'.
+ # &mt('Save Partial Grade and Continue Grading').'" /> ';
$result.='</form>'.&Apache::loncommon::endbodytag().'</html>';
} elsif ($target eq 'meta') {
$result.='<parameter part="0" package="Task"></parameter>'."\n";
@@ -290,7 +338,8 @@
my $cdom=$env{'course.'.$cid.'.domain'};
my $regexp="^$symb\0";
my %queue=&Apache::lonnet::dump('gradingqueue',$cdom,$cnum,$regexp);
- $result.="\n<h3>Current Queue</h3><table><tr><th>resource</th><th>user</th><th>type</th><th>data</th></tr>";
+ $result.="\n<h3>Current Queue</h3><table><tr><th>resource</th>".
+ "<th>user</th><th>type</th><th>data</th></tr>";
foreach my $key (sort(keys(%queue))) {
if ($key=~/locked$/) {
my ($symb,$uname,$udom) = &decode_queue_key($key);
@@ -309,7 +358,9 @@
$result.="<tr><td>$title</td><td>$uname</td><td>";
my $slot=$queue{$key}->[0];
my %slot_data=&Apache::lonnet::get_slot($slot);
- $result.='<td>queue entry</td><td>End time: '.&Apache::lonlocal::locallocaltime($slot_data{'endtime'})."</td></tr>";
+ $result.='<td>queue entry</td><td>End time: '.
+ &Apache::lonlocal::locallocaltime($slot_data{'endtime'}).
+ "</td></tr>";
}
}
$result.="</table><hr />\n";
@@ -484,6 +535,8 @@
$Apache::bridgetask::dimension=$dim_id;
push(@Apache::bridgetask::dimensionlist,$dim_id);
undef(@Apache::bridgetask::instance);
+ $Apache::bridgetask::dimensionmandatory{$dim_id}=
+ &Apache::lonxml::get_param('Mandatory',$parstack,$safeeval);
return '';
}
@@ -507,6 +560,7 @@
} elsif ($target eq 'webgrade') {
foreach my $id (@{$dimension{$instance.'.criterias'}}) {
my $link='criteria_'.$instance.'_'.$id;
+ my $status=$Apache::lonhomeork::history{'resource.'.$instance.'.'.$id.'.status'};
$result.='<tr><td width="100%" valign="top">'.
'<a name="'.$link.'" />'.
'<a name="next_'.$last_link.'" />'.
@@ -514,29 +568,53 @@
#$dimension{$instance.'.criteria.'.$id}.
'</td>'.
'<td><nobr>Additional Comment for Student</nobr> <br />'.
- '<textarea style="width:100%" rows="8" width="25" wrap="hard" name="HWVAL_comment_'.$link.'"></textarea>'.
+ '<textarea style="width:100%" rows="8" width="25" wrap="hard" name="HWVAL_comment_'.$link.'">'.&HTML::Entities::encode($Apache::lonhomeork::history{'resource.'.$instance.'.'.$id.'.comment'}).'</textarea>'.
'</td>'.
'<td>'.
- '<nobr><label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" />Ungraded</label></nobr><br />'.
- '<label><input type="radio" name="HWVAL_'.$link.'" value="pass" />Pass</label><br />'.
- '<label><input type="radio" name="HWVAL_'.$link.'" value="fail" />Fail</label><br />'.
- '<label><input type="radio" name="HWVAL_'.$link.'" value="review" />Review</label><br />'.
+ '<nobr><label><input type="radio" name="HWVAL_'.$link.'" value="ungraded" '.($status eq 'ungraded' || !$status ? 'checked="checked"':'').'/>Ungraded</label></nobr><br />'.
+ '<label><input type="radio" name="HWVAL_'.$link.'" value="pass" '.($status eq 'pass' ? 'checked="checked"':'').' />Pass</label><br />'.
+ '<label><input type="radio" name="HWVAL_'.$link.'" value="fail" '.($status eq 'fail' ? 'checked="checked"':'').' />Fail</label><br />'.
+ '<label><input type="radio" name="HWVAL_'.$link.'" value="review" '.($status eq 'review' ? 'checked="checked"':'').' />Review</label><br />'.
'</td>'.
'<td>'.
'<a href="#'.$last_link.'">Prev</a><br />'.
- '<a href="#next_'.$link.'">Next</a><br />'.
+ '<a href="#next_'.$link.'">Next</a><br /><br /><br />'.
+ '<input type="submit" name="next" value="'.
+ &mt('Done').'" /> '.
'</td></tr>';
$last_link=$link;
}
} elsif ($target eq 'grade') {
my $optional_passed=0;
+ my $mandatory_failed=0;
+ my $ungraded=0;
+ my $review=0;
foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- if ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'pass') {
- } elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'fail') {
- } elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'ungraded') {
- } elsif ($env{'form.HWVAL_criteria_'.$instance.'_'.$id} eq 'review') {
+ my $status=$Apache::lonhomeork::results{'resource.'.$instance.'.'.$id.'.status'}=$env{'form.HWVAL_criteria_'.$instance.'_'.$id};
+ $Apache::lonhomeork::results{'resource.'.$instance.'.'.$id.'.comment'}=$env{'form.HWVAL_comment_'.$instance.'_'.$id};
+ my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
+ if ($status eq 'pass') {
+ if (!$mandatory) { $optional_passed++; }
+ } elsif ($status eq 'fail') {
+ if ($mandatory) { $mandatory_failed++; }
+ } elsif ($status eq 'ungraded') {
+ $ungraded++;
+ } elsif ($status eq 'review') {
+ $review++;
}
}
+ if ($optional_passed < $dimension{$instance.'.optionalrequired'}) {
+ $mandatory_failed++;
+ }
+ if ($review) {
+ $Apache::lonhomeork::results{'resource.'.$instance.'.status'}='review';
+ } elsif ($ungraded) {
+ $Apache::lonhomeork::results{'resource.'.$instance.'.status'}='ungraded';
+ } elsif ($mandatory_failed) {
+ $Apache::lonhomeork::results{'resource.'.$instance.'.status'}='fail';
+ } else {
+ $Apache::lonhomeork::results{'resource.'.$instance.'.status'}='pass';
+ }
}
return $result;
}
@@ -570,7 +648,7 @@
push(@{$dimension{'instances'}},$id);
push(@Apache::bridgetask::instance,$id);
push(@Apache::bridgetask::instancelist,$id);
- $dimension{$instance_id.'.optionalrequired'}=
+ $dimension{$id.'.optionalrequired'}=
&Apache::lonxml::get_param('OptionalRequired',$parstack,$safeeval);
return '';
}
--albertel1115741024--