--- loncom/homework/grades.pm 2001/02/09 03:24:45 1.2
+++ loncom/homework/grades.pm 2001/04/16 23:34:11 1.5
@@ -1,50 +1,226 @@
# The LON-CAPA Grading handler
-# Guy Albertelli
-# 11/30 Gerd Kortemeyer
-# 6/1 Gerd Kortemeyer
+# 2/9,2/13 Guy Albertelli
package Apache::grades;
use strict;
use Apache::style;
use Apache::lonxml;
use Apache::lonnet;
+use Apache::loncommon;
use Apache::lonhomework;
use Apache::Constants qw(:common);
sub moreinfo {
my ($request,$reason) = @_;
$request->print("Unable to process request: $reason");
- $request->print('
');
+ if ( $Apache::grades::viewgrades eq 'F' ) {
+ $request->print('');
+ }
+ return '';
}
+#FIXME - needs to be much smarter
sub finduser {
my ($name) = @_;
-
+
+ if ( $Apache::grades::viewgrades eq 'F' ) {
+ return ($name,$ENV{'user.domain'});
+ } else {
+ return ($ENV{'user.name'},$ENV{'user.domain'});
+ }
+}
+
+sub getclasslist {
+ my ($coursedomain,$coursenum,$coursehome,$hideexpired) = @_;
+ my $classlist=&Apache::lonnet::reply("dump:$coursedomain:$coursenum:classlist",$coursehome);
+ my %classlist=();
+ my $now = time;
+ foreach my $record (split /&/, $classlist) {
+ my ($name,$value)=split(/=/,&Apache::lonnet::unescape($record));
+ my ($end,$start)=split(/:/,$value);
+ # still a student?
+ if (($hideexpired) && ($end) && ($end < $now)) {
+ print "Skipping:$name:$end:$now \n";
+ next;
+ }
+ push( @{ $classlist{'allids'} }, $name);
+ }
+ return (%classlist);
+}
+
+sub getpartlist {
+ my ($url) = @_;
+ my @parts =();
+ my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys'));
+ foreach my $key (@metakeys) {
+ if ( $key =~ m/stores_([0-9]+)_.*/ ) { push(@parts,$key); }
+ }
+ return @parts;
+}
+
+sub viewstudentgrade {
+ my ($url,$symb,$courseid,$student,@parts) = @_;
+ my $result ='';
+
+ my ($stuname,$domain) = split(/:/,$student);
+
+ my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname,
+ &Apache::lonnet::homeserver($stuname,$domain));
+
+ $result.="
$stuname
$domain
\n";
+ foreach my $part (@parts) {
+ my ($temp,$part,$type)=split(/_/,$part);
+ #print "resource.$part.$type = ".$record{"resource.$part.$type"}." \n";
+ if ($type eq 'awarded') {
+ my $score=$record{"resource.$part.$type"};
+ $result.="