\n";
+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);
+ }
}
- }
- $result.='
';
- return $result;
+ return @parts;
}
#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) = @_;
- print "set student grade parts=@parts ";
- my $result ='';
- my ($stuname,$domain) = split(/:/,$student);
- my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
- my %newrecord;
-
- foreach my $part (@parts) {
- my ($temp,$part,$type)=split(/_/,$part);
- my $oldscore=$record{"resource.$part.$type"};
- my $newscore=$ENV{"form.GRADE.$student.$part.$type"};
- print "old=$oldscore:new=$newscore: ";
- if ($type eq 'solved') {
- my $update=0;
- if ($newscore eq 'nothing' ) {
- if ($oldscore ne '') {
- $update=1;
- $newscore = '';
- }
- } elsif ($oldscore !~ m/^$newscore/) {
- $update=1;
- $result.="Updating $stuname to $newscore \n";
- if ($newscore eq 'correct') { $newscore = 'correct_by_override'; }
- if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }
- if ($newscore eq 'excused') { $newscore = 'excused'; }
- if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
-# if ($newscore eq 'partial') { $newscore = 'correct_partially_by_override'; }
- } else {
- #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
- }
- if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }
- } else {
- if ($oldscore ne $newscore) {
- $newrecord{"resource.$part.$type"}=$newscore;
- $result.="Updating $student"."'s status for $part.$type to $newscore \n";
- } else {
- #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
- }
+ 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) {
+ my ($temp,$part,$type)=split(/_/,$part);
+ my $oldscore=$record{"resource.$part.$type"};
+ my $newscore=$ENV{"form.GRADE.$student.$part.$type"};
+ if ($type eq 'solved') {
+ my $update=0;
+ if ($newscore eq 'nothing' ) {
+ if ($oldscore ne '') {
+ $update=1;
+ $newscore = '';
+ }
+ } elsif ($oldscore !~ m/^$newscore/) {
+ $update=1;
+ $result.="Updating $stuname to $newscore \n";
+ if ($newscore eq 'correct') { $newscore = 'correct_by_override'; }
+ if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }
+ if ($newscore eq 'excused') { $newscore = 'excused'; }
+ if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
+ } else {
+ #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
+ }
+ if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }
+ } else {
+ if ($oldscore ne $newscore) {
+ $newrecord{"resource.$part.$type"}=$newscore;
+ $result.="Updating $student"."'s status for $part.$type to $newscore \n";
+ } else {
+ #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore: \n";
+ }
+ }
}
- }
- if ( scalar(keys(%newrecord)) > 0 ) {
- $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
-# &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
+ if ( scalar(keys(%newrecord)) > 0 ) {
+ $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+# &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
- $result.="Stored away ".scalar(keys(%newrecord))." elements. \n";
- }
- return $result;
+ $result.="Stored away ".scalar(keys(%newrecord))." elements. \n";
+ }
+ return $result;
}
+sub print_hash {
+ my ($request, $hash) = @_;
+ $request->print('
Key
Value
');
+ for (sort keys (%$hash)) {
+ $request->print('
'.$_.'
'.$$hash{$_}.'
');
+ }
+ $request->print('
');
+ return '';
+}
#
# --------------------------- show submissions of a student, option to grade --------
sub submission {
- my ($request,$counter,$total) = @_;
-
- (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 ''; }
- my ($uname,$udom) = &finduser($ENV{'form.student'});
- 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
- if ($counter == 0) {
- &sub_page_js($request);
- $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.
- if ($ENV{'form.vProb'} eq 'yes') {
- my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
- $ENV{'request.course.id'});
- my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
- $ENV{'request.course.id'});
- my $result.='
';
- $request->print($result);
- }
+ my ($request,$counter,$total) = @_;
- # kwclr is the only variable that is guaranteed to be non blank if this subroutine has been called once.
- my %keyhash = ();
- if ($ENV{'form.kwclr'} eq '') {
- %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'};
- $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.msgsub'} = $keyhash{$symb.'_subject'} ne '' ?
- $keyhash{$symb.'_subject'} : &Apache::lonnet::metadata($url,'title');
- $ENV{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
+ (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 ''; }
+ my ($uname,$udom) = &finduser($ENV{'form.student'});
+ 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' : '');
+ $ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes';
+ my ($classlist,$seclist,$ids,$stusec,$fullname);
+
+ # header info
+ if ($counter == 0) {
+ &sub_page_js($request);
+ $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.
+ if ($ENV{'form.vProb'} eq 'yes') {
+ my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
+ $ENV{'request.course.id'});
+ my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
+ $ENV{'request.course.id'});
+ my $result.='
'."\n";
+ return $result;
}
sub viewGradeaStu_form {
- my ($symb,$url,$response,$handgrade) = @_;
- my ($classlist,$sections) = &getclasslist('all','0');
- my $result.='
'."\n";
- $result.='
'."\n";
- $result.=' View/Grade an Individual Student\'s Submission
'."\n";
- $result.='
'."\n";
- $result.=''."\n";
- $result.='
'."\n";
- $result.='
'."\n";
- return $result;
+ my ($symb,$url,$response,$handgrade) = @_;
+ my ($classlist,$sections) = &getclasslist('all','0');
+ my $result.='
'."\n";
+ $result.='
'."\n";
+ $result.=' View/Grade an Individual Student\'s Submission
'."\n";
+ $result.='
'."\n";
+ $result.=''."\n";
+ $result.='
'."\n";
+ $result.='
'."\n";
+ return $result;
}
sub verifyReceipt_form {
- my ($symb,$url) = @_;
- 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'});
-
- my $result.='
'."\n";
- $result.='
'."\n";
- $result.=' Verify a Submission Receipt Issued by this Server
'."\n";
- $result.='
'."\n";
- $result.='';
- $result.='
'."\n";
- $result.='
'."\n";
- return $result;
+ my ($symb,$url) = @_;
+ 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'});
+
+ my $result.='
'."\n";
+ $result.='
'."\n";
+ $result.=' Verify a Submission Receipt Issued by this Server
'."\n";
+ $result.='
'."\n";
+ $result.='';
+ $result.='
'."\n";
+ $result.='
'."\n";
+ return $result;
}
sub viewgrades {
- my ($request) = @_;
- my $result='';
+ my ($request) = @_;
+ $request->print(<
+ function viewOneStudent(user) {
+ document.onestudent.student.value = user;
+ document.onestudent.submit();
+ }
+
+
+ function writePoint(partid,weight,point) {
+ for (i=0;i
+VIEWJAVASCRIPT
+
+ my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'});
+ $request->print ('
Manual Grading
');
- #get resource reference
- my ($symb,$url)=&get_symb_and_url($request);
- if (!$symb) {return '';}
- #get classlist
- my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
- #print "Found $cdom:$cnum ";
- my ($classlist) = &getclasslist('all','0');
- my $headerclr = '"#ddffff"';
- my $cellclr = '"#ffffdd"';
-
- #get list of parts for this problem
- my (@parts) = sort(&getpartlist($url));
-
- $request->print ("
Manual Grading
");
-
- #start the form
- $result = ''."\n";
+
+ #start the form
+ $result.= '';
- $result.=&show_grading_menu_form($symb,$url);
- return $result;
+ ''."\n";
+ $result.='To assign the same score for all the students use the radio buttons or box below. '.
+ 'To assign individual score fill in the score for each student in the table below. ';
+ $result.='
';
+ for (sort keys (%weight)) {
+ my $ctr = 0;
+ $result.='
Part '.$_.'
';
+ $result.='
'; # display radio buttons in a nice table 10 across
+ while ($ctr<=$weight{$_}) {
+ $result.= '
'.$ctr."
\n";
+ $result.=(($ctr+1)%10 == 0 ? '
' : '');
+ $ctr++;
+ }
+ $result.='
';
+ }
+ $result.='
';
+
+ $result.= ''."\n".
+ '
'."\n".
+ '
'.
+ '
Username
Fullname
Domain
'."\n";
+ #get list of parts for this problem
+ my (@parts) = sort(&getpartlist($url));
+ foreach my $part (@parts) {
+ my $display=&Apache::lonnet::metadata($url,$part.'.display');
+ next if ($display =~ /^Number of Attempts/);
+ if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
+ if ($display =~ /^Partial Credit Factor/) {
+ $_ = $display;
+ my ($partid) = /.*?(\d+).*/;
+ $result.='
Score Part '.$partid.' (weight = '.$weight{$partid}.')
'."\n";
+ foreach my $part (@$parts) {
+ my ($temp,$part,$type)=split(/_/,$part);
+ my $score=$record{"resource.$part.$type"};
+ next if $type eq 'tries';
+ if ($type eq 'awarded') {
+ my $pts = $score*$$weight{$part};
+ $result.='