--- loncom/homework/grades.pm 2010/03/15 07:54:04 1.598 +++ loncom/homework/grades.pm 2010/04/07 21:08:35 1.607 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.598 2010/03/15 07:54:04 www Exp $ +# $Id: grades.pm,v 1.607 2010/04/07 21:08:35 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -214,55 +214,6 @@ sub get_display_part { return $display; } -#--- Show resource title -#--- and parts and response type -#sub showResourceInfo { -# my ($symb,$probTitle,$checkboxes,$res_error) = @_; -# my $result = '

'.&mt('Current Resource').': '.$probTitle.'

'."\n"; -# my ($partlist,$handgrade,$responseType) = &response_type($symb,$res_error); -# if (ref($res_error)) { -# if ($$res_error) { -# return; -# } -# } -# $result.=&Apache::loncommon::start_data_table() -# .&Apache::loncommon::start_data_table_header_row(); -# if ($checkboxes) { -# $result.=' '; -# } -# $result.=''.&mt('Problem Part').'' -# .''.&mt('Res. ID').'' -# .''.&mt('Type').'' -# .&Apache::loncommon::end_data_table_header_row(); -# my %resptype = (); -# my $hdgrade='no'; -# my %partsseen; -# foreach my $partID (sort(keys(%$responseType))) { -# foreach my $resID (sort(keys(%{ $responseType->{$partID} }))) { -# my $handgrade=$$handgrade{$partID.'_'.$resID}; -# my $responsetype = $responseType->{$partID}->{$resID}; -# $hdgrade = $handgrade if ($handgrade eq 'yes'); -# $result.=&Apache::loncommon::start_data_table_row(); -# if ($checkboxes) { -# if (exists($partsseen{$partID})) { -# $result.=" "; -# } else { -# $result.=""; -# } -# $partsseen{$partID}=1; -# } -# my $display_part=&get_display_part($partID,$symb); -# $result.=''.$display_part.'' -# .''.''.$resID.'' -# .''.&mt($responsetype).'' -# .''.&mt('Handgrade: [_1]',$handgrade).'' -# .&Apache::loncommon::end_data_table_row(); -# } -# } -# $result.=&Apache::loncommon::end_data_table(); -# return $result,$responseType,$hdgrade,$partlist,$handgrade; -#} - sub reset_caches { &reset_analyze_cache(); &reset_perm(); @@ -686,7 +637,6 @@ sub jscriptNform { $jscript.= '
'."\n". ''."\n". ''."\n". - ''."\n". ''."\n". ''."\n". ''."\n". @@ -776,6 +726,19 @@ sub most_similar { #------------------------------------ Receipt Verification Routines # + +sub initialverifyreceipt { + my $request = shift; + &commonJSfunctions($request); + my ($symb) = &get_symb($request); + return ''. + &Apache::lonnet::recprefix($env{'request.course.id'}). + '-'. + ''."\n". + ''. + "
\n"; +} + #--- Check whether a receipt number is valid.--- sub verifyreceipt { my $request = shift; @@ -788,10 +751,8 @@ sub verifyreceipt { my $title.= '

'. - &mt('Verifying Receipt No. [_1]',$receipt). - '

'."\n". - '

'.&mt('Resource: [_1]',$env{'form.probTitle'}). - '

'."\n"; + &mt('Verifying Receipt Number [_1]',$receipt). + ''."\n"; my ($string,$contents,$matches) = ('','',0); my (undef,undef,$fullname) = &getclasslist('all','0'); @@ -878,14 +839,11 @@ sub listStudents { 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'; - $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ? - &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'}; my $result='

 ' .&mt("$viewgrade Submissions for a Student or a Group of Students") .'

