-
-Username Name Domain
+
+
+Resource: $ENV{'form.url'}
+Username Name Domain
+View Problem Submissions Action
ENDTABLEST
my (%classlist) = &getclasslist($cdom,$cnum,'0');
foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
@@ -131,26 +145,32 @@ ENDTABLEST
$fullname.=$name{'firstname'}.' '.$name{'middlename'};
}
if ( $Apache::grades::viewgrades eq 'F' ) {
- $request->print("\n".''."$sname $fullname $sdom ".
+ $request->print("\n".' '."$sname $fullname $sdom ".
' ');
# $request->print('');
}
@@ -201,7 +221,7 @@ sub getpartlist {
my @parts =();
my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys'));
foreach my $key (@metakeys) {
- if ( $key =~ m/stores_([0-9]+)_.*/ ) {
+ if ( $key =~ m/stores_([0-9]+)_.*/) {
push(@parts,$key);
}
}
@@ -224,44 +244,33 @@ sub viewstudentgrade {
$result.="$username $fullname $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.=" \n";
- } elsif ($type eq 'tries') {
- my $score=$record{"resource.$part.$type"};
- $result.=" \n"
+ my $score=$record{"resource.$part.$type"};
+ if ($type eq 'awarded' || $type eq 'tries') {
+ $result.=' '."\n";
} elsif ($type eq 'solved') {
- my $score=$record{"resource.$part.$type"};
+ my ($status,$foo)=split(/_/,$score,2);
$result.="\n";
- if ($score =~ /^correct/) {
- $result.="correct \nincorrect \nexcused \nungraded \nnothing \n";
- } elsif ($score =~ /^incorrect/) {
- $result.="correct \nincorrect \nexcused \nungraded \nnothing \n";
- } elsif ($score eq '') {
- $result.="correct \nincorrect \nexcused \nungraded \nnothing \n";
- } elsif ($score =~ /^excused/) {
- $result.="correct \nincorrect \nexcused \nungraded \nnothing \n";
- } elsif ($score =~ /^ungraded/) {
- $result.="correct \nincorrect \nexcused \nungraded \nnothing \n";
- }
+ my $optsel = 'correct incorrect excused '.
+ 'ungraded handgraded nothing '."\n";
+ $status = 'nothing' if ($status eq '');
+ $optsel =~ s/$status/ $status/;
+ $result.=$optsel;
$result.=" \n";
}
}
- $result.=' ';
+ $result.=' ';
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) {
@@ -304,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;
@@ -319,17 +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'});
+#
+# header info
my $result='Submission Record ';
- $result.='Username : '.$uname.'Fullname : '.$ENV{'form.fullname'}.'Domain : '.$udom.'Resource : '.$url.' '.$answer;
- my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
+ $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.='';
+ $result.='';
+ $result.='Student\'s view of the problem '.$rendered.' ';
+ $result.='Correct answer: '.$companswer;
+ $result.='
';
+ $result.='
';
+ }
+ my $last = '';
+ $last = 'last' if ($ENV{'form.submission'} eq 'last');
+ my $answer=&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
+ $ENV{'request.course.id'},$last);
$result.=$answer;
+
+ my $maxpt = &Apache::lonnet::EXT('resource.partid.weight',$symb,$udom,$uname);
+ my %record= &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
+ my $score = $record{'resource.0.awarded'}*$maxpt;
+
+ $result.= '';
return $result;
}
@@ -343,33 +412,56 @@ sub get_symb_and_url {
return ($symb,$url);
}
+sub view_edit_entire_class_form {
+ my ($symb,$url)=@_;
+ my $result.=''."\n";
+ return $result;
+}
+
+sub show_grading_menu_form {
+ my ($symb,$url)=@_;
+ my $result.=''."\n";
+ return $result;
+}
+
sub gradingmenu {
my ($request) = @_;
my ($symb,$url)=&get_symb_and_url($request);
if (!$symb) {return '';}
my $result=' Select a Grading Method ';
- $result.=''."\n";
+ $result.=''."\n";
$result.=''."\n";
$result.=' Resource : '.$url.' '."\n";
$result.=''."\n";
+ $result.=&view_edit_entire_class_form($symb,$url);
$result.=''."\n";
$result.=''."\n";
$result.=''."\n";
$result.='
'."\n";
$result.='
'."\n";
@@ -391,7 +483,7 @@ 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 ");
@@ -401,21 +493,25 @@ sub viewgrades {
' '."\n".
' '."\n".
' '."\n".
- ''."\n".
+ ''."\n".
''."\n".
'Username Name Domain '."\n";
- foreach my $part (sort(@parts)) {
+ foreach my $part (@parts) {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
+ print "Manual grading:$url:$part:$display: ";
$result.=''.$display.' '."\n";
- }
+ }
$result.=' ';
#get info for each student
foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
+ my $display=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);
+# print "ID=$ENV{'request.course.id'}:STU=$student:DIS=$display: \n";
$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);
}
- $result.='
';
-
+ $result.='
';
+ $result.=' ';
+ $result.=&show_grading_menu_form($symb,$url);
return $result;
}
@@ -658,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 {
@@ -695,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 {
@@ -742,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 '');
@@ -759,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));