--- loncom/homework/grades.pm 2003/07/18 20:14:35 1.119
+++ loncom/homework/grades.pm 2003/07/23 18:04:51 1.124
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.119 2003/07/18 20:14:35 ng Exp $
+# $Id: grades.pm,v 1.124 2003/07/23 18:04:51 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -123,23 +123,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 +157,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 +214,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));
@@ -430,7 +448,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 +515,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".
@@ -707,9 +729,10 @@ sub sub_page_js {
}
function checkSolved(formname,id) {
- if (eval("formname.solved"+id+".value") == "correct_by_student") {
+ if (eval("formname.solved"+id+".value") == "correct_by_student" && formname.overRideScore.value == 'no') {
var reply = confirm("This problem has been graded correct by the computer. Do you want to change the score?");
if (!reply) {return "noupdate";}
+ formname.overRideScore.value = 'yes';
}
return "update";
}
@@ -720,9 +743,9 @@ sub sub_page_js {
return;
}
-//=========== Check that a point is assigned for all the parts (essay grading only) ============
+//=========== Check that a point is assigned for all the parts ============
function checksubmit(formname,val,total,parttot) {
- document.SCORE.gradeOpt.value = val;
+ formname.gradeOpt.value = val;
if (val == "Save & Next") {
for (i=0;i<=total;i++) {
for (j=0;j
//===================== 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;
}
@@ -855,14 +885,18 @@ sub sub_page_kw_js {
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 shownOnce = eval("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");
shwsel = "";
@@ -873,6 +907,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";
@@ -894,11 +944,11 @@ sub sub_page_kw_js {
pDoc.write("