--- loncom/homework/grades.pm 2006/04/10 06:34:07 1.349
+++ loncom/homework/grades.pm 2006/09/14 21:47:22 1.375
@@ -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.375 2006/09/14 21:47:22 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=();
@@ -120,7 +123,7 @@ sub response_type {
foreach (split(/,/,&Apache::lonnet::metadata($url,'packages'))) {
if (/^\w+response_.*/ || /^Task_/) {
my ($responsetype,$part) = split(/_/,$_,2);
- my ($partid,$respid) = split(/_/,$part);
+ my ($partid,$respid) = split(/_/,$part,2);
if ($responsetype eq 'Task') { $respid='0'; }
if (&Apache::loncommon::check_if_partid_hidden($partid,$symb)) {
next;
@@ -141,6 +144,18 @@ sub response_type {
return (\@partlist,\%handgrade,\%responseType);
}
+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 {
my ($partID,$symb)=@_;
my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb);
@@ -165,25 +180,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;
@@ -1142,6 +1158,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
");
@@ -5924,7 +5995,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 +6086,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;