--- loncom/homework/grades.pm 2006/03/19 21:29:50 1.335
+++ loncom/homework/grades.pm 2006/10/13 21:49:28 1.378
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.335 2006/03/19 21:29:50 albertel Exp $
+# $Id: grades.pm,v 1.378 2006/10/13 21:49:28 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,10 +36,13 @@ use Apache::lonhtmlcommon;
use Apache::lonnavmaps;
use Apache::lonhomework;
use Apache::loncoursedata;
-use Apache::lonmsg qw(:user_normal_msg);
+use Apache::lonmsg();
use Apache::Constants qw(:common);
use Apache::lonlocal;
use String::Similarity;
+use lib '/home/httpd/lib/perl';
+use LONCAPA;
+
use POSIX qw(floor);
my %oldessays=();
@@ -109,36 +112,34 @@ sub nameUserString {
#--- Indicate if a response type is coded handgraded or not. ---
sub response_type {
my ($symb) = shift;
- my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb);
- my $allkeys = &Apache::lonnet::metadata($url,'keys');
- my %vPart;
- foreach my $partid (&Apache::loncommon::get_env_multiple('form.vPart')) {
- $vPart{$partid}=1;
- }
- my %seen = ();
- my (@partlist,%handgrade,%responseType);
- foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
- if (/^\w+response_.*/ || /^Task_/) {
- my ($responsetype,$part) = split(/_/,$_,2);
- my ($partid,$respid) = split(/_/,$part);
- if ($responsetype eq 'Task') { $respid='0'; }
- if (&Apache::loncommon::check_if_partid_hidden($partid,$symb)) {
- next;
- }
- if (%vPart && !exists($vPart{$partid})) {
- next;
- }
- $responsetype =~ s/response$//; # make it compatible w/ navmaps - should move to that!!
- my ($value) = &Apache::lonnet::EXT('resource.'.$part.'.handgrade',$symb);
- $handgrade{$part} = ($value eq 'yes' ? 'yes' : 'no');
- if (!exists($responseType{$partid})) { $responseType{$partid}={}; }
- $responseType{$partid}->{$respid}=$responsetype;
- next if ($seen{$partid} > 0);
- $seen{$partid}++;
- push @partlist,$partid;
- }
- }
- return (\@partlist,\%handgrade,\%responseType);
+
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my $res = $navmap->getBySymb($symb);
+ my $partlist = $res->parts();
+ my (%response_types,%handgrade);
+ foreach my $part (@{ $partlist }) {
+ my @types = $res->responseType($part);
+ my @ids = $res->responseIds($part);
+ for (my $i=0; $i < scalar(@ids); $i++) {
+ $response_types{$part}{$ids[$i]} = $types[$i];
+ $handgrade{$part.'_'.$ids[$i]} =
+ &Apache::lonnet::EXT('resource.'.$part.'_'.$ids[$i].
+ '.handgrade',$symb);
+ }
+ }
+ return ($partlist,\%handgrade,\%response_types);
+}
+
+sub flatten_responseType {
+ my ($responseType) = @_;
+ my @part_response_id =
+ map {
+ my $part = $_;
+ map {
+ [$part,$_]
+ } sort(keys(%{ $responseType->{$part} }));
+ } sort(keys(%$responseType));
+ return @part_response_id;
}
sub get_display_part {
@@ -165,25 +166,26 @@ sub showResourceInfo {
my %resptype = ();
my $hdgrade='no';
my %partsseen;
- for my $part_resID (sort keys(%$handgrade)) {
- my $handgrade=$$handgrade{$part_resID};
- my ($partID,$resID) = split(/_/,$part_resID);
- my $responsetype = $responseType->{$partID}->{$resID};
- $hdgrade = $handgrade if ($handgrade eq 'yes');
- $result.='
';
- if ($checkboxes) {
- if (exists($partsseen{$partID})) {
- $result.=" | ";
- } else {
- $result.=" | ";
+ foreach my $partID (sort keys(%$responseType)) {
+ foreach my $resID (sort keys(%{ $responseType->{$partID} })) {
+ my $handgrade=$$handgrade{$partID.'_'.$resID};
+ my $responsetype = $responseType->{$partID}->{$resID};
+ $hdgrade = $handgrade if ($handgrade eq 'yes');
+ $result.='
';
+ if ($checkboxes) {
+ if (exists($partsseen{$partID})) {
+ $result.=" | ";
+ } else {
+ $result.=" | ";
+ }
+ $partsseen{$partID}=1;
}
- $partsseen{$partID}=1;
- }
- my $display_part=&get_display_part($partID,$symb);
- $result.='Part: '.$display_part.' '.
- $resID.' | '.
- 'Type: '.$responsetype.' |
';
+ my $display_part=&get_display_part($partID,$symb);
+ $result.='Part: '.$display_part.' '.
+ $resID.' | '.
+ 'Type: '.$responsetype.' | ';
# 'Handgrade: '.$handgrade.' | ';
+ }
}
$result.=''."\n";
return $result,$responseType,$hdgrade,$partlist,$handgrade;
@@ -209,7 +211,8 @@ sub get_order {
#--- Currently filters option/rank/radiobutton/match/essay/Task
# response types only.
sub cleanRecord {
- my ($answer,$response,$symb,$partid,$respid,$record,$order,$version) = @_;
+ my ($answer,$response,$symb,$partid,$respid,$record,$order,$version,
+ $uname,$udom) = @_;
my $grayFont = '';
if ($response =~ /^(option|rank)$/) {
my %answer=&Apache::lonnet::str2hash($answer);
@@ -293,7 +296,7 @@ sub cleanRecord {
} elsif ( $response eq 'Task') {
if ( $answer eq 'SUBMITTED') {
my $files = $record->{$version."resource.$respid.$partid.bridgetask.portfiles"};
- my $result = &Apache::bridgetask::file_list($files);
+ my $result = &Apache::bridgetask::file_list($files,$uname,$udom);
return $result;
} elsif ( grep(/^\Q$version\E.*?\.instance$/, keys(%{$record})) ) {
my @matches = grep(/^\Q$version\E.*?\.instance$/,
@@ -585,7 +588,7 @@ sub verifyreceipt {
my $receipt = &Apache::lonnet::recprefix($courseid).'-'.
$env{'form.receipt'};
$receipt =~ s/[^\-\d]//g;
- my $symb = &Apache::lonnet::symbread();
+ my ($symb) = &get_symb($request);
my $title.='Verifying Submission Receipt '.
$receipt.'
'."\n".
@@ -721,7 +724,14 @@ LISTJAVASCRIPT
$gradeTable.=''."\n".
''."\n".
''."\n".
- ''."\n".
+ '
'."\n".
+ ' Grading Increments: '.
+
''."\n".
''."\n".
'
'."\n".
@@ -1134,6 +1144,81 @@ sub sub_page_kw_js {
my $request = shift;
my $iconpath = $request->dir_config('lonIconsURL');
&commonJSfunctions($request);
+
+ my $inner_js_msg_central=<
+ function checkInput() {
+ opener.document.SCORE.msgsub.value = opener.checkEntities(document.msgcenter.msgsub.value);
+ var nmsg = opener.document.SCORE.savemsgN.value;
+ var usrctr = document.msgcenter.usrctr.value;
+ var newval = opener.document.SCORE["newmsg"+usrctr];
+ newval.value = opener.checkEntities(document.msgcenter.newmsg.value);
+
+ var msgchk = "";
+ if (document.msgcenter.subchk.checked) {
+ msgchk = "msgsub,";
+ }
+ var includemsg = 0;
+ for (var i=1; i<=nmsg; i++) {
+ var opnmsg = opener.document.SCORE["savemsg"+i];
+ var frmmsg = document.msgcenter["msg"+i];
+ opnmsg.value = opener.checkEntities(frmmsg.value);
+ var showflg = opener.document.SCORE["shownOnce"+i];
+ showflg.value = "1";
+ var chkbox = document.msgcenter["msgn"+i];
+ if (chkbox.checked) {
+ msgchk += "savemsg"+i+",";
+ includemsg = 1;
+ }
+ }
+ if (document.msgcenter.newmsgchk.checked) {
+ msgchk += "newmsg"+usrctr;
+ includemsg = 1;
+ }
+ imgformname = opener.document.SCORE["mailicon"+usrctr];
+ imgformname.src = "$iconpath/"+((includemsg) ? "mailto.gif" : "mailbkgrd.gif");
+ var includemsg = opener.document.SCORE["includemsg"+usrctr];
+ includemsg.value = msgchk;
+
+ self.close()
+
+ }
+
+INNERJS
+
+ my $inner_js_highlight_central=<
+ function updateChoice(flag) {
+ opener.document.SCORE.kwclr.value = opener.radioSelection(document.hlCenter.kwdclr);
+ opener.document.SCORE.kwsize.value = opener.radioSelection(document.hlCenter.kwdsize);
+ opener.document.SCORE.kwstyle.value = opener.radioSelection(document.hlCenter.kwdstyle);
+ opener.document.SCORE.refresh.value = "on";
+ if (opener.document.SCORE.keywords.value!=""){
+ opener.document.SCORE.submit();
+ }
+ self.close()
+ }
+
+INNERJS
+
+ my $start_page_msg_central =
+ &Apache::loncommon::start_page('Message Central',$inner_js_msg_central,
+ {'js_ready' => 1,
+ 'only_body' => 1,
+ 'bgcolor' =>'#FFFFFF',});
+ my $end_page_msg_central =
+ &Apache::loncommon::end_page({'js_ready' => 1});
+
+
+ my $start_page_highlight_central =
+ &Apache::loncommon::start_page('Highlight Central',
+ $inner_js_highlight_central,
+ {'js_ready' => 1,
+ 'only_body' => 1,
+ 'bgcolor' =>'#FFFFFF',});
+ my $end_page_highlight_central =
+ &Apache::loncommon::end_page({'js_ready' => 1});
+
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
$docopen=~s/^document\.//;
$request->print(<");
- pDoc.write("Message Central");
-
- pDoc.write("
ENDSCRIPT
my $href="/adm/pickcode?".
- "form=".&Apache::lonnet::escape("scantronupload").
- "&scantron_format=".&Apache::lonnet::escape($env{'form.scantron_format'}).
- "&scantron_CODElist=".&Apache::lonnet::escape($env{'form.scantron_CODElist'}).
- "&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}).
- "&scantron_selectfile=".&Apache::lonnet::escape($env{'form.scantron_selectfile'});
+ "form=".&escape("scantronupload").
+ "&scantron_format=".&escape($env{'form.scantron_format'}).
+ "&scantron_CODElist=".&escape($env{'form.scantron_CODElist'}).
+ "&curCODE=".&escape($$scan_record{'scantron.CODE'}).
+ "&scantron_selectfile=".&escape($env{'form.scantron_selectfile'});
if ($env{'form.scantron_CODElist'} =~ /\S/) {
$r->print(" Selected CODE is ");
$r->print("\n
");
@@ -5486,6 +5611,10 @@ SCANTRONFORM
&Apache::lonxml::clear_problem_counter();
&Apache::lonnet::appenv(%$scan_record);
+
+ if (&scantron_clear_skip($scanlines,$scan_data,$i)) {
+ &scantron_putfile($scanlines,$scan_data);
+ }
my $i=0;
foreach my $resource (@resources) {
@@ -5873,7 +6002,7 @@ sub handler {
if ($#commands > 0) {
&Apache::lonnet::logthis("grades got multiple commands ".join(':',@commands));
}
- &send_header($request);
+ $request->print(&Apache::loncommon::start_page('Grading'));
if ($symb eq '' && $command eq '') {
if ($env{'user.adv'}) {
if (($env{'form.codeone'}) && ($env{'form.codetwo'}) &&
@@ -5964,27 +6093,10 @@ sub handler {
$request->print("Access Denied ($command)");
}
}
- &send_footer($request);
+ $request->print(&Apache::loncommon::end_page());
return '';
}
-sub send_header {
- my ($request)= @_;
- $request->print(&Apache::lontexconvert::header());
-# $request->print("
-#");
- $request->print(&Apache::loncommon::bodytag('Grading'));
- $request->rflush();
-}
-
-sub send_footer {
- my ($request)= @_;
- $request->print('