--- loncom/homework/grades.pm 2002/07/01 21:20:29 1.34
+++ loncom/homework/grades.pm 2002/07/08 21:18:54 1.37
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.34 2002/07/01 21:20:29 ng Exp $
+# $Id: grades.pm,v 1.37 2002/07/08 21:18:54 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -30,7 +30,7 @@
# 7/26 H.K. Ng
# 8/20 Gerd Kortemeyer
# Year 2002
-# June 2002 H.K. Ng
+# June, July 2002 H.K. Ng
#
package Apache::grades;
@@ -53,6 +53,7 @@ sub moreinfo {
if ($ENV{'form.symb'}) {
$request->print(''."\n");
}
+# $request->print(''."\n");
$request->print(''."\n");
$request->print("Student:".''." \n");
$request->print("Domain:".''." \n");
@@ -135,11 +136,15 @@ sub listStudents {
Resource: $ENV{'form.url'}
View Problem: no
- yes
- Submissions: last
- all
+ yes
+ Submissions:
+ last sub only
+ last sub & parts info
+ all details
+
+
Select
Username
@@ -181,31 +186,39 @@ sub processGroup {
my ($request) = shift;
my $ctr = 0;
my @stuchecked = (ref($ENV{'form.stuinfo'}) ? @{$ENV{'form.stuinfo'}}
- : ($ENV{'form.stuinfo'}) );
+ : ($ENV{'form.stuinfo'}));
my $total = scalar(@stuchecked)-1;
- foreach my $student (@stuchecked) {
- my ($sname,$sdom,$fullname) = split(/:/,$student);
+ if ($stuchecked[0] eq '') {
+ &userError($request,'No student was selected for viewing/grading.');
+ return;
+ }
+ foreach (@stuchecked) {
+ my ($sname,$sdom,$fullname) = split(/:/);
$ENV{'form.student'} = $sname;
$ENV{'form.fullname'} = $fullname;
&submission($request,$ctr,$total);
$ctr++;
}
-
return 'The End';
}
+sub userError {
+ my ($request, $reason, $step) = @_;
+ $request->print('
LON-CAPA User Error
'."\n");
+ $request->print('Reason: '.$reason.'
'."\n");
+ $request->print('Step: '.($step ne '' ? $step : 'Use your browser back button to correct')
+ .'
'."\n");
+ return '';
+}
+
#FIXME - needs to handle multiple matches
sub finduser {
my ($name) = @_;
my $domain = '';
-
if ( $Apache::grades::viewgrades eq 'F' ) {
- #get classlist
-# my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
- #print "Found $cdom:$cnum ";
my ($classlist) = &getclasslist('all','0');
- foreach my $student ( sort(@{ $$classlist{'all'} }) ) {
- my ($posname,$posdomain) = split(/:/,$student);
+ foreach ( sort(@{ $$classlist{'all'} }) ) {
+ my ($posname,$posdomain) = split(/:/);
if ($posname =~ $name) { $name=$posname; $domain=$posdomain; last; }
}
return ($name,$domain);
@@ -228,8 +241,9 @@ sub getclasslist {
}
my ($unam,$udom) = split(/:/,$student,2);
my $section = &Apache::lonnet::usection($udom,$unam,$ENV{'request.course.id'});
+ $section = ($section ne '-1' ? $section : 'no');
push @holdsec,$section;
- push (@{ $classlist{$getsec} }, $student) if ($getsec eq 'all' or $getsec == $section);
+ push (@{ $classlist{$getsec} }, $student) if ($getsec eq 'all' || $getsec eq $section);
}
my %seen = ();
foreach my $item (@holdsec) {
@@ -326,10 +340,6 @@ sub setstudentgrade {
}
if ( scalar(keys(%newrecord)) > 0 ) {
$newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
- print "grader=$newrecord{'resource.regrader'}: records ";
- while (my ($k,$v) = each %newrecord) {
- print "k=$k:v=$v: \n";
- }
# &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
$result.="Stored away ".scalar(keys(%newrecord))." elements. \n";
@@ -343,7 +353,7 @@ sub submission {
my ($request,$counter,$total) = @_;
if ($counter == 0) {
- $request->print(<print(<
function updateRadio(radioButton,formtextbox,formsel,wgt) {
var pts = formtextbox.value;
@@ -390,25 +400,255 @@ sub submission {
return;
}
+ function keywords(keyform) {
+ var keywds = keyform.value;
+ var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keywds);
+ if (nret==null) return;
+ keyform.value = nret;
+ return;
+ }
+
+//===================== Script to add keyword(s) ==================
+ function getSel() {
+ if (document.getSelection) txt = document.getSelection();
+ else if (document.selection) txt = document.selection.createRange().text;
+ else return;
+ var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");
+ if (cleantxt=="") {
+ alert("Select a word or group of words from document and then click this link.");
+ return;
+ }
+ var nret = prompt("Add selection to keyword list?",cleantxt);
+ if (nret==null) return;
+ var curlist = document.SCORE.keywords.value;
+ document.SCORE.keywords.value = curlist+" "+nret;
+ return;
+ }
+
+//====================== Script for composing message ==============
+ function msgCenter(msgform,usrctr,fullname) {
+ var Nmsg = msgform.savemsgN.value;
+ savedMsgHeader(Nmsg,usrctr,fullname);
+ var subject = msgform.msgsub.value;
+ var rtrchk = eval("document.SCORE.includemsg"+usrctr);
+ var msgchk = rtrchk.value;
+// alert("checked=>"+msgchk);
+ re = /msgsub/;
+ var shwsel = "";
+ if (re.test(msgchk)) { shwsel = "checked" }
+ displaySubject(subject,shwsel);
+ for (var i=1; i<=Nmsg; i++) {
+ var testpt = "savemsg"+i+",";
+ re = /testpt/;
+ shwsel = "";
+ if (re.test(msgchk)) { shwsel = "checked" }
+ var message = eval("document.SCORE.savemsg"+i+".value");
+ displaySavedMsg(i,message,shwsel);
+ }
+ newmsg = eval("document.SCORE.newmsg"+usrctr+".value");
+ shwsel = "";
+ re = /newmsg/;
+ if (re.test(msgchk)) { shwsel = "checked" }
+ newMsg(newmsg,shwsel);
+ msgTail();
+ return;
+ }
+
+function savedMsgHeader(Nmsg,usrctr,fullname) {
+ var height = 30*Nmsg+250;
+ var scrollbar = "no";
+ if (height > 600) {
+ height = 600;
+ scrollbar = "yes";
+ }
+/* if (window.pWin)
+ window.pWin.close(); */
+ pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',width=600,height='+height);
+ pWin.document.write("");
+ pWin.document.write("Message Central");
+
+ pWin.document.write("
-JAVASCRIPT
+SUBJAVASCRIPT
}
(my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
- if ($ENV{'form.student'} eq '') { &moreinfo($request,"Need student login id"); return ''; }
+ if ($ENV{'form.student'} eq '') { &moreinfo($request,'Need student login id'); return ''; }
my ($uname,$udom) = &finduser($ENV{'form.student'});
- if ($uname eq '') { &moreinfo($request,"Unable to find student"); return ''; }
+ if ($uname eq '') { &moreinfo($request,'Unable to find student'); return ''; }
my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
-#
-# header info
+
+ # header info
if ($counter == 0) {
- $request->print('
Submission Record
');
+ $request->print('
Submission Record
'.
+ ' Resource: '.$url.'');
}
-#
-# option to display problem, only once else it cause problems with the form later since the problem has a form.
+ # option to display problem, only once else it cause problems with the form later since the problem has a form.
if ($ENV{'form.vProb'} eq 'yes' && $counter == 0) {
my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
$ENV{'request.course.id'});
@@ -422,50 +662,120 @@ JAVASCRIPT
$result.='
';
$request->print($result);
}
-#
-# beginning of form
+
+ # beginning of form
if ($counter == 0) {
+ 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'};
+ # if the handgrade db has never being initialized then set some default values
+ if ($keyhash{$symb.'_handgrade'} eq '') {
+ $keyhash{$symb.'_keywords'} = '';
+ $keyhash{$symb.'_subject'} = &Apache::lonnet::metadata($url,'title');
+ $keyhash{$loginuser.'_kwclr'} = $keyhash{$loginuser.'_kwclr'} eq '' ? 'red' : $keyhash{$loginuser.'_kwclr'};
+ $keyhash{$loginuser.'_kwsize'} = $keyhash{$loginuser.'_kwsize'} eq '' ? '0' : $keyhash{$loginuser.'_kwsize'};
+ $keyhash{$loginuser.'_kwstyle'} = $keyhash{$loginuser.'_kwstyle'} eq '' ? '' : $keyhash{$loginuser.'_kwstyle'};
+ $keyhash{$symb.'_savemsgN'} = '0';
+ }
$request->print('