--- loncom/homework/grades.pm 2010/04/13 11:38:30 1.615
+++ loncom/homework/grades.pm 2010/04/17 22:48:52 1.622
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.615 2010/04/13 11:38:30 www Exp $
+# $Id: grades.pm,v 1.622 2010/04/17 22:48:52 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,6 +43,7 @@ use Apache::lonmsg();
use Apache::Constants qw(:common);
use Apache::lonlocal;
use Apache::lonenc;
+use Apache::lonstathelpers;
use String::Similarity;
use LONCAPA;
@@ -808,17 +809,18 @@ sub verifyreceipt {
#--- Also called directly when one clicks on the subm button
# on the problem page.
sub listStudents {
- my ($request,$symb) = @_;
+ my ($request,$symb,$submitonly) = @_;
my $cdom = $env{"course.$env{'request.course.id'}.domain"};
my $cnum = $env{"course.$env{'request.course.id'}.num"};
my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
my $getgroup = $env{'form.group'} eq '' ? 'all' : $env{'form.group'};
- my $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
- my $viewgrade = $env{'form.showgrading'} eq 'yes' ? 'View/Grade/Regrade' : 'View';
+ unless ($submitonly) {
+ $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'};
+ }
my $result='
'
- .&mt("$viewgrade Submissions for a Student or a Group of Students")
+ .&mt("View/Grade/Regrade Submissions for a Student or a Group of Students")
.' ';
my ($partlist,$handgrade,$responseType) = &response_type($symb
@@ -918,11 +920,10 @@ LISTJAVASCRIPT
&build_section_inputs().
' '."\n".
' '."\n".
- ' '."\n".
' '."\n".
' '."\n";
- if (exists($env{'form.gradingMenu'}) && exists($env{'form.Status'})) {
+ if (exists($env{'form.Status'})) {
$gradeTable .= ' '."\n";
} else {
$gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Student Status'))
@@ -937,7 +938,7 @@ LISTJAVASCRIPT
.&Apache::lonhtmlcommon::end_pick_box();
$gradeTable .= ''
- .&mt('To '.lc($viewgrade)." a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.")."\n"
+ .&mt("To view/grade/regrade a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.")."\n"
.' '
.'
';
@@ -954,9 +955,7 @@ LISTJAVASCRIPT
while ($loop < 2) {
$gradeTable.=''.&mt('No.').' '.&mt('Select').' '.
''.&nameUserString('header').' '.&mt('Section/Group').' ';
- if ($env{'form.showgrading'} eq 'yes'
- && $submitonly ne 'queued'
- && $submitonly ne 'all') {
+ if (($submitonly ne 'queued') && ($submitonly ne 'all')) {
foreach my $part (sort(@$partlist)) {
my $display_part=
&get_display_part((split(/_/,$part))[0],$symb);
@@ -992,9 +991,7 @@ LISTJAVASCRIPT
$status{'gradingqueue'} = $queue_status{'gradingqueue'};
}
- if ($env{'form.showgrading'} eq 'yes'
- && $submitonly ne 'queued'
- && $submitonly ne 'all') {
+ if (($submitonly ne 'queued') && ($submitonly ne 'all')) {
(%status) =&student_gradeStatus($symb,$udom,$uname,$partlist);
my $submitted = 0;
my $graded = 0;
@@ -1035,7 +1032,7 @@ LISTJAVASCRIPT
&nameUserString(undef,$$fullname{$student},$uname,$udom).
' '.$section.($group ne '' ?'/'.$group:'').''."\n";
- if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ if ($submitonly ne 'all') {
foreach (sort(keys(%status))) {
next if ($_ =~ /^resource.*?submitted_by$/);
$gradeTable.=' '.&mt($status{$_}).' '."\n";
@@ -1049,9 +1046,7 @@ LISTJAVASCRIPT
}
if ($ctr%2 ==1) {
$gradeTable.=' ';
- if ($env{'form.showgrading'} eq 'yes'
- && $submitonly ne 'queued'
- && $submitonly ne 'all') {
+ if (($submitonly ne 'queued') && ($submitonly ne 'all')) {
foreach (@$partlist) {
$gradeTable.=' ';
}
@@ -1135,7 +1130,7 @@ sub check_buttons {
# Displays the submissions for one student or a group of students
sub processGroup {
- my ($request) = shift;
+ my ($request,$symb) = @_;
my $ctr = 0;
my @stuchecked = &Apache::loncommon::get_env_multiple('form.stuinfo');
my $total = scalar(@stuchecked)-1;
@@ -1145,7 +1140,7 @@ sub processGroup {
$env{'form.student'} = $uname;
$env{'form.userdom'} = $udom;
$env{'form.fullname'} = $fullname;
- &submission($request,$ctr,$total);
+ &submission($request,$ctr,$total,$symb);
$ctr++;
}
return '';
@@ -1283,7 +1278,6 @@ sub sub_page_js {
}
if (val == "Grade Student") {
- formname.showgrading.value = "yes";
if (formname.Status.value == "") {
formname.Status.value = "Active";
}
@@ -1852,6 +1846,11 @@ sub files_exist {
sub download_all_link {
my ($r,$symb) = @_;
+ unless (&files_exist($r, $symb)) {
+ $r->print(&mt('There are currently no submitted documents.'));
+ return;
+ }
+
my $all_students =
join("\n", &Apache::loncommon::get_env_multiple('form.stuinfo'));
@@ -1864,7 +1863,14 @@ sub download_all_link {
'cgi.'.$identifier.'.parts' => $parts,});
$r->print(''.
&mt('Download All Submitted Documents').' ');
- return
+ return;
+}
+
+sub submit_download_link {
+ my ($request,$symb) = @_;
+ if (!$symb) { return ''; }
+#FIXME: Figure out which type of problem this is and provide appropriate download
+ &download_all_link($request,$symb);
}
sub build_section_inputs {
@@ -1910,10 +1916,7 @@ sub submission {
# header info
if ($counter == 0) {
&sub_page_js($request);
- &sub_page_kw_js($request) if ($env{'form.handgrade'} eq 'yes');
- if ($env{'form.handgrade'} eq 'yes' && &files_exist($request, $symb)) {
- &download_all_link($request, $symb);
- }
+ &sub_page_kw_js($request);
$request->print(' '.&mt('Submission Record').' ');
# option to display problem, only once else it cause problems
@@ -1958,7 +1961,6 @@ sub submission {
' '."\n".
' '."\n".
' '."\n".
- ' '."\n".
' '."\n".
' '."\n".
' '."\n".
@@ -1992,7 +1994,7 @@ sub submission {
}
$request->print($prnmsg);
- if ($env{'form.handgrade'} eq 'yes' && $env{'form.showgrading'} eq 'yes') {
+ if ($env{'form.handgrade'} eq 'yes') {
#
# Print out the keyword options line
#
@@ -2204,9 +2206,7 @@ KEYWORDS
}
$request->print($lastsubonly);
} elsif ($env{'form.lastSub'} eq 'datesub') {
-# my (undef,$responseType,undef,$parts) = &showResourceInfo($symb);
- my ($parts,$handgrade,$responseType) = &response_type($symb);
-
+ my ($parts,$handgrade,$responseType) = &response_type($symb);
$request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom));
} elsif ($env{'form.lastSub'} =~ /^(last|all)$/) {
$request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
@@ -2218,7 +2218,8 @@ KEYWORDS
$request->print(' '."\n");
# return if view submission with no grading option
- if ($env{'form.showgrading'} eq '' || (!&canmodify($usec))) {
+# FIXME: the logic seems off here. Why show the grade button if you cannot grade?
+ if (!&canmodify($usec)) {
my $toGrade.=' '."\n" if (&canmodify($usec));
@@ -8382,9 +8383,7 @@ sub grading_menu {
if (!$symb) {return '';}
my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb),
- 'command'=>'individual',
- 'gradingMenu'=>1,
- 'showgrading'=>"yes");
+ 'command'=>'individual');
my $url1a = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
@@ -8397,6 +8396,9 @@ sub grading_menu {
$fields{'command'}='all_for_one';
my $url1d=&Apache::lonhtmlcommon::build_url('grades/',\%fields);
+ $fields{'command'}='downloadfilesselect';
+ my $url1e=&Apache::lonhtmlcommon::build_url('grades/',\%fields);
+
$fields{'command'} = 'csvform';
my $url2 = &Apache::lonhtmlcommon::build_url('grades/',\%fields);
@@ -8435,6 +8437,12 @@ sub grading_menu {
permission => 'F',
icon => 'edit-find-replace.png',
linktitle => 'Grade all resources in current page/sequence/folder for one student.'
+ },
+ { linktext => 'Download submissions',
+ url => $url1e,
+ permission => 'F',
+ icon => 'edit-find-replace.png',
+ linktitle => 'Download all students submissions.'
}]},
{ categorytitle=>'Automated Grading',
items =>[
@@ -8457,7 +8465,7 @@ sub grading_menu {
icon => 'stat.png',
linktitle => 'Grade scantron exams, upload/download scantron data files, and review previously graded scantron exams.'
},
- { linktext => 'Verify Receipt No.',
+ { linktext => 'Verify Receipt Number',
url => $url5,
permission => 'F',
icon => 'edit-find-replace.png',
@@ -8471,9 +8479,7 @@ sub grading_menu {
my $Str;
$Str .= '';
+ return $result;
+}
#--- Displays the submissions first page -------
sub submit_options {
@@ -8546,10 +8567,7 @@ sub submit_options {
my $result;
$result.='');
+}
+
sub handler {
my $request=$_[0];
&reset_caches();
@@ -9183,11 +9209,12 @@ sub handler {
&Apache::lonenc::check_decrypt(\$symb);
$ssi_error = 0;
- if ($symb eq '' && $command eq '') {
+ if ($symb eq '' || $command eq '') {
#
# Not called from a resource
#
-
+ &startpage($request,undef,[],1,1);
+ &select_problem($request);
} else {
&init_perm();
if ($command eq 'submission' && $perm{'vgr'}) {
@@ -9204,20 +9231,24 @@ sub handler {
{href=>'',text=>'Grade student'}],1,1);
&displayPage($request,$symb);
} elsif ($command eq 'gradeByPage' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>&href_symb_cmd($symb,'all_for_one'),text=>'Grade page/folder for one student'},
+ {href=>'',text=>'Select student'},
+ {href=>'',text=>'Grade student'},
+ {href=>'',text=>'Store grades'}],1,1);
&updateGradeByPage($request,$symb);
} elsif ($command eq 'processGroup' && $perm{'vgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'',text=>'...'},
+ {href=>'',text=>'Modify grades'}]);
&processGroup($request,$symb);
} elsif ($command eq 'gradingmenu' && $perm{'vgr'}) {
&startpage($request,$symb);
$request->print(&grading_menu($request,$symb));
} elsif ($command eq 'individual' && $perm{'vgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'',text=>'Select individual students to grade'}]);
$request->print(&submit_options($request,$symb));
} elsif ($command eq 'ungraded' && $perm{'vgr'}) {
- &startpage($request,$symb);
- $request->print(&submit_options($request,$symb));
+ &startpage($request,$symb,[{href=>'',text=>'Grade ungraded submissions'}]);
+ $request->print(&listStudents($request,$symb,'graded'));
} elsif ($command eq 'table' && $perm{'vgr'}) {
&startpage($request,$symb,[{href=>"", text=>"Grading table"}]);
$request->print(&submit_options_table($request,$symb));
@@ -9228,7 +9259,8 @@ sub handler {
&startpage($request,$symb,[{href=>&href_symb_cmd($symb,"table"), text=>"Grading table"},{href=>'', text=>"Modify grades"}]);
$request->print(&viewgrades($request,$symb));
} elsif ($command eq 'handgrade' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'',text=>'...'},
+ {href=>'',text=>'Store grades'}]);
$request->print(&processHandGrade($request,$symb));
} elsif ($command eq 'editgrades' && $perm{'mgr'}) {
&startpage($request,$symb,[{href=>&href_symb_cmd($symb,"table"), text=>"Grading table"},
@@ -9237,10 +9269,11 @@ sub handler {
{href=>'', text=>"Store grades"}]);
$request->print(&editgrades($request,$symb));
} elsif ($command eq 'initialverifyreceipt' && $perm{'vgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'',text=>'Verify Receipt Number'}]);
$request->print(&initialverifyreceipt($request,$symb));
} elsif ($command eq 'verify' && $perm{'vgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>&href_symb_cmd($symb,"initialverifyreceipt"),text=>'Verify Receipt Number'},
+ {href=>'',text=>'Verification Result'}]);
$request->print(&verifyreceipt($request,$symb));
} elsif ($command eq 'processclicker' && $perm{'mgr'}) {
&startpage($request,$symb,[{href=>'', text=>'Process clicker'}]);
@@ -9255,17 +9288,17 @@ sub handler {
{href=>'', text=>'Store grades'}]);
$request->print(&assign_clicker_grades($request,$symb));
} elsif ($command eq 'csvform' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&upcsvScores_form($request,$symb));
} elsif ($command eq 'csvupload' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&csvupload($request,$symb));
} elsif ($command eq 'csvuploadmap' && $perm{'mgr'} ) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&csvuploadmap($request,$symb));
} elsif ($command eq 'csvuploadoptions' && $perm{'mgr'}) {
if ($env{'form.associate'} ne 'Reverse Association') {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&csvuploadoptions($request,$symb));
} else {
if ( $env{'form.upfile_associate'} ne 'reverse' ) {
@@ -9273,43 +9306,51 @@ sub handler {
} else {
$env{'form.upfile_associate'} = 'forward';
}
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&csvuploadmap($request,$symb));
}
} elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&csvuploadassign($request,$symb));
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&scantron_selectphase($request,undef,$symb));
} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&scantron_do_warning($request,$symb));
} elsif ($command eq 'scantron_validate' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&scantron_validate_file($request,$symb));
} elsif ($command eq 'scantron_process' && $perm{'mgr'}) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&scantron_process_students($request,$symb));
} elsif ($command eq 'scantronupload' &&
(&Apache::lonnet::allowed('usc',$env{'request.role.domain'})||
&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&scantron_upload_scantron_data($request,$symb));
} elsif ($command eq 'scantronupload_save' &&
(&Apache::lonnet::allowed('usc',$env{'request.role.domain'})||
&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&scantron_upload_scantron_data_save($request,$symb));
} elsif ($command eq 'scantron_download' &&
&Apache::lonnet::allowed('usc',$env{'request.course.id'})) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
$request->print(&scantron_download_scantron_data($request,$symb));
} elsif ($command eq 'checksubmissions' && $perm{'vgr'}) {
- &startpage($request,$symb);
- $request->print(&checkscantron_results($request,$symb));
+ &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1);
+ $request->print(&checkscantron_results($request,$symb));
+ } elsif ($command eq 'downloadfilesselect' && $perm{'vgr'}) {
+ &startpage($request,$symb,[{href=>'', text=>'Select which submissions to download'}]);
+ $request->print(&submit_options_download($request,$symb));
+ } elsif ($command eq 'downloadfileslink' && $perm{'vgr'}) {
+ &startpage($request,$symb,
+ [{href=>&href_symb_cmd($symb,'downloadfilesselect'), text=>'Select which submissions to download'},
+ {href=>'', text=>'Download submissions'}]);
+ &submit_download_link($request,$symb);
} elsif ($command) {
- &startpage($request,$symb);
+ &startpage($request,$symb,[{href=>'', text=>'Access denied'}]);
$request->print(''.&mt('Access Denied ([_1])',$command).'
');
}
}