--- loncom/homework/grades.pm 2006/04/10 06:34:07 1.349
+++ loncom/homework/grades.pm 2007/03/13 18:59:56 1.391
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.349 2006/04/10 06:34:07 albertel Exp $
+# $Id: grades.pm,v 1.391 2007/03/13 18:59:56 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,10 +36,14 @@ 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 Apache::lonenc;
use String::Similarity;
+use lib '/home/httpd/lib/perl';
+use LONCAPA;
+
use POSIX qw(floor);
my %oldessays=();
@@ -109,36 +113,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 +167,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;
@@ -586,7 +589,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".
@@ -596,7 +599,8 @@ sub verifyreceipt {
my (undef,undef,$fullname) = &getclasslist('all','0');
my $receiptparts=0;
- if ($env{"course.$courseid.receiptalg"} eq 'receipt2') { $receiptparts=1; }
+ if ($env{"course.$courseid.receiptalg"} eq 'receipt2' ||
+ $env{"course.$courseid.receiptalg"} eq 'receipt3') { $receiptparts=1; }
my $parts=['0'];
if ($receiptparts) { ($parts)=&response_type($symb); }
foreach (sort
@@ -1142,6 +1146,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
");
@@ -5537,6 +5701,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) {
@@ -5547,8 +5715,9 @@ SCANTRONFORM
'grade_domain' =>$udom,
'grade_courseid'=>$env{'request.course.id'},
'grade_symb' =>$resource->symb());
- if (exists($scan_record->{'scantron.CODE'}) &&
- $scan_record->{'scantron.CODE'}) {
+ if (exists($scan_record->{'scantron.CODE'})
+ &&
+ &Apache::lonnet::validCODE($scan_record->{'scantron.CODE'})) {
$form{'CODE'}=$scan_record->{'scantron.CODE'};
} else {
$form{'CODE'}='';
@@ -5924,7 +6093,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'}) &&
@@ -6015,20 +6184,8 @@ sub handler {
$request->print("Access Denied ($command)");
}
}
- &send_footer($request);
- return '';
-}
-
-sub send_header {
- my ($request)= @_;
- &Apache::lontexconvert::init_tth();
- $request->print(&Apache::loncommon::start_page('Grading'));
- $request->rflush();
-}
-
-sub send_footer {
- my ($request)= @_;
$request->print(&Apache::loncommon::end_page());
+ return '';
}
1;