--- loncom/homework/grades.pm 2003/07/11 14:45:59 1.111
+++ loncom/homework/grades.pm 2003/07/16 19:28:08 1.117
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.111 2003/07/11 14:45:59 ng Exp $
+# $Id: grades.pm,v 1.117 2003/07/16 19:28:08 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,6 +41,7 @@ use Apache::style;
use Apache::lonxml;
use Apache::lonnet;
use Apache::loncommon;
+use Apache::lonhtmlcommon;
use Apache::lonnavmaps;
use Apache::lonhomework;
use Apache::loncoursedata;
@@ -129,8 +130,8 @@ sub getclasslist {
my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
@{$classlist->{$_}};
# filter students according to status selected
- if ($filterlist && $ENV{'form.status'} ne 'Any') {
- if ($ENV{'form.status'} ne $status) {
+ if ($filterlist && $ENV{'form.Status'} ne 'Any') {
+ if ($ENV{'form.Status'} ne $status) {
delete ($classlist->{$_});
next;
}
@@ -391,7 +392,7 @@ sub listStudents {
}
function reLoadList(formname) {
- if (formname.saveStatusOld.value == pullDownSelection(formname.status)) {return;}
+ if (formname.saveStatusOld.value == pullDownSelection(formname.Status)) {return;}
formname.command.value = 'submission';
formname.submit();
}
@@ -417,7 +418,7 @@ LISTJAVASCRIPT
my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
my $gradeTable='
'."\n");
$request->print(&show_grading_menu_form($symb,$url))
if (($ENV{'form.command'} eq 'submission') ||
@@ -1390,7 +1394,7 @@ KEYWORDS
my ($partid,$respid) = split(/_/);
next if ($seen{$partid} > 0);
$seen{$partid}++;
- next if ($$handgrade{$_} =~ /:no$/);
+# next if ($$handgrade{$_} =~ /:no$/);
push @partlist,$partid;
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
@@ -1975,10 +1979,11 @@ sub viewgrades {
}
$result.= '
'."\n".
'
'.
- '
Fullname
Username
Domain
'."\n";
+ '
Fullname (Username)
'."\n";
my (@parts) = sort(&getpartlist($url));
foreach my $part (@parts) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
+ next if ($display =~ /Number of Attempts/);
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
if ($display =~ /^Partial Credit Factor/) {
my ($partid) = &split_part_type($part);
@@ -2009,7 +2014,8 @@ sub viewgrades {
'onClick="javascript:submit();" TARGET=_self />'."\n";
if (scalar(%$fullname) eq 0) {
my $colspan=3+scalar(@parts);
- $result='There are no students in section "'.$ENV{'form.section'}.'" with enrollment status "'.$ENV{'form.status'}.'" to modify or grade.';
+ $result='There are no students in section "'.$ENV{'form.section'}.
+ '" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade.';
}
$result.=&show_grading_menu_form($symb,$url);
return $result;
@@ -2023,8 +2029,8 @@ sub viewstudentgrade {
my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
my $result='
';
@@ -2609,7 +2615,7 @@ LISTJAVASCRIPT
$result.=''."\n".
''."\n";
- $result.=' View Problems: no '."\n".
+ $result.=' View Problems Text: no '."\n".
' yes '." \n";
$result.=' Submission Details: '.
@@ -2618,7 +2624,7 @@ LISTJAVASCRIPT
' all details'."\n";
$result.=''."\n".
- ''."\n".
+ ''."\n".
''."\n".
''."\n".
''."\n".
@@ -2663,53 +2669,22 @@ LISTJAVASCRIPT
sub getSymbMap {
my ($request) = @_;
my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db',
- $ENV{'request.course.fn'}.'_parms.db',1, 1);
-
- my $res = $navmap->firstResource(); # temp resource to access constants
+ $ENV{'request.course.fn'}.'_parms.db');
$navmap->init();
- # End navmap using boilerplate
-
- my $iterator = $navmap->getIterator(undef, undef, undef, 1);
- my $depth = 1;
- $iterator->next(); # ignore first BEGIN_MAP
- my $curRes = $iterator->next();
-
my %symbx = ();
my @titles = ();
- my $minder=0;
- while ($depth > 0) {
- if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
- if ($curRes == $iterator->END_MAP()) { $depth--; }
+ my $minder = 0;
- if (ref($curRes) && $curRes->is_map()) {
- my ($mapUrl, $id, $resUrl) = split(/___/, $curRes->symb()); # check map contains at least one problem
- my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
-
- my $mapiterator = $navmap->getIterator($map->map_start(),
- $map->map_finish());
-
- my $mapdepth = 1;
- my $countProblems = 0;
- $mapiterator->next(); # skip the first BEGIN_MAP
- my $mapcurRes = $mapiterator->next(); # for "current resource"
- while ($mapdepth > 0) {
- if($mapcurRes == $mapiterator->BEGIN_MAP) { $mapdepth++; }
- if($mapcurRes == $mapiterator->END_MAP) { $mapdepth--; }
-
- if (ref($mapcurRes) && $mapcurRes->is_problem() && !$mapcurRes->randomout) {
- $countProblems++;
- }
- $mapcurRes = $mapiterator->next();
- }
- if ($countProblems > 0) {
- my $title = $curRes->compTitle();
- push @titles,$minder.'.'.$title; # minder, just in case two titles are identical
- $symbx{$minder.'.'.$title} = $curRes->symb();
- $minder++;
- }
- }
- $curRes = $iterator->next();
+ # Gather every sequence that has problems.
+ my @sequences = $navmap->retrieveResources(undef, sub { shift->is_map(); }, 1);
+ for my $sequence ($navmap->getById('0.0'), @sequences) {
+ if ($navmap->hasResource($sequence, sub { shift->is_problem(); }, 0) ) {
+ my $title = $minder.'.'.$sequence->compTitle();
+ push @titles, $title; # minder in case two titles are identical
+ $symbx{$title} = $sequence->symb();
+ $minder++;
+ }
}
$navmap->untieHashes();
@@ -2785,21 +2760,18 @@ sub displayPage {
if ($ENV{'form.vProb'} eq 'yes') {
$studentTable.=&show_problem($request,$symbx,$uname,$udom,1);
} else {
- my $companswer = &Apache::loncommon::get_student_answers(
- $symbx,$uname,$udom,$ENV{'request.course.id'});
+ my $companswer = &Apache::loncommon::get_student_answers($symbx,$uname,$udom,$ENV{'request.course.id'});
$companswer =~ s|||g;
-
# while ($companswer =~ /()/s) { #\n");
# }
-# $companswer =~ s/
/
/g;
+# $companswer =~ s|
|
|g;
$studentTable.=' '.$title.' Correct answer: '.$companswer;
}
my %record = &Apache::lonnet::restore($symbx,$ENV{'request.course.id'},$udom,$uname);
-
if ($ENV{'form.lastSub'} eq 'datesub') {
if ($record{'version'} eq '') {
$studentTable.=' No recorded submission for this problem ';
@@ -2809,6 +2781,10 @@ sub displayPage {
'
Date/Time
'.
'
Submission
'.
'
Status
';
+ my %responseType = ();
+ foreach my $partid (@{$parts}) {
+ $responseType{$partid} = $curRes->responseType($partid);
+ }
my ($version);
for ($version=1;$version<=$record{'version'};$version++) {
my $timestamp = scalar(localtime($record{$version.':timestamp'}));
@@ -2818,13 +2794,11 @@ sub displayPage {
foreach my $partid (@{$parts}) {
my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
next if ($record{"$version:resource.$partid.solved"} eq '');
-# next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' &&
-# $record{"$version:resource.$partid.solved"} eq '');
$displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ?
'Part '.$partid.' '.
($record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' :
'Trial '.$record{"$version:resource.$partid.tries"}).' '.
- $record{$version.':'.$matchKey[0]}.' ' : '';
+ &cleanRecord($record{$version.':'.$matchKey[0]},$responseType{$partid}).' ' : '';
$displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ?
'Part '.$partid.' '.
$record{"$version:resource.$partid.award"}.'/'.
@@ -2871,6 +2845,26 @@ sub displayPage {
return '';
}
+sub cleanRecord {
+ my ($answer,$response) = @_;
+ if ($response eq 'option') {
+ my (@IDs,@ans);
+ foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
+ my ($optionID,$ans) = split(/=/);
+ push @IDs,$optionID.'';
+ push @ans,$ans;
+ }
+ my $grayFont = '';
+ return '
'.
+ '
Answer
'.
+ (join '
',@ans).'
'.
+ '
'.$grayFont.'Option ID
'.$grayFont.
+ (join '
'.$grayFont,@IDs).'
'.
+ '
';
+ }
+ return $answer;
+}
+
sub updateGradeByPage {
my ($request) = shift;
@@ -3338,12 +3332,17 @@ sub gradingmenu {
$request->print(<
- function checkChoice(formname) {
- var cmd = formname.command;
- formname.saveState.value = "saveCmd="+radioSelection(cmd)+":saveSec="+pullDownSelection(formname.section)+
- ":saveSub="+radioSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.status);
- if (cmd[0].checked || cmd[1].checked || cmd[2].checked || cmd[3].checked || cmd[4].checked) formname.submit();
- if (cmd[5].checked) {
+ function checkChoice(formname,val,cmdx) {
+ if (val <= 2) {
+ var cmd = radioSelection(formname.radioChoice);
+ } else {
+ cmd = cmdx;
+ }
+ formname.command.value = cmd;
+ formname.saveState.value = "saveCmd="+cmd+":saveSec="+pullDownSelection(formname.section)+
+ ":saveSub="+radioSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.Status);
+ if (val < 5) formname.submit();
+ if (val == 5) {
if (!checkReceiptNo(formname,'notOK')) { return false;}
formname.submit();
}
@@ -3360,7 +3359,6 @@ sub gradingmenu {
formname.receipt.focus();
return false;
}
- formname.command[5].checked = true;
return true;
}
@@ -3404,8 +3402,8 @@ GRADINGMENUJS
$resptype = $responsetype;
$hdgrade = $handgrade if ($handgrade eq 'yes');
$result.='
'."\n".
+ ' Section: ';
+
+ $result.='Student Status:'.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,undef);
+
+ if (ref($sections)) {
+ $result.=' (Section "no" implies the students were not assigned a section.) '
+ if (grep /no/,@$sections);
+ }
+ $result.='
';
- $result.='
'.
- '
'.
- '
'.
+ ' '.
- 'Handgrade/View Submission for a student by page/sequence
'."\n".
+ 'One student for whole page/sequence/folder'."\n";
- '
'.
- '
'.
+ ' '.
- 'Grade by section or class
'."\n".
+ 'All students in section/course for current resource'."\n";
- '
'."\n".
- ' Select section: ';
-
- $result.='Student Status:';
-
- $result.=' (Applies to the first three options only.)'."\n";
-
- if (ref($sections)) {
- $result.=' (Section "no" implies the students were not assigned a section.) '
- if (grep /no/,@$sections);
- }
- $result.='