'; -# my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes')); my ($partlist,$handgrade,$responseType) = &response_type($symb #,$res_error ); @@ -985,7 +943,6 @@ LISTJAVASCRIPT '
'."\n". '
'."\n". ''."\n". - ''."\n". ''."\n". ''."\n"; @@ -1795,7 +1752,6 @@ sub gradeBox { $line.=''."\n"; - #&mt('Part:[_1]Points:[_2]or[_3]',$display_part,$radio,$line); $result .= ''.$display_part.''.$radio.''.&mt('or').''.$line.''; $result.=&Apache::loncommon::end_data_table_row(); @@ -1956,7 +1912,8 @@ sub submission { $udom = ($udom eq '' ? $env{'user.domain'} : $udom); #has form.userdom changed for a student? my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'}); $env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq ''; - my $symb = &get_symb($request); + my $symb = &get_symb($request); + my $probtitle=&Apache::lonnet::gettitle($symb); if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; } if (!&canview($usec)) { @@ -1980,13 +1937,10 @@ sub submission { if ($counter == 0) { &sub_page_js($request); &sub_page_kw_js($request) if ($env{'form.handgrade'} eq 'yes'); - $env{'form.probTitle'} = $env{'form.probTitle'} eq '' ? - &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'}; if ($env{'form.handgrade'} eq 'yes' && &files_exist($request, $symb)) { &download_all_link($request, $symb); } - $request->print('

 '.&mt('Submission Record').'

'."\n". - '

 '.&mt('Resource: [_1]',$env{'form.probTitle'}).'

'."\n"); + $request->print('

 '.&mt('Submission Record').'

'); # option to display problem, only once else it cause problems # with the form later since the problem has a form. @@ -2017,7 +1971,7 @@ sub submission { $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'} : $env{'form.probTitle'}; + $keyhash{$symb.'_subject'} : $probtitle; $env{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0'; } my $overRideScore = $env{'form.overRideScore'} eq '' ? 'no' : $env{'form.overRideScore'}; @@ -2027,7 +1981,6 @@ sub submission { ''."\n". ''."\n". ''."\n". - ''."\n". ''."\n". ''."\n". ''."\n". @@ -2575,7 +2528,7 @@ sub processHandGrade { if ($env{'form.withgrades'.$ctr}) { $message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt; $messagetail = " for $env{'form.probTitle'}"; + $feedurl."?symb=$showsymb\">$restitle"; } $msgstatus = &Apache::lonmsg::user_normal_msg($uname,$udom,$subject, @@ -2603,7 +2556,7 @@ sub processHandGrade { $udom); if ($env{'form.withgrades'.$ctr}) { $messagetail = " for $env{'form.probTitle'}"; + $baseurl."?symb=$showsymb\">$restitle"; } $msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$subject,$message.$messagetail,undef,$baseurl,undef,undef,undef,$showsymb,$restitle); @@ -2703,6 +2656,7 @@ sub processHandGrade { } return $a cmp $b; } (keys(%$fullname))) { +# FIXME: this is fishy, looks like the button label if ($nextflg == 1 && $button =~ /Next$/) { push(@parsedlist,$item); } @@ -2713,6 +2667,7 @@ sub processHandGrade { } } $ctr = 0; +# FIXME: this is fishy, looks like the button label @parsedlist = reverse @parsedlist if ($button eq 'Previous'); my $res_error; my ($partlist) = &response_type($symb,\$res_error); @@ -3348,7 +3303,6 @@ sub viewgrades { &Apache::lonnet::clear_EXT_cache_status(); my $result='

'.&mt('Manual Grading').'

'; - $result.='

'.&mt('Current Resource: [_1]',$env{'form.probTitle'}).'

'."\n"; #view individual student submission form - called using Javascript viewOneStudent $result.=&jscriptNform($symb); @@ -3361,7 +3315,6 @@ sub viewgrades { &build_section_inputs(). ''."\n". ''."\n". - ''."\n"; my ($common_header,$specific_header); if ($env{'form.section'} eq 'all') { @@ -3584,7 +3537,6 @@ sub editgrades { my $symb=&get_symb($request); my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section')); my $title='

'.&mt('Current Grade Status').'

'; - $title.='

'.&mt('Current Resource: [_1]',$env{'form.probTitle'}).'

'."\n"; $title.='

'.&mt('Section: [_1]',$section_display).'

'."\n"; my $result= &Apache::loncommon::start_data_table(). @@ -3906,7 +3858,6 @@ sub csvuploadmap_header { $javascript=&csvupload_javascript_forward_associate(); } -# my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); my $result=''; my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); my $ignore=&mt('Ignore First Line'); @@ -3931,7 +3882,6 @@ to this page if the data selected is ins value="$env{'form.upfile_associate'}" /> -
ENDPICK @@ -3997,9 +3947,6 @@ sub upcsvScores_form { my ($symb)=&get_symb($request); if (!$symb) {return '';} my $result=&checkforfile_js(); - $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb); -# my ($table) = &showResourceInfo($symb,$env{'form.probTitle'}); -# $result.=$table; $result.='
'."\n"; $result.=' + '.&Apache::loncommon::end_data_table_header_row().' + '.&Apache::loncommon::start_data_table_row().' + + '.&Apache::loncommon::end_data_table_row().' + '.&Apache::loncommon::end_data_table().' +'); + } + # Chunk of form to prompt for a file to grade and how: $result.= ' @@ -5292,51 +5283,7 @@ sub scantron_selectphase { $r->print($result); - if (&Apache::lonnet::allowed('usc',$env{'request.role.domain'}) || - &Apache::lonnet::allowed('usc',$env{'request.course.id'})) { - # Chunk of form to prompt for a scantron file upload. - - $r->print(' -
- '.&Apache::loncommon::start_data_table('LC_scantron_action').' - '.&Apache::loncommon::start_data_table_header_row().' - - '.&Apache::loncommon::end_data_table_header_row().' - '.&Apache::loncommon::start_data_table_row().' - - '.&Apache::loncommon::end_data_table_row().' - '.&Apache::loncommon::end_data_table().' -'); - } # Chunk of the form that prompts to view a scoring office file, # corrected file, skipped records in a file. @@ -8515,29 +8462,13 @@ sub show_grading_menu_form { return $result; } -# -- Retrieve choices for grading form -sub savedState { - my %savedState = (); - if ($env{'form.saveState'}) { - foreach (split(/:/,$env{'form.saveState'})) { - my ($key,$value) = split(/=/,$_,2); - $savedState{$key} = $value; - } - } - return \%savedState; -} - sub grading_menu { my ($request) = @_; my ($symb)=&get_symb($request); if (!$symb) {return '';} - my $probTitle = &Apache::lonnet::gettitle($symb); -# $request->print($table); my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb), - 'probTitle'=>$probTitle, 'command'=>'individual', - 'saveState'=>"", 'gradingMenu'=>1, 'showgrading'=>"yes"); @@ -8560,6 +8491,9 @@ sub grading_menu { $fields{'command'} = 'scantron_selectphase'; my $url4 = &Apache::lonhtmlcommon::build_url('grades/',\%fields); + + $fields{'command'} = 'initialverifyreceipt'; + my $url5 = &Apache::lonhtmlcommon::build_url('grades/',\%fields); my @menu = ({ categorytitle=>'Hand Grading', items =>[ @@ -8582,7 +8516,7 @@ sub grading_menu { icon => 'edit-find-replace.png', linktitle => 'Grade current resource for all students.' }, - { linktext => 'Grade complete page/sequence/folder for one student.', + { linktext => 'Grade complete page/sequence/folder for one student', url => $url1d, permission => 'F', icon => 'edit-find-replace.png', @@ -8608,179 +8542,129 @@ sub grading_menu { permission => 'F', icon => 'stat.png', linktitle => 'Grade scantron exams, upload/download scantron data files, and review previously graded scantron exams.' - } + }, + { linktext => 'Verify Receipt No.', + url => $url5, + permission => 'F', + icon => 'edit-find-replace.png', + linktitle => 'Verify a system-generated receipt number for correct problem solution.' + } + ] }); - #$fields{'command'} = 'verify'; - #$url = &Apache::lonhtmlcommon::build_url('grades/',\%fields); - # # Create the menu my $Str; - # $Str .= '

'.&mt('Please select a grading task').'

'; $Str .= ''; $Str .= ''. ''."\n". -# ''."\n". - ''."\n". - ''."\n". ''."\n". ''."\n"; - $Str .= Apache::lonhtmlcommon::generate_menu(@menu); - #$menudata->{'jscript'} - $Str .='
'. - &Apache::lonnet::recprefix($env{'request.course.id'}). - '-'; - - $Str .="\n"; - my $receiptalert = &mt("Please enter a receipt number given by a student in the receipt box."); - $request->print(&Apache::lonhtmlcommon::scripttag(<'."\n". + ''."\n". + ''."\n"; + + $result.=' +

+ '.&mt('Grade complete page/sequence/folder for one student').' +

'. + &selectfield(0). + ' +
+ +
+ + '; + $result .= &show_grading_menu_form($symb); + return $result; } -sub all_for_one { - my ($request)=@_; - &submit_options($request); +sub submit_options_table { + my ($request) = @_; + my ($symb)=&get_symb($request); + if (!$symb) {return '';} + &commonJSfunctions($request); + my $result; + + $result.='
'."\n". + ''."\n". + ''."\n". + ''."\n"; + + $result.=' +

+ '.&mt('Grading table').' +

'. + &selectfield(0). + ' +
+ +
+ + '; + $result .= &show_grading_menu_form($symb); + return $result; } + #--- Displays the submissions first page ------- sub submit_options { my ($request) = @_; my ($symb)=&get_symb($request); if (!$symb) {return '';} - my $probTitle = &Apache::lonnet::gettitle($symb); - my $receiptalert = &mt("Please enter a receipt number given by a student in the receipt box."); - $request->print(&Apache::lonhtmlcommon::scripttag(<'.$section.''."\n"; - } - } $result.='
'."\n". ''."\n". -# ''."\n". - ''."\n". - ''."\n". - ''."\n". ''."\n". ''."\n"; $result.='

- '.&mt('Grade Current Resource').' -

+ '.&mt('Select individual students to grade').' +'.&selectfield(1).' + + + + -
+ + '; + $result .= &show_grading_menu_form($symb); + return $result; +} + +sub selectfield { + my ($full)=@_; + my $result='
'.&mt('Sections').' -   '; - $result.=' + '.&Apache::lonstatistics::SectionSelect('section','multiple',5).'
@@ -8794,63 +8678,25 @@ GRADINGMENUJS '.&mt('Access Status').' - '.&Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,5,undef,'mult').' -
- + '.&Apache::lonhtmlcommon::StatusOptions(undef,undef,5,undef,'mult').' + '; + if ($full) { + $result.='
'.&mt('Submission Status').' - - -
- -
- -
-
-
- -
-
- -
-
- -
-
- - -

- '.&mt('Grade Complete Folder for One Student').' -

-
-
- -
-
- -
-
- '; - $result .= &show_grading_menu_form($symb); + '. + &Apache::loncommon::select_form('all','submitonly', + (&Apache::lonlocal::texthash( + 'yes' => 'with submissions', + 'queued' => 'in grading queue', + 'graded' => 'with ungraded submissions', + 'incorrect' => 'with incorrect submissions', + 'all' => 'with any status'), + 'select_form_order' => ['yes','queued','graded','incorrect','all'])). + ''; + } + $result.='

'; return $result; } @@ -8942,14 +8788,11 @@ sub process_clicker { my ($symb)=&get_symb($r); if (!$symb) {return '';} my $result=&checkforfile_js(); - $env{'form.probTitle'} = &Apache::lonnet::gettitle($symb); -# my ($table) = &showResourceInfo($symb,$env{'form.probTitle'}); -# $result.=$table; $result.='
'."\n"; $result.=' '.&mt('Specify a file containing the class scores for current resource.'). @@ -4013,7 +3960,6 @@ sub upcsvScores_form {
- $upfile_select
@@ -4939,8 +4885,7 @@ the homework problem. sub defaultFormData { my ($symb)=@_; return ''."\n". - ''."\n". - ''."\n"; + ''; } @@ -5245,6 +5190,52 @@ sub scantron_selectphase { $ssi_error = 0; + if (&Apache::lonnet::allowed('usc',$env{'request.role.domain'}) || + &Apache::lonnet::allowed('usc',$env{'request.course.id'})) { + + # Chunk of form to prompt for a scantron file upload. + + $r->print(' +
+ '.&Apache::loncommon::start_data_table('LC_scantron_action').' + '.&Apache::loncommon::start_data_table_header_row().' +
+  '.&mt('Specify a bubblesheet data file to upload.').' + +'); + my $default_form_data=&defaultFormData(&get_symb($r,1)); + my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'}; + $r->print(&Apache::lonhtmlcommon::scripttag(' + function checkUpload(formname) { + if (formname.upfile.value == "") { + alert("'.&mt('Please use the browse button to select a file from your local directory.').'"); + return false; + } + formname.submit(); + }')); + $r->print(' + + '.$default_form_data.' + + + + '.&mt('File to upload: [_1]','').' +
+ + +'); + + $r->print(' +
-  '.&mt('Specify a bubblesheet data file to upload.').' - -'); - my $default_form_data=&defaultFormData(&get_symb($r,1)); - my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'}; - $r->print(&Apache::lonhtmlcommon::scripttag(' - function checkUpload(formname) { - if (formname.upfile.value == "") { - alert("'.&mt('Please use the browse button to select a file from your local directory.').'"); - return false; - } - formname.submit(); - }')); - $r->print(' -
- '.$default_form_data.' - - - - '.&mt('File to upload: [_1]','').' -
- -
-'); - - $r->print(' -
'."\n"; $result.=''."\n"; - $result.='
'."\n"; $result.=' '.&mt('Specify a file containing the clicker information for this resource.'). '
'."\n"; + $result.='
'."\n"; # Attempt to restore parameters from last session, set defaults if not present my %Saveable_Parameters=&clicker_grading_parameters(); &Apache::loncommon::restore_course_settings('grades_clicker', @@ -9022,7 +8865,6 @@ ENDUPFORM
-
@@ -9054,7 +8896,6 @@ sub process_clicker_file { &Apache::loncommon::store_course_settings('grades_clicker', \%Saveable_Parameters); my $result=''; -# my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); if (($env{'form.gradingmechanism'} eq 'specific') && ($env{'form.specificid'}!~/\w/)) { $result.=''.&mt('You need to specify a clicker ID for the correct answer').''; return $result.&show_grading_menu_form($symb); @@ -9131,7 +8972,6 @@ sub process_clicker_file { - @@ -9294,7 +9134,6 @@ sub assign_clicker_grades { my $part=$$partlist[0]; # Start screen output my $result=''; -# my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); my $heading=&mt('Assigning grades based on clicker file'); $result.=(<',''). ''; } +sub startpage{ + my ($r,$crumbs) = @_; + + unshift(@$crumbs, {href=>"/adm/grades",text=>"Grading"}); + $r->print(&Apache::loncommon::start_page('Grading',undef, + {'bread_crumbs' => $crumbs})); +} sub handler { my $request=$_[0]; @@ -9419,40 +9265,17 @@ sub handler { if ($#commands > 0) { &Apache::lonnet::logthis("grades got multiple commands ".join(':',@commands)); } - + $ssi_error = 0; - my $brcrum = [{href=>"/adm/grades",text=>"Grading"}]; - $request->print(&Apache::loncommon::start_page('Grading',undef, - {'bread_crumbs' => $brcrum})); if ($symb eq '' && $command eq '') { - if ($env{'user.adv'}) { - if (($env{'form.codeone'}) && ($env{'form.codetwo'}) && - ($env{'form.codethree'})) { - my $token=$env{'form.codeone'}.'*'.$env{'form.codetwo'}.'*'. - $env{'form.codethree'}; - my ($tsymb,$tuname,$tudom,$tcrsid)= - &Apache::lonnet::checkin($token); - if ($tsymb) { - my ($map,$id,$url)=&Apache::lonnet::decode_symb($tsymb); - if (&Apache::lonnet::allowed('mgr',$tcrsid)) { - $request->print(&ssi_with_retries('/res/'.$url, $ssi_retries, - ('grade_username' => $tuname, - 'grade_domain' => $tudom, - 'grade_courseid' => $tcrsid, - 'grade_symb' => $tsymb))); - } else { - $request->print('

Not authorized: '.$token.'

'); - } - } else { - $request->print('

Not a valid DocID: '.$token.'

'); - } - } else { - $request->print(&Apache::lonxml::tokeninputfield()); - } - } +# +# Not called from a resource +# + } else { &init_perm(); if ($command eq 'submission' && $perm{'vgr'}) { + &startpage($request, [{href=>"", text=>"Student Submissions"}]); ($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0)); } elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) { &pickStudentPage($request); @@ -9463,21 +9286,24 @@ sub handler { } elsif ($command eq 'processGroup' && $perm{'vgr'}) { &processGroup($request); } elsif ($command eq 'gradingmenu' && $perm{'vgr'}) { + &startpage($request); $request->print(&grading_menu($request)); } elsif ($command eq 'individual' && $perm{'vgr'}) { - $request->print(&individual($request)); + $request->print(&submit_options($request)); } elsif ($command eq 'ungraded' && $perm{'vgr'}) { $request->print(&submit_options($request)); } elsif ($command eq 'table' && $perm{'vgr'}) { - $request->print(&submit_options($request)); + $request->print(&submit_options_table($request)); } elsif ($command eq 'all_for_one' && $perm{'vgr'}) { - $request->print(&submit_options($request)); + $request->print(&submit_options_sequence($request)); } elsif ($command eq 'viewgrades' && $perm{'vgr'}) { $request->print(&viewgrades($request)); } elsif ($command eq 'handgrade' && $perm{'mgr'}) { $request->print(&processHandGrade($request)); } elsif ($command eq 'editgrades' && $perm{'mgr'}) { $request->print(&editgrades($request)); + } elsif ($command eq 'initialverifyreceipt' && $perm{'vgr'}) { + $request->print(&initialverifyreceipt($request)); } elsif ($command eq 'verify' && $perm{'vgr'}) { $request->print(&verifyreceipt($request)); } elsif ($command eq 'processclicker' && $perm{'mgr'}) {