--- loncom/homework/grades.pm 2004/11/23 14:19:32 1.231
+++ loncom/homework/grades.pm 2005/10/30 02:40:09 1.293
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.231 2004/11/23 14:19:32 albertel Exp $
+# $Id: grades.pm,v 1.293 2005/10/30 02:40:09 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -80,8 +80,8 @@ sub getpartlist {
# --- Get the symbolic name of a problem and the url
sub get_symb_and_url {
my ($request,$silent) = @_;
- (my $url=$ENV{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
- my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
+ (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
+ my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url)));
if ($symb eq '') {
if (!$silent) {
$request->print("Unable to handle ambiguous references:$url:.");
@@ -96,10 +96,10 @@ sub get_symb_and_url {
sub nameUserString {
my ($type,$fullname,$uname,$udom) = @_;
if ($type eq 'header') {
- return ' Fullname (Username) ';
+ return ' Fullname (Username)';
} else {
return ' '.$fullname.' ('.$uname.
- ($ENV{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')';
+ ($env{'user.domain'} eq $udom ? '' : ' ('.$udom.')').')';
}
}
@@ -107,7 +107,7 @@ sub nameUserString {
#--- Indicate if a response type is coded handgraded or not. ---
sub response_type {
my ($url,$symb) = shift;
- $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
+ $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url))) if ($symb eq '');
my $allkeys = &Apache::lonnet::metadata($url,'keys');
my %vPart;
foreach my $partid (&Apache::loncommon::get_env_multiple('form.vPart')) {
@@ -141,7 +141,7 @@ sub response_type {
sub get_display_part {
my ($partID,$url,$symb)=@_;
if (!defined($symb) || $symb eq '') {
- $symb=$ENV{'form.symb'};
+ $symb=$env{'form.symb'};
if ($symb eq '') { $symb=&Apache::lonnet::symbread($url) }
}
my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb);
@@ -152,6 +152,7 @@ sub get_display_part {
}
return $display;
}
+
#--- Show resource title
#--- and parts and response type
sub showResourceInfo {
@@ -199,7 +200,7 @@ sub get_order {
('grade_domain' => $udom),
('grade_symb' => $symb),
('grade_courseid' =>
- $ENV{'request.course.id'}),
+ $env{'request.course.id'}),
('grade_username' => $uname));
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
my %analyze=&Apache::lonnet::str2hash($subresult);
@@ -270,20 +271,25 @@ sub cleanRecord {
'
'.$grayFont.'Option ID
'.
$grayFont.$bottomrow.'
'.'';
} elsif ($response eq 'essay') {
- if (! exists ($ENV{'form.'.$symb})) {
+ 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'});
+ $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.
+ 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.
}
$answer =~ s-\n- -g;
return '
'.&keywords_highlight($answer).'
';
+ } elsif ( $response eq 'organic') {
+ my $result='Smile representation: "'.$answer.'"';
+ my $jme=$record->{$version."resource.$partid.$respid.molecule"};
+ $result.=&Apache::chemresponse::jme_img($jme,$answer,400);
+ return $result;
}
return $answer;
}
@@ -328,7 +334,16 @@ COMMONJSFUNCTIONS
#--- section, ids and fullnames for each user.
sub getclasslist {
my ($getsec,$filterlist) = @_;
- $getsec = $getsec eq '' ? 'all' : $getsec;
+ my @getsec;
+ if (!ref($getsec)) {
+ if ($getsec ne '' && $getsec ne 'all') {
+ @getsec=($getsec);
+ }
+ } else {
+ @getsec=@{$getsec};
+ }
+ if (grep(/^all$/,@getsec)) { undef(@getsec); }
+
my $classlist=&Apache::loncoursedata::get_classlist();
# Bail out if we were unable to get the classlist
return if (! defined($classlist));
@@ -349,15 +364,15 @@ sub getclasslist {
my $status =
$classlist->{$student}->[&Apache::loncoursedata::CL_STATUS()];
# filter students according to status selected
- if ($filterlist && $ENV{'form.Status'} ne 'Any') {
- if ($ENV{'form.Status'} ne $status) {
+ if ($filterlist && $env{'form.Status'} ne 'Any') {
+ if ($env{'form.Status'} ne $status) {
delete ($classlist->{$student});
next;
}
}
$section = ($section ne '' ? $section : 'none');
if (&canview($section)) {
- if ($getsec eq 'all' || $getsec eq $section) {
+ if (!@getsec || grep(/^\Q$section\E$/,@getsec)) {
$sections{$section}++;
$fullnames{$student}=$fullname;
} else {
@@ -415,7 +430,7 @@ sub canview {
#--- Retrieve the grade status of a student for all the parts
sub student_gradeStatus {
my ($url,$symb,$udom,$uname,$partlist) = @_;
- my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+ my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
my %partstatus = ();
foreach (@$partlist) {
my ($status,undef) = split(/_/,$record{"resource.$_.solved"},2);
@@ -442,9 +457,9 @@ sub jscriptNform {
$jscript.= ''."\n";
if (scalar(%$fullname) eq 0) {
my $colspan=3+scalar(@parts);
- $result='There are no students in section "'.$ENV{'form.section'}.
- '" with enrollment status "'.$ENV{'form.Status'}.'" to modify or grade.';
+ $result='There are no students in section "'.$env{'form.section'}.
+ '" with enrollment status "'.$env{'form.Status'}.'" to modify or grade.';
}
$result.=&show_grading_menu_form($symb,$url);
return $result;
@@ -2416,22 +2671,41 @@ sub viewgrades {
#--- call by previous routine to display each student
sub viewstudentgrade {
- my ($url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr) = @_;
+ my ($url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr,$last_resets) = @_;
my ($uname,$udom) = split(/:/,$student);
- $student=~s/:/_/;
my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
- my $result='