--- loncom/homework/grades.pm 2002/05/24 21:45:22 1.27
+++ loncom/homework/grades.pm 2002/06/25 21:07:56 1.31
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.27 2002/05/24 21:45:22 albertel Exp $
+# $Id: grades.pm,v 1.31 2002/06/25 21:07:56 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -29,6 +29,9 @@
# 6/8 Gerd Kortemeyer
# 7/26 H.K. Ng
# 8/20 Gerd Kortemeyer
+# Year 2002
+# June 2002 H.K. Ng
+#
package Apache::grades;
use strict;
@@ -83,18 +86,18 @@ sub verifyreceipt {
$matches++;
}
}
- $request->print('
'.$matches.' match(es)
');
+ $request->printf('
'.$matches." match%s
",$matches <= 1 ? '' : 'es');
}
return '';
}
-sub listStudents {
+sub receiptInput {
my ($request) = shift;
my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};
my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};
my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
$request->print(<Verify a Submission Receipt Issued by this Server
+
Verify a Submission Receipt Issued by this Server
');
+ return '';
+}
+
+sub listStudents {
+ my ($request) = shift;
+ my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};
+ my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};
+
$request->print(<
-
Show Student Submissions on Assessment
-
-
Username
Domain
Name
+
Show Student Submissions on Assessment
+
+
+
+
Resource: $ENV{'form.url'}
+
Username
Name
Domain
+
View Problem
Submissions
Action
ENDTABLEST
my (%classlist) = &getclasslist($cdom,$cnum,'0');
foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
@@ -125,32 +141,41 @@ ENDTABLEST
my ($tmp) = keys(%name);
if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
$fullname=$name{'lastname'}.$name{'generation'};
- if ($fullname =~ /[^\s]+/) { $fullname.=','; }
+ if ($fullname =~ /[^\s]+/) { $fullname.=', '; }
$fullname.=$name{'firstname'}.' '.$name{'middlename'};
}
if ( $Apache::grades::viewgrades eq 'F' ) {
- $request->print("\n".'
';
return $result;
}
-#FIXME need to look at the meatdata spec on what type of data to accept and provide an
+
+#FIXME need to look at the metadata spec on what type of data to accept and provide an
#interface based on that, also do that to above function.
sub setstudentgrade {
my ($url,$symb,$courseid,$student,@parts) = @_;
my $result ='';
-
my ($stuname,$domain) = split(/:/,$student);
-
my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
-
my %newrecord;
foreach my $part (@parts) {
@@ -294,12 +313,19 @@ sub setstudentgrade {
return $result;
}
+# -- show submissions of a student, option to grade
+#
sub submission {
my ($request) = @_;
+ $request->print(<
+ function changeRadio(title,url) {
+ }
+
+JAVASCRIPT
my $url=$ENV{'form.url'};
$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 '') { &listStudents($request); return ''; }
my ($uname,$udom) = &finduser($ENV{'form.student'});
if ($uname eq '') { &moreinfo($request,"Unable to find student"); return ''; }
my $symb;
@@ -309,16 +335,70 @@ sub submission {
$symb=&Apache::lonnet::symbread($url);
}
if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
- my $answer=&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
- $ENV{'request.course.id'});
- my $result="
Submission Record
$uname:$udom for $url ".$answer;
- my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
+#
+# header info
+ my $result='
Submission Record
';
+ $result.='
Username: '.$uname.'
Fullname: '.$ENV{'form.fullname'}.'
Domain: '.$udom.'
';
+ $result.='
Resource: '.$url.'
';
+#
+# option to display problem
+ if ($ENV{'form.vProb'} eq 'yes') {
+ my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
$ENV{'request.course.id'});
- $result.="Student's view of the problem: $rendered Correct answer: ";
-
- $answer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
- $ENV{'request.course.id'});
+ my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
+ $ENV{'request.course.id'});
+ $result.='
'."\n";
return $result;
}
@@ -373,9 +483,9 @@ sub viewgrades {
my $cellclr = '"#ffffcc"';
#get list of parts for this problem
- my (@parts) = &getpartlist($url);
+ my (@parts) = sort(&getpartlist($url));
- $request->print ("
Manual Grading
");
+ $request->print ("
Manual Grading
");
#start the form
$result = '';
+ $result.=&show_grading_menu_form($symb,$url);
return $result;
}
@@ -640,21 +754,44 @@ sub csvuploadassign {
}
}
$request->print('
Assigning Grades
');
- &Apache::lonhomework::showhash(('1'=>\@keyfields));
- &Apache::lonhomework::showhash(%fields);
my $courseid=$ENV{'request.course.id'};
my $cdom=$ENV{"course.$courseid.domain"};
my $cnum=$ENV{"course.$courseid.num"};
my (%classlist) = &getclasslist($cdom,$cnum,'1');
- foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
- my %newhash;
- foreach my $grade (@gradedata) {
- my %entries=&Apache::loncommon::record_sep($grade);
- foreach my $dest (keys(%fields)) {
-
- }
+ my @skipped;
+ my $countdone=0;
+ foreach my $grade (@gradedata) {
+ my %entries=&Apache::loncommon::record_sep($grade);
+ my $username=$entries{$fields{'username'}};
+ my $domain=$entries{$fields{'domain'}};
+ if (!exists($classlist{"$username:$domain"})) {
+ push(@skipped,"$username:$domain");
+ next;
}
+ my %grades;
+ foreach my $dest (keys(%fields)) {
+ if ($dest eq 'username' || $dest eq 'domain') { next; }
+ if ($entries{$fields{$dest}} eq '') { next; }
+ my $store_key=$dest;
+ $store_key=~s/^stores/resource/;
+ $store_key=~s/_/\./g;
+ $grades{$store_key}=$entries{$fields{$dest}};
+ }
+ $grades{"resource.regrader"}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ &Apache::lonnet::cstore(\%grades,$symb,$ENV{'request.course.id'},
+ $domain,$username);
+ $request->print('.');
+ $request->rflush();
+ $countdone++;
+ }
+ $request->print(" Stored $countdone students\n");
+ if (@skipped) {
+ $request->print(' Skipped Students ');
+ foreach my $student (@skipped) { $request->print(" $student"); }
}
+ $request->print(&view_edit_entire_class_form($symb,$url));
+ $request->print(&show_grading_menu_form($symb,$url));
+ return '';
}
sub send_header {
@@ -677,8 +814,6 @@ sub send_footer {
sub handler {
my $request=$_[0];
- if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;} else {$Apache::lonxml::debug=0;}
-
if ($ENV{'browser.mathml'}) {
$request->content_type('text/xml');
} else {
@@ -724,7 +859,7 @@ sub handler {
}
}
} else {
- &Apache::lonhomework::showhashsubset(\%ENV,'^form');
+ #&Apache::lonhomework::showhashsubset(\%ENV,'^form');
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
if ($command eq 'submission') {
&listStudents($request) if ($ENV{'form.student'} eq '');
@@ -741,6 +876,8 @@ sub handler {
$request->print(&csvupload($request));
} elsif ($command eq 'csvuploadmap') {
$request->print(&csvuploadmap($request));
+ } elsif ($command eq 'receiptInput') {
+ &receiptInput($request);
} elsif ($command eq 'csvuploadassign') {
if ($ENV{'form.associate'} ne 'Reverse Association') {
$request->print(&csvuploadassign($request));