--- loncom/homework/grades.pm 2003/07/19 15:11:27 1.120
+++ loncom/homework/grades.pm 2003/07/25 20:35:40 1.125
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.120 2003/07/19 15:11:27 ng Exp $
+# $Id: grades.pm,v 1.125 2003/07/25 20:35:40 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@
# June-August H.K. Ng
# Year 2003
# February, March H.K. Ng
+# July, H. K. Ng
#
package Apache::grades;
@@ -98,7 +99,8 @@ sub get_fullname {
#--- Get the partlist and the response type for a given problem. ---
#--- Indicate if a response type is coded handgraded or not. ---
sub response_type {
- my ($url) = shift;
+ my ($url,$symb) = shift;
+ $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
my $allkeys = &Apache::lonnet::metadata($url,'keys');
my %seen = ();
my (@partlist,%handgrade);
@@ -107,7 +109,9 @@ sub response_type {
my ($responsetype,$part) = split(/_/,$_,2);
my ($partid,$respid) = split(/_/,$part);
$responsetype =~ s/response$//; # make it compatible w/ navmaps - should move to that!!
- $handgrade{$part} = $responsetype.':'.($allkeys =~ /parameter_$part\_handgrade/ ? 'yes' : 'no');
+# my ($value) = &Apache::lonnet::EXT('resource.'.$part.'.handgrade',$symb);
+# $handgrade{$part} = $responsetype.':'.($value eq 'yes' ? 'yes' : 'no'); #a bug $value is 'yes' regardless
+ $handgrade{$part} = $responsetype.':'.(($allkeys =~ /parameter_$part\_handgrade/) ? 'yes' : 'no');
next if ($seen{$partid} > 0);
$seen{$partid}++;
push @partlist,$partid;
@@ -123,23 +127,25 @@ sub showResourceInfo {
my $result ='
'.
'
Current Resource: '.$probTitle.'
'."\n";
my ($partlist,$handgrade) = &response_type($url);
- my ($resptype,$hdgrade)=('','no');
+ my %resptype = (); #,$hdgrade)=('','no');
+ my $hdgrade='no';
for (sort keys(%$handgrade)) {
my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
- $resptype = $responsetype;
+ my $partID = (split(/_/))[0];
+ $resptype{$partID} = $responsetype;
$hdgrade = $handgrade if ($handgrade eq 'yes');
- $result.='
Part '.(split(/_/))[0].'
'.
+ $result.='
Part '.$partID.'
'.
'
Type: '.$responsetype.'
';
# '
Handgrade: '.$handgrade.'
';
}
$result.='
'."\n";
- return $result,$resptype,$hdgrade,$partlist,$handgrade;
+ return $result,\%resptype,$hdgrade,$partlist,$handgrade;
}
#--- Clean response type for display
#--- Currently filters option response type only.
sub cleanRecord {
- my ($answer,$response) = @_;
+ my ($answer,$response,$symb) = @_;
if ($response eq 'option') {
my (@IDs,@ans);
foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
@@ -155,6 +161,21 @@ sub cleanRecord {
(join '
'.$grayFont,@IDs).'
'.
'';
}
+ if ($response eq 'essay') {
+ if (! exists ($ENV{'form.'.$symb})) {
+ my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
+ $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+
+ my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
+ $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
+ $ENV{'form.kwclr'} = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
+ $ENV{'form.kwsize'} = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
+ $ENV{'form.kwstyle'} = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
+ $ENV{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.
+ }
+ return &keywords_highlight($answer);
+ }
return $answer;
}
@@ -197,6 +218,7 @@ COMMONJSFUNCTIONS
#--- section, ids and fullnames for each user.
sub getclasslist {
my ($getsec,$filterlist) = @_;
+ $getsec = $getsec eq '' ? 'all' : $getsec;
my $classlist=&Apache::loncoursedata::get_classlist();
# Bail out if we were unable to get the classlist
return if (! defined($classlist));
@@ -303,6 +325,7 @@ sub jscriptNform {
''."\n".
''."\n".
''."\n".
+ ''."\n".
''."\n".
''."\n".
''."\n".
@@ -430,7 +453,7 @@ sub listStudents {
my $result='
'.$viewgrade.
' Submissions for a Student or a Group of Students
';
- my ($table,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
+ my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
$result.=$table;
$request->print(< last sub only'."\n".
' last sub & parts info'."\n".
+ ' by dates and submissions'."\n".
' all details'."\n".
''."\n".
''."\n".
- ''."\n".
' '."\n".
' '."\n".
''."\n".
@@ -497,8 +520,12 @@ LISTJAVASCRIPT
''."\n".
''."\n";
- $gradeTable.='Student Status: '.
- &Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,'javascript:reLoadList(this.form);').' ';
+ if (exists($ENV{'form.gradingMenu'}) && exists($ENV{'form.Status'})) {
+ $gradeTable.=''."\n";
+ } else {
+ $gradeTable.='Student Status: '.
+ &Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,'javascript:reLoadList(this.form);').' ';
+ }
$gradeTable.='To '.lc($viewgrade).' a submission, click on the check box next to the student\'s name. Then '."\n".
'click on the '.$viewgrade.' button. To view the submissions for a group of students, click'."\n".
@@ -623,9 +650,9 @@ sub sub_page_js {
$request->print(<
function updateRadio(formname,id,weight) {
- var gradeBox = eval("formname.GD_BOX"+id);
- var radioButton = eval("formname.RADVAL"+id);
- var oldpts = eval("formname.oldpts"+id+".value");
+ var gradeBox = formname["GD_BOX"+id];
+ var radioButton = formname["RADVAL"+id];
+ var oldpts = formname["oldpts"+id].value;
var pts = checkSolved(formname,id) == 'update' ? gradeBox.value : oldpts;
gradeBox.value = pts;
var resetbox = false;
@@ -647,7 +674,7 @@ sub sub_page_js {
var resp = confirm("You entered a value ("+pts+
") greater than the weight for the part. Accept?");
if (resp == false) {
- gradeBox.value = "";
+ gradeBox.value = oldpts;
return;
}
}
@@ -659,18 +686,17 @@ sub sub_page_js {
}
}
updateSelect(formname,id);
- var stores = eval("formname.stores"+id);
- stores.value = "0";
+ formname["stores"+id].value = "0";
}
function writeBox(formname,id,pts) {
- var gradeBox = eval("formname.GD_BOX"+id);
+ var gradeBox = formname["GD_BOX"+id];
if (checkSolved(formname,id) == 'update') {
gradeBox.value = pts;
} else {
- var oldpts = eval("formname.oldpts"+id+".value");
+ var oldpts = formname["oldpts"+id].value;
gradeBox.value = oldpts;
- var radioButton = eval("formname.RADVAL"+id);
+ var radioButton = formname["RADVAL"+id];
for (var i=0; i
//===================== Show list of keywords ====================
- function keywords(keyform) {
- var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value);
+ function keywords(formname) {
+ var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",formname.keywords.value);
if (nret==null) return;
- keyform.value = nret;
+ formname.keywords.value = nret;
- document.SCORE.refresh.value = "on";
- if (document.SCORE.keywords.value != "") {
- document.SCORE.submit();
+ formname.refresh.value = "on";
+ if (formname.keywords.value != "") {
+ formname.submit();
}
return;
}
@@ -859,21 +882,25 @@ sub sub_page_kw_js {
var Nmsg = msgform.savemsgN.value;
savedMsgHeader(Nmsg,usrctr,fullname);
var subject = msgform.msgsub.value;
- var rtrchk = eval("document.SCORE.includemsg"+usrctr);
+ var rtrchk = document.SCORE["includemsg"+usrctr];
var msgchk = rtrchk.value;
re = /msgsub/;
var shwsel = "";
if (re.test(msgchk)) { shwsel = "checked" }
- displaySubject(subject,shwsel);
+ subject = (document.SCORE.shownSub.value == 0 ? checkEntities(subject) : subject);
+ displaySubject(checkEntities(subject),shwsel);
for (var i=1; i<=Nmsg; i++) {
- var testpt = "savemsg"+i+",";
- re = /testpt/;
+ var testmsg = "savemsg"+i+",";
+ re = new RegExp(testmsg,"g");
shwsel = "";
if (re.test(msgchk)) { shwsel = "checked" }
- var message = eval("document.SCORE.savemsg"+i+".value");
- displaySavedMsg(i,message,shwsel);
+ var message = document.SCORE["savemsg"+i].value;
+ var shownOnce = document.SCORE["shownOnce"+i].value;
+ message = (shownOnce == 0 ? checkEntities(message) : message);
+ displaySavedMsg(i,message,shwsel); //I do not get it. w/o checkEntities on saved messages,
+ //any < is already converted to <, etc. However, only once!!
}
- newmsg = eval("document.SCORE.newmsg"+usrctr+".value");
+ newmsg = document.SCORE["newmsg"+usrctr].value;
shwsel = "";
re = /newmsg/;
if (re.test(msgchk)) { shwsel = "checked" }
@@ -882,6 +909,22 @@ sub sub_page_kw_js {
return;
}
+ function checkEntities(strx) {
+ if (strx.length == 0) return strx;
+ var orgStr = ["&", "<", ">", '"'];
+ var newStr = ["&", "<", ">", """];
+ var counter = 0;
+ while (counter < 4) {
+ strx = strReplace(strx,orgStr[counter],newStr[counter]);
+ counter++;
+ }
+ return strx;
+ }
+
+ function strReplace(strx, orgStr, newStr) {
+ return strx.split(orgStr).join(newStr);
+ }
+
function savedMsgHeader(Nmsg,usrctr,fullname) {
var height = 70*Nmsg+250;
var scrollbar = "no";
@@ -903,11 +946,11 @@ sub sub_page_kw_js {
pDoc.write("