[LON-CAPA-cvs] cvs: loncom /homework grades.pm

ng lon-capa-cvs@mail.lon-capa.org
Fri, 28 Mar 2003 20:49:55 -0000


This is a MIME encoded message

--ng1048884595
Content-Type: text/plain

ng		Fri Mar 28 15:49:55 2003 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  Show with icon (appears next to Compose a Message link) that an 
  instructor has composed a message that will be sent
  to the student.
  When grading by sequence show the tries for each part.
  Clear out hmtl before displaying messages - bug 1315.
  
  
--ng1048884595
Content-Type: text/plain
Content-Disposition: attachment; filename="ng-20030328154955.txt"

Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.79 loncom/homework/grades.pm:1.80
--- loncom/homework/grades.pm:1.79	Fri Mar 28 13:15:24 2003
+++ loncom/homework/grades.pm	Fri Mar 28 15:49:55 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.79 2003/03/28 18:15:24 bowersj2 Exp $
+# $Id: grades.pm,v 1.80 2003/03/28 20:49:55 ng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -343,8 +343,8 @@
     my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
 
     my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n".
-	'&nbsp;<b>View Problem: </b><input type="radio" name="vProb" value="no" /> no '."\n".
-	'<input type="radio" name="vProb" value="yes" checked /> one student '."\n".
+	'&nbsp;<b>View Problem: </b><input type="radio" name="vProb" value="no" checked /> no '."\n".
+	'<input type="radio" name="vProb" value="yes" /> one student '."\n".
 	'<input type="radio" name="vProb" value="all" /> all students <br />'."\n".
 	'&nbsp;<b>Submissions: </b>'."\n";
     if ($ENV{'form.handgrade'} eq 'yes') {
@@ -628,6 +628,7 @@
 #--- javascript for essay type problem --
 sub sub_page_kw_js {
     my $request = shift;
+    my $iconpath = $request->dir_config('lonIconsURL');
     $request->print(<<SUBJAVASCRIPT);
 <script type="text/javascript" language="javascript">
 
@@ -675,6 +676,12 @@
   }
 
 //====================== Script for composing message ==============
+   // preload images
+   img1 = new Image();
+   img1.src = "$iconpath/mailbkgrd.gif";
+   img2 = new Image();
+   img2.src = "$iconpath/mailto.gif";
+
   function msgCenter(msgform,usrctr,fullname) {
     var Nmsg  = msgform.savemsgN.value;
     savedMsgHeader(Nmsg,usrctr,fullname);
@@ -729,17 +736,26 @@
     pDoc.write("  if (document.msgcenter.subchk.checked) {");
     pDoc.write("     msgchk = \\"msgsub,\\";");
     pDoc.write("  }");
-    pDoc.write(   "for (var i=1; i<=nmsg; i++) {");
+    pDoc.write("  var includemsg = 0;");
+    pDoc.write("  for (var i=1; i<=nmsg; i++) {");
     pDoc.write("      var opnmsg = eval(\\"opener.document.SCORE.savemsg\\"+i);");
     pDoc.write("      var frmmsg = eval(\\"document.msgcenter.msg\\"+i);");
     pDoc.write("      opnmsg.value = frmmsg.value;");
     pDoc.write("      var chkbox = eval(\\"document.msgcenter.msgn\\"+i);");
     pDoc.write("      if (chkbox.checked) {");
     pDoc.write("         msgchk += \\"savemsg\\"+i+\\",\\";");
+    pDoc.write("         includemsg = 1;");
     pDoc.write("      }");
     pDoc.write("  }");
     pDoc.write("  if (document.msgcenter.newmsgchk.checked) {");
     pDoc.write("     msgchk += \\"newmsg\\"+usrctr;");
+    pDoc.write("     includemsg = 1;");
+    pDoc.write("  }");
+    pDoc.write("  imgformname = eval(\\"opener.document.SCORE.mailicon\\"+usrctr);");
+    pDoc.write("  if (includemsg) {");
+    pDoc.write("     imgformname.src = \\"$iconpath/mailto.gif\\";");
+    pDoc.write("  } else {");
+    pDoc.write("     imgformname.src = \\"$iconpath/mailbkgrd.gif\\";");
     pDoc.write("  }");
     pDoc.write("  var includemsg = eval(\\"opener.document.SCORE.includemsg\\"+usrctr);");
     pDoc.write("  includemsg.value = msgchk;");
@@ -1030,7 +1046,7 @@
 
 	$request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n".
 			'<input type="hidden" name="command"    value="handgrade" />'."\n".
-			'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n".
+			'<input type="hidden" name="saveState"  value="'.$ENV{'form.saveState'}.'" />'."\n".
 			'<input type="hidden" name="probTitle"  value="'.$ENV{'form.probTitle'}.'" />'."\n".
 			'<input type="hidden" name="refresh"    value="off" />'."\n".
 			'<input type="hidden" name="symb"       value="'.$symb.'" />'."\n".
@@ -1054,7 +1070,9 @@
 	my ($cts,$prnmsg) = (1,'');
 	while ($cts <= $ENV{'form.savemsgN'}) {
 	    $prnmsg.='<input type="hidden" name="savemsg'.$cts.'" value="'.
-		($keyhash{$symb.'_savemsg'.$cts} eq '' ? $ENV{'form.savemsg'.$cts} : $keyhash{$symb.'_savemsg'.$cts}).
+		($keyhash{$symb.'_savemsg'.$cts} eq '' ? 
+		 &Apache::lonfeedback::clear_out_html($ENV{'form.savemsg'.$cts}) :
+		 &Apache::lonfeedback::clear_out_html($keyhash{$symb.'_savemsg'.$cts})).
 		'" />'."\n";
 	    $cts++;
 	}
@@ -1095,7 +1113,7 @@
     my ($classlist,$fullname);
     if ($ENV{'form.handgrade'} eq 'yes') {
 	my @col_list;
-	($classlist,undef,$fullname) = &getclasslist('all',$ENV{'form.showgrading'} eq 'yes' ? '1' : '0');
+	($classlist,undef,$fullname) = &getclasslist('all','0');
 	for (keys (%$handgrade)) {
 	    my $ncol = &Apache::lonnet::EXT('resource.'.$_.
 					    '.maxcollaborators',
@@ -1103,20 +1121,26 @@
 	    next if ($ncol <= 0);
             s/\_/\./g;
             next if ($record{'resource.'.$_.'.collaborators'} eq '');
-            my (@collaborators) = split(/,?\s+/,
+            my (@colList) = split(/,?\s+/,
                                    $record{'resource.'.$_.'.collaborators'});
+            my @collaborators = ();
+	    foreach (@colList) { #pre-filter list - throw out submitter
+		my ($co_name,$co_dom) = split /\@|:/,$_;
+		$co_dom = $udom if (! defined($co_dom));
+		next if ($co_name eq $uname && $co_dom eq $udom);
+		push @collaborators, $_;
+	    }
             my (@badcollaborators);
             if (scalar(@collaborators) != 0) {
                 $result.='<b>Collaborators: </b>';
                 foreach my $collaborator (@collaborators) {
                     my ($co_name,$co_dom) = split /\@|:/,$collaborator;
                     $co_dom = $udom if (! defined($co_dom));
-                    next if ($co_name eq $uname && $co_dom eq $udom);
                     # Doing this grep allows 'fuzzy' specification
-                    my @Matches = grep /^$co_name:$co_dom/i,
+                    my @Matches = grep /^$co_name:$co_dom$/i,
                     keys %$classlist;
-                    if (! scalar(@Matches)) {
-                        push @badcollaborators,$collaborator;
+		    if (! scalar(@Matches)) {
+                        push @badcollaborators,':'.$collaborator.':';
                         next;
                     }
                     push @col_list, @Matches;
@@ -1229,7 +1253,9 @@
     $result.='<tr><td bgcolor="#ffffff">'."\n".
 	'&nbsp;<a href="javascript:msgCenter(document.SCORE,'.$counter.
 	',\''.$msgfor.'\')"; TARGET=_self>'.
-	'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a>'.
+	'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a> &nbsp;'.
+	'<img src="'.$request->dir_config('lonIconsURL').
+	'/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n".
 	'<br />&nbsp;(Message will be sent when you click on Save & Next below.)'."\n" 
 	if ($ENV{'form.handgrade'} eq 'yes');
     $request->print($result);
@@ -1348,7 +1374,6 @@
 		$ctr++;
 		next;
 	    }
-
 	    my $includemsg = $ENV{'form.includemsg'.$ctr};
 	    my ($subject,$message,$msgstatus) = ('','','');
 	    if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) {
@@ -1357,9 +1382,11 @@
 		foreach (@msgnum) {
 		    $message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne '');
 		}
-		$message =~ s/<([^>]|\n)*>//g; # removes html codes Or should this be lonnet::escape ??
+		$message =&Apache::lonfeedback::clear_out_html($message);
 		$message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt;
-		$message.=" for <a href=\"$url?symb=$symb\">$ENV{'form.probTitle'}</a>";
+		$message.=" for <a href=\"".
+		    &Apache::lonnet::clutter($url).
+		    "?symb=$symb\">$ENV{'form.probTitle'}</a>";
 		$msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom,
 							       $ENV{'form.msgsub'},$message);
 	    }
@@ -2343,7 +2370,7 @@
     my $result='<h3><font color="#339933">&nbsp;'.
 	'Manual Grading by Page or Sequence</font></h3>';
 
-    $result.='<form action="/adm/grades" method="post" name="displayPage">'."<br>\n";
+    $result.='<form action="/adm/grades" method="post" name="displayPage">'."\n";
     $result.='&nbsp;<b>Problems from:</b> <select name="selectpage">'."\n";
     my ($titles,$symbx) = &getSymbMap($request);
     my ($curpage,$type,$mapId) = ($symb =~ /(.*?\.(page|sequence))___(\d+)___/); 
@@ -2377,10 +2404,10 @@
     $result.='<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".
 	'<input type="hidden" name="command" value="displayPage" />'."\n".
 	'<input type="hidden" name="url"     value="'.$url.'" />'."\n".
-	'<input type="hidden" name="symb"    value="'.$symb.'" />'."<br><br>\n".
-	'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n";
+	'<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
+	'<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."<br />\n";
 
-    $result.='<br />&nbsp;<input type="button" '.
+    $result.='&nbsp;<input type="button" '.
 	'onClick="javascript:checkPickOne(this.form);"value="Submit" /><br />'."\n";
 
     $request->print($result);
@@ -2540,8 +2567,8 @@
 	    } else {
 		my $companswer = &Apache::loncommon::get_student_answers(
 									 $symbx,$uname,$udom,$ENV{'request.course.id'});
-		$companswer=~s|<form(.*?)>||g;
-		$companswer=~s|</form>||g;
+		$companswer =~ s|<form(.*?)>||g;
+		$companswer =~ s|</form>||g;
 
 #		while ($companswer =~ /(<a href\=\"javascript:newWindow.*?Script Vars<\/a>)/s) { #<a href="javascript:newWindow</a>
 #		    $request->print('match='.$1.'<br>');
@@ -2574,8 +2601,10 @@
 #			    next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' && 
 #				     $record{"$version:resource.$partid.solved"} eq '');
 			    $displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ? 
-				'<b>Trial&nbsp;'.$version.'&nbsp;Part&nbsp;'.$partid.'</b>&nbsp; '
-				.$record{$version.':'.$matchKey[0]}.'<br />' : '';
+				'<b>Part&nbsp;'.$partid.'&nbsp;'.
+				($record{"$version:resource.$partid.tries"} eq '' ? 'Trial&nbsp;not&nbsp;counted' :
+				'Trial&nbsp;'.$record{"$version:resource.$partid.tries"}).'</b>&nbsp; '.
+				$record{$version.':'.$matchKey[0]}.'<br />' : '';
 			    $displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ?
 				'<b>Part&nbsp;'.$partid.'</b> &nbsp;'.
 				$record{"$version:resource.$partid.award"}.'/'.

--ng1048884595--