--- loncom/homework/grades.pm 2009/12/15 18:26:18 1.584 +++ loncom/homework/grades.pm 2010/04/12 22:19:53 1.613 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.584 2009/12/15 18:26:18 bisitz Exp $ +# $Id: grades.pm,v 1.613 2010/04/12 22:19:53 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -96,6 +96,9 @@ sub ssi_print_error { # # --- Retrieve the parts from the metadata file.--- +# Returns an array of everything that the resources stores away +# + sub getpartlist { my ($symb,$errorref) = @_; @@ -120,21 +123,6 @@ sub getpartlist { return @stores; } -# --- Get the symbolic name of a problem and the url -sub get_symb { - 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))); - if ($symb eq '') { - if (!$silent) { - $request->print("Unable to handle ambiguous references:$url:."); - return (); - } - } - &Apache::lonenc::check_decrypt(\$symb); - return ($symb); -} - #--- Format fullname, username:domain if different for display #--- Use anywhere where the student names are listed sub nameUserString { @@ -160,6 +148,10 @@ sub response_type { return; } my $res = $navmap->getBySymb($symb); + unless (ref($res)) { + $$response_error = 1; + return; + } my $partlist = $res->parts(); my %vPart = map { $_ => 1 } (&Apache::loncommon::get_env_multiple('form.vPart')); @@ -203,55 +195,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(); @@ -421,7 +364,7 @@ sub cleanRecord { return '
'. ''.$toprow.''. ''. - $grayFont.$bottomrow.''.'
'.&mt('Answer').'
'.$grayFont.&mt('Option ID').'
'; + $bottomrow.''.''; } elsif ($response eq 'essay') { if (! exists ($env{'form.'.$symb})) { my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade', @@ -483,8 +426,7 @@ sub cleanRecord { #-- A couple of common js functions sub commonJSfunctions { my $request = shift; - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< 1) { @@ -512,7 +454,6 @@ sub commonJSfunctions { return selectOne.value; } } - COMMONJSFUNCTIONS } @@ -667,17 +608,15 @@ sub student_gradeStatus { sub jscriptNform { my ($symb) = @_; my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); - my $jscript=''."\n"; + "\n"); $jscript.= '
'."\n". ''."\n". - ''."\n". - ''."\n". ''."\n". ''."\n". ''."\n". @@ -730,7 +669,7 @@ sub most_similar { # ignore empty submissions (occuring when only files are sent) - unless ($uessay=~/\w+/) { return ''; } + unless ($uessay=~/\w+/s) { return ''; } # these will be returned. Do not care if not at least 50 percent similar my $limit=0.6; @@ -767,22 +706,31 @@ sub most_similar { #------------------------------------ Receipt Verification Routines # + +sub initialverifyreceipt { + my ($request,$symb) = @_; + &commonJSfunctions($request); + return ''. + &Apache::lonnet::recprefix($env{'request.course.id'}). + '-'. + ''."\n". + ''. + "
\n"; +} + #--- Check whether a receipt number is valid.--- sub verifyreceipt { - my $request = shift; + my ($request,$symb) = @_; my $courseid = $env{'request.course.id'}; my $receipt = &Apache::lonnet::recprefix($courseid).'-'. $env{'form.receipt'}; $receipt =~ s/[^\-\d]//g; - my ($symb) = &get_symb($request); 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'); @@ -860,30 +808,28 @@ sub verifyreceipt { #--- Also called directly when one clicks on the subm button # on the problem page. sub listStudents { - my ($request) = shift; + my ($request,$symb) = @_; - my ($symb) = &get_symb($request); 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'; - $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 + ); my %lt = &Apache::lonlocal::texthash ( 'multiple' => 'Please select a student or group of students before clicking on the Next button.', 'single' => 'Please select the student before clicking on the Next button.', ); - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< LISTJAVASCRIPT &commonJSfunctions($request); @@ -921,7 +866,7 @@ LISTJAVASCRIPT my $checkhdgrade = ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1 ) ? 'checked="checked"' : ''; my $checklastsub = $checkhdgrade eq '' ? 'checked="checked"' : ''; my $gradeTable='
'. - "\n".$table; + "\n"; $gradeTable .= &Apache::lonhtmlcommon::start_pick_box(); $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Problem Text')) @@ -944,10 +889,18 @@ LISTJAVASCRIPT my $saveStatus = $stu_status eq '' ? 'Active' : $stu_status; $env{'form.Status'} = $saveStatus; $submission_options.= - ''."\n". - ''."\n". - ''."\n". - ''; + ''. + ''."\n". + ''. + ''."\n". + ''. + ''."\n". + ''. + ''; $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Submissions')) .$submission_options .&Apache::lonhtmlcommon::row_closure(); @@ -966,8 +919,6 @@ LISTJAVASCRIPT ''."\n". '
'."\n". '
'."\n". - ''."\n". - ''."\n". ''."\n". ''."\n"; @@ -993,8 +944,8 @@ LISTJAVASCRIPT # checkall buttons $gradeTable.=&check_script('gradesub', 'stuinfo'); $gradeTable.='
'."\n"; + 'onclick="javascript:checkSelect(this.form.stuinfo);" '."\n". + 'value="'.&mt('Next').' →" />
'."\n"; $gradeTable.=&check_buttons(); my ($classlist, undef, $fullname) = &getclasslist($getsec,'1',$getgroup); $gradeTable.= &Apache::loncommon::start_data_table(). @@ -1111,9 +1062,9 @@ LISTJAVASCRIPT } $gradeTable.=&Apache::loncommon::end_data_table()."\n". - '
'."\n"; + ''."\n"; if ($ctr == 0) { my $num_students=(scalar(keys(%$fullname))); if ($num_students eq 0) { @@ -1140,7 +1091,7 @@ LISTJAVASCRIPT sub check_script { my ($form, $type)=@_; - my $chkallscript=''."\n"; +'."\n"); return $chkallscript; } @@ -1210,8 +1161,7 @@ sub processGroup { sub sub_page_js { my $request = shift; my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = '); - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< SUBJAVASCRIPT } @@ -1389,8 +1338,7 @@ sub sub_page_kw_js { my $iconpath = $request->dir_config('lonIconsURL'); &commonJSfunctions($request); - my $inner_js_msg_central=< + my $inner_js_msg_central= &Apache::lonhtmlcommon::scripttag(< INNERJS - my $inner_js_highlight_central=< + my $inner_js_highlight_central= &Apache::lonhtmlcommon::scripttag(< INNERJS my $start_page_msg_central = @@ -1466,8 +1411,7 @@ INNERJS my $docopen=&Apache::lonhtmlcommon::javascript_docopen(); $docopen=~s/^document\.//; my $alertmsg = &mt('Please select a word or group of words from document and then click this link.'); - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(<"); pDoc.write("<\\/td><\\/tr><\\/table> "); - pDoc.write("  "); - pDoc.write("

"); + pDoc.write("  "); + pDoc.write("

"); pDoc.write("<\\/form>"); pDoc.write('$end_page_msg_central'); pDoc.close(); @@ -1691,14 +1635,13 @@ INNERJS var hDoc = hwdWin.document; hDoc.write("<\\/table>"); hDoc.write("<\\/td><\\/tr><\\/table> "); - hDoc.write("  "); - hDoc.write("

"); + hDoc.write("  "); + hDoc.write("

"); hDoc.write("<\\/form>"); hDoc.write('$end_page_highlight_central'); hDoc.close(); } - SUBJAVASCRIPT } @@ -1711,6 +1654,25 @@ sub get_increment { return $increment; } +sub gradeBox_start { + return ( + &Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row() + .''.&mt('Part').'' + .''.&mt('Points').'' + .' ' + .''.&mt('Assign Grade').'' + .''.&mt('Weight').'' + .''.&mt('Grade Status').'' + .&Apache::loncommon::end_data_table_header_row() + ); +} + +sub gradeBox_end { + return ( + &Apache::loncommon::end_data_table() + ); +} #--- displays the grading box, used in essay type problem and grading by page/sequence sub gradeBox { my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_; @@ -1730,7 +1692,7 @@ sub gradeBox { if ($last_resets{$partid}) { $aggtries = &get_num_tries($record,$last_resets{$partid},$partid); } - $result.=''; + $result.=&Apache::loncommon::start_data_table_row(); my $ctr = 0; my $thisweight = 0; my $increment = &get_increment(); @@ -1738,7 +1700,7 @@ sub gradeBox { my $radio.='
'."\n"; # display radio buttons in a nice table 10 across while ($thisweight<=$wgt) { $radio.= '\n"; $radio.=(($ctr+1)%10 == 0 ? '' : ''); @@ -1749,13 +1711,13 @@ sub gradeBox { my $line.=''."\n"; $line.=''."\n"; + $line.='',$display_part,$radio,$line); $result .= - ''; - $result.='
/'.$wgt.' '.$wgtmsg. ($$record{'resource.'.$partid.'.solved'} eq 'correct_by_student' ? ' '.$checkIcon : ''). - ' '.&mt('Grade Status').':'."\n"; - $line.=''."\n"; - #&mt('Part:[_1]Points:[_2]or[_3]'.&mt('Part:').''.$display_part.''.&mt('Points:').''.$radio.''.&mt('or').''.$line.'
'."\n"; + ''.$display_part.''.$radio.''.&mt('or').''.$line.''; + $result.=&Apache::loncommon::end_data_table_row(); $result.=''."\n". ''."\n". ''. - &mt('View of the problem'). - '
'. - $rendered. - '
'; + '
' + .'

'.&mt('View of the problem').'

' + .$rendered + .'
'; $companswer= - '
'. - &mt('Correct answer'). - '
'. - $companswer. - '
'; + '
' + .'

'.&mt('Correct answer').'

' + .$companswer + .'
'; my $result; if ($mode eq 'both') { - $result=$rendered.$companswer; + $result=$rendered.$companswer; } elsif ($mode eq 'text') { - $result=$rendered; + $result=$rendered; } elsif ($mode eq 'answer') { - $result=$companswer; + $result=$companswer; } - $result='
'.$result.'
'; return $result; } @@ -1925,12 +1883,13 @@ sub build_section_inputs { # --------------------------- show submissions of a student, option to grade sub submission { - my ($request,$counter,$total) = @_; + my ($request,$counter,$total,$symb) = @_; my ($uname,$udom) = ($env{'form.student'},$env{'form.userdom'}); $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 $probtitle=&Apache::lonnet::gettitle($symb); if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; } if (!&canview($usec)) { @@ -1954,13 +1913,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. @@ -1991,17 +1947,15 @@ 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'}; my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); $request->print('
'."\n". ''."\n". - ''."\n". ''."\n". ''."\n". - ''."\n". ''."\n". ''."\n". ''."\n". @@ -2047,7 +2001,7 @@ sub submission { $request->print(<Keyword Options:  List    -Paste Selection to List    Highlight Attribute

KEYWORDS @@ -2063,12 +2017,31 @@ KEYWORDS } # This is where output for one specific student would start - my $add_class = ($counter%2) ? 'LC_grade_show_user_odd_row' : ''; - $request->print("\n\n". - '
'. - '
'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).'
'. - '
'."\n"); + my $add_class = ($counter%2) ? ' LC_grade_show_user_odd_row' : ''; + $request->print( + "\n\n" + .'
' + .'

'.&nameUserString(undef,$env{'form.fullname'},$uname,$udom).'

' + ."\n" + ); + + # Show additional functions if allowed + if ($perm{'vgr'}) { + $request->print( + &Apache::loncommon::track_student_link( + &mt('View recent activity'), + $uname,$udom,'check') + .' ' + ); + } + if ($perm{'opa'}) { + $request->print( + &Apache::loncommon::pprmlink( + &mt('Set/Change parameters'), + $uname,$udom,$symb,'check')); + } + # Show Problem if ($env{'form.vProb'} eq 'all' or $env{'form.vAns'} eq 'all') { my $mode; if ($env{'form.vProb'} eq 'all' && $env{'form.vAns'} eq 'all') { @@ -2092,20 +2065,17 @@ KEYWORDS # Display student info $request->print(($counter == 0 ? '' : '
')); - my $result='
'; - - $result.='
'; - $result.= &mt('Submissions'); + + my $result='
' + .'

'.&mt('Submissions').'

'; $result.=''."\n"; + '" value="'.$env{'form.fullname'}.'" />'."\n"; if ($env{'form.handgrade'} eq 'no') { - $result.=''. - &mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)."\n"; - + $result.='

' + .&mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon) + ."

\n"; } - - # If any part of the problem is an essay-response (handgraded), then check for collaborators my $fullname; my $col_fullnames = []; @@ -2116,9 +2086,9 @@ KEYWORDS $result.=$sub_result; } $request->print($result."\n"); - $request->print('
'."\n"); + # print student answer/submission - # Options are (1) Handgaded submission only + # Options are (1) Handgraded submission only # (2) Last submission, includes submission that is not handgraded # (for multi-response type part) # (3) Last submission plus the parts info @@ -2128,10 +2098,12 @@ KEYWORDS my $lastsubonly; - if ($$timestamp eq '') { - $lastsubonly.='
'.$$string[0].'
'; - } else { - $lastsubonly = '
Date Submitted: '.$$timestamp."\n"; + if ($$timestamp eq '') { + $lastsubonly.='
'.$$string[0].'
'; + } else { + $lastsubonly = + '
' + .''.&mt('Date Submitted:').' '.$$timestamp."\n"; my %seenparts; my @part_response_id = &flatten_responseType($responseType); @@ -2158,7 +2130,7 @@ KEYWORDS $lastsubonly.="\n".'
'. ''.&mt('Part: [_1]',$display_part).''. ' '. - '('.&mt('Part ID: [_1]',$respid).')'. + '('.&mt('Part ID: [_1]',$respid).')'. '   '. ''.&mt('Nothing submitted - no attempts.').'

'; next; @@ -2166,7 +2138,7 @@ KEYWORDS foreach my $submission (@$string) { my ($partid,$respid) = ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/); if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; } - my ($ressub,$subval) = split(/:/,$submission,2); + my ($ressub,$hide,$subval) = split(/:/,$submission,3); # Similarity check my $similar=''; if($env{'form.checkPlag'}){ @@ -2178,16 +2150,21 @@ KEYWORDS &Apache::lonnet::coursedescription($ocrsid, {'one_time' => 1}); - $similar="

". - &mt('Essay is [_1]% similar to an essay by [_2] in course [_3] (course id [_4]:[_5])', - $osim, - &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')', - $old_course_desc{'description'}, - $old_course_desc{'num'}, - $old_course_desc{'domain'}). - '

'. - &keywords_highlight($oessay). - '

'; + if ($hide) { + $similar='
'.&mt("Essay was found to be similar to another essay submitted for this assignment.").'
'. + &mt('As the current submission is for an anonymous survey, no other details are available.').'

'; + } else { + $similar="

". + &mt('Essay is [_1]% similar to an essay by [_2] in course [_3] (course id [_4]:[_5])', + $osim, + &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')', + $old_course_desc{'description'}, + $old_course_desc{'num'}, + $old_course_desc{'domain'}). + '

'. + &keywords_highlight($oessay). + '

'; + } } } my $order=&get_order($partid,$respid,$symb,$uname,$udom); @@ -2199,31 +2176,39 @@ KEYWORDS ''.&mt('Part: [_1]',$display_part).''. ' '. '('.&mt('Part ID: [_1]',$respid).')'. - '   '; + '   '; my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); if (@$files) { - $lastsubonly.='
'.&mt('Like all files provided by users, this file may contain viruses').'
'; - my $file_counter = 0; - foreach my $file (@$files) { - $file_counter++; - &Apache::lonnet::allowuploaded('/adm/grades',$file); - $lastsubonly.='
'.$file.''; - } + if ($hide) { + $lastsubonly.='
'.&mt('[quant,_1,file] uploaded to this anonymous survey',scalar(@{$files})); + } else { + $lastsubonly.='
'.&mt('Like all files provided by users, this file may contain viruses').'
'; + foreach my $file (@$files) { + &Apache::lonnet::allowuploaded('/adm/grades',$file); + $lastsubonly.='
'.$file.''; + } + } $lastsubonly.='
'; } - $lastsubonly.=''.&mt('Submitted Answer:').' '. - &cleanRecord($subval,$responsetype,$symb,$partid, - $respid,\%record,$order,undef,$uname,$udom); + if ($hide) { + $lastsubonly.=''.&mt('Anonymous Survey').''; + } else { + $lastsubonly.=''.&mt('Submitted Answer:').' '. + &cleanRecord($subval,$responsetype,$symb,$partid, + $respid,\%record,$order,undef,$uname,$udom); + } if ($similar) {$lastsubonly.="

$similar\n";} $lastsubonly.='
'; } } } - $lastsubonly.='
'."\n"; + $lastsubonly.='
'."\n"; # End: LC_grade_submissions_body } $request->print($lastsubonly); } elsif ($env{'form.lastSub'} eq 'datesub') { - my (undef,$responseType,undef,$parts) = &showResourceInfo($symb); +# my (undef,$responseType,undef,$parts) = &showResourceInfo($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, @@ -2237,7 +2222,7 @@ KEYWORDS # return if view submission with no grading option if ($env{'form.showgrading'} eq '' || (!&canmodify($usec))) { my $toGrade.='  '."\n" if (&canmodify($usec)); $toGrade.='
'."\n"; if (($env{'form.command'} eq 'submission') || @@ -2281,11 +2266,11 @@ KEYWORDS my @partlist; my @gradePartRespid; my @part_response_id = &flatten_responseType($responseType); - $request->print('
'. - - '
'. - &mt('Assign Grades').'
'. - '
'); + $request->print( + '
' + .'

'.&mt('Assign Grades').'

' + ); + $request->print(&gradeBox_start()); foreach my $part_response_id (@part_response_id) { my ($partid,$respid) = @{ $part_response_id }; my $part_resp = join('_',@{ $part_response_id }); @@ -2297,19 +2282,10 @@ KEYWORDS push(@gradePartRespid,$partid.'.'.$respid); $request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record)); } - $request->print('
'); + $request->print(&gradeBox_end()); #
+ $request->print('
'); $request->print(''); $result=''."\n"; + my $endform='

'."\n"; $endform.='  '."\n"; my $ntstu ='  '; - $endform.=&mt('(Next and Previous (student) do not save the scores.)')."\n" ; + 'onclick="javascript:checksubmit(this.form,\'Next\');" target="_self" />  '; + $endform.=''. + &mt('(Next and Previous (student) do not save the scores.)'). + ''."\n" ; $endform.=""; $endform.='
'; @@ -2416,7 +2393,7 @@ sub check_collaborators { #--- Retrieve the last submission for all the parts sub get_last_submission { my ($returnhash)=@_; - my (@string,$timestamp); + my (@string,$timestamp,%lasthidden); if ($$returnhash{'version'}) { my %lasthash=(); my ($version); @@ -2428,13 +2405,39 @@ sub get_last_submission { &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'}); } } + my %typeparts; + my $showsurv = + &Apache::lonnet::allowed('vas',$env{'request.course.id'}); + foreach my $key (sort(keys(%lasthash))) { + if ($key =~ /\.type$/) { + if (($lasthash{$key} eq 'anonsurvey') || + ($lasthash{$key} eq 'anonsurveycred')) { + my ($ign,@parts) = split(/\./,$key); + pop(@parts); + unless ($showsurv) { + my $id = join(',',@parts); + $typeparts{$ign.'.'.$id} = $lasthash{$key}; + } + delete($lasthash{$key}); + } + } + } + my @hidden = keys(%typeparts); foreach my $key (keys(%lasthash)) { next if ($key !~ /\.submission$/); - + my $hide; + if (@hidden) { + foreach my $id (@hidden) { + if ($key =~ /^\Q$id\E/) { + $hide = 1; + last; + } + } + } my ($partid,$foo) = split(/submission$/,$key); my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ? 'Draft Copy ' : ''; - push(@string, join(':', $key, $draft.$lasthash{$key})); + push(@string, join(':', $key, $hide, $draft.$lasthash{$key})); } } if (!@string) { @@ -2459,8 +2462,7 @@ sub keywords_highlight { #--- Called from submission routine sub processHandGrade { - my ($request) = shift; - my $symb = &get_symb($request); + my ($request,$symb) = @_; my (undef,undef,$url) = &Apache::lonnet::decode_symb($symb); my $button = $env{'form.gradeOpt'}; my $ngrade = $env{'form.NCT'}; @@ -2500,7 +2502,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, @@ -2528,7 +2530,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); @@ -2601,7 +2603,7 @@ sub processHandGrade { # Go directly to grade student - from submission or link from chart page if ($button eq 'Grade Student') { - (undef,undef,$env{'form.handgrade'},undef,undef) = &showResourceInfo($symb); +# (undef,undef,$env{'form.handgrade'},undef,undef) = &showResourceInfo($symb); my $processUser = $env{'form.unamedom'.$env{'form.studentNo'}}; ($env{'form.student'},$env{'form.userdom'}) = split(/:/,$processUser); $env{'form.fullname'} = $$fullname{$processUser}; @@ -2628,6 +2630,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); } @@ -2638,6 +2641,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); @@ -3095,8 +3099,7 @@ sub viewgrades_js { my ($request) = shift; my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = '); - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< VIEWJAVASCRIPT } #--- show scores for a section or whole class w/ option to change/update a score sub viewgrades { - my ($request) = shift; + my ($request,$symb) = @_; &viewgrades_js($request); - my ($symb) = &get_symb($request); #need to make sure we have the correct data for later EXT calls, #thus invalidate the cache &Apache::lonnet::devalidatecourseresdata( @@ -3275,7 +3276,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); @@ -3286,9 +3286,7 @@ sub viewgrades { ''."\n". ''."\n". &build_section_inputs(). - ''."\n". ''."\n". - ''."\n"; my ($common_header,$specific_header); if ($env{'form.section'} eq 'all') { @@ -3335,11 +3333,11 @@ sub viewgrades { } $radio.=''; my $line = ' /'. $weight{$partid}.' '.&mt('(problem weight)').''."\n"; $line.= ''.&mt('Grade Status').':'; $result.=''; + 'onclick="javascript:resetEntry('.$ctsparts.');" />'; #table listing all the students in a section/class #header of table @@ -3424,7 +3422,7 @@ sub viewgrades { $result.=&Apache::loncommon::end_data_table(); $result.=''."\n"; $result.=''."\n"; + 'onclick="javascript:submit();" target="_self" />'."\n"; if (scalar(%$fullname) eq 0) { my $colspan=3+scalar(@parts); my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section')); @@ -3476,7 +3474,7 @@ sub viewstudentgrade { 'GD_'.$student.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n"; $result.=''."\n"; } elsif ($type eq 'solved') { my ($status,$foo)=split(/_/,$score,2); @@ -3485,7 +3483,7 @@ sub viewstudentgrade { $part.'_solved_s" value="'.$status.'" />'."\n"; $result.='  + @@ -3855,14 +3852,10 @@ to this page if the data selected is ins - -
- ENDPICK + $request->print(&Apache::lonhtmlcommon::scripttag($javascript)); return ''; } @@ -3900,15 +3893,14 @@ sub csvuploadmap_footer { -
+
ENDPICK } sub checkforfile_js { my $alertmsg = &mt('Please use the browse button to select a file from your local directory.'); - my $result =< + my $result = &Apache::lonhtmlcommon::scripttag(< CSVFORMJS return $result; } sub upcsvScores_form { - my ($request) = shift; - my ($symb)=&get_symb($request); + my ($request,$symb) = @_; 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.=''. @@ -4485,11 +4463,13 @@ sub displayPage { } if (&canmodify($usec)) { + $studentTable.=&gradeBox_start(); foreach my $partid (@{$parts}) { $studentTable.=&gradeBox($request,$symbx,$uname,$udom,$question,$partid,\%record); $studentTable.=''."\n"; $question++; } + $studentTable.=&gradeBox_end(); $prob++; } $studentTable.=''; @@ -4498,10 +4478,11 @@ sub displayPage { $curRes = $iterator->next(); } - $studentTable.='
'."\n"; $result.=' '.&mt('Specify a file containing the class scores for current resource.'). @@ -3942,10 +3929,8 @@ sub upcsvScores_form {
- - $upfile_select -
+
ENDUPFORM @@ -3959,8 +3944,7 @@ ENDUPFORM sub csvuploadmap { - my ($request)= @_; - my ($symb)=&get_symb($request); + my ($request,$symb)= @_; if (!$symb) {return '';} my $datatoken; @@ -4007,8 +3991,7 @@ sub csvuploadmap { } sub csvuploadoptions { - my ($request)= @_; - my ($symb)=&get_symb($request); + my ($request,$symb)= @_; my $checked=(($env{'form.noFirstLine'})?'1':'0'); my $ignore=&mt('Ignore First Line'); $request->print(<print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< LISTJAVASCRIPT &commonJSfunctions($request); - my ($symb) = &get_symb($request); + 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'}; @@ -4262,13 +4242,12 @@ LISTJAVASCRIPT my $stu_status = join(':',&Apache::loncommon::get_env_multiple('form.Status')); $result.=''."\n". ''."\n". - ''."\n". - ''."
\n"; + ''."
\n"; $result.=' '.&mt('Use CODE').':
'."\n"; $result.=' 
'."\n"; + 'onclick="javascript:checkPickOne(this.form);" value="'.&mt('Next').' →" />
'."\n"; $request->print($result); @@ -4307,7 +4286,7 @@ LISTJAVASCRIPT } $studentTable.=&Apache::loncommon::end_data_table()."\n"; $studentTable.=''."\n"; + 'onclick="javascript:checkPickOne(this.form);" value="'.&mt('Next').' →" />'."\n"; $studentTable.=&show_grading_menu_form($symb); $request->print($studentTable); @@ -4346,9 +4325,7 @@ sub getSymbMap { # #--- Displays a page/sequence w/wo problems, w/wo submissions sub displayPage { - my ($request) = shift; - - my ($symb) = &get_symb($request); + my ($request,$symb) = @_; 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'}; @@ -4404,8 +4381,7 @@ sub displayPage { ''."\n". ''."\n". ''."\n". - ''."\n". - ''."\n"; + ''."\n"; if (defined($env{'form.CODE'})) { $studentTable.= @@ -4414,7 +4390,9 @@ sub displayPage { my $checkIcon = ''.&mt('Check Mark').
 	''; - $studentTable.=' '.&mt('Note: Problems graded correct by the computer are marked with a [_1] symbol.',$checkIcon)."\n". + $studentTable.=' '. + &mt('Problems graded correct by the computer are marked with a [_1] symbol.',$checkIcon). + ''."\n". &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). '
 Prob. 
'."\n". - ''. - ''."\n"; + $studentTable.= + '
'."\n". + ''. + ''."\n"; $studentTable.=&show_grading_menu_form($symb); $request->print($studentTable); @@ -4547,16 +4528,20 @@ sub displaySubByDates { my @versionKeys = split(/\:/,$$record{$version.':keys'}); my @displaySub = (); foreach my $partid (@{$parts}) { + my $hidden; + if (($$record{$version.':resource.'.$partid.'.type'} eq 'anonsurvey') || + ($$record{$version.':resource.'.$partid.'.type'} eq 'anonsurveycred')) { + $hidden = 1; + } my @matchKey = ($isTask ? sort(grep /^resource\.\d+\.\Q$partid\E\.award$/,@versionKeys) : sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys)); - # next if ($$record{"$version:resource.$partid.solved"} eq ''); my $display_part=&get_display_part($partid,$symb); foreach my $matchKey (@matchKey) { if (exists($$record{$version.':'.$matchKey}) && $$record{$version.':'.$matchKey} ne '') { - + my ($responseId)= ($isTask ? ($matchKey=~ /^resource\.(.*?)\.\Q$partid\E\.award$/) : ($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/)); $displaySub[0].='' .' '; - if ($$record{"$where.$partid.tries"} eq '') { - $displaySub[0].=&mt('Trial not counted'); - } else { - $displaySub[0].=&mt('Trial: [_1]', + if ($hidden) { + $displaySub[0].= &mt('Anonymous Survey').''; + } else { + if ($$record{"$where.$partid.tries"} eq '') { + $displaySub[0].=&mt('Trial not counted'); + } else { + $displaySub[0].=&mt('Trial: [_1]', $$record{"$where.$partid.tries"}); - } - my $responseType=($isTask ? 'Task' + } + my $responseType=($isTask ? 'Task' : $responseType->{$partid}->{$responseId}); - if (!exists($orders{$partid})) { $orders{$partid}={}; } - if (!exists($orders{$partid}->{$responseId})) { - $orders{$partid}->{$responseId}= - &get_order($partid,$responseId,$symb,$uname,$udom, - $no_increment); - } - $displaySub[0].=''; # /nobreak - $displaySub[0].='  '. - &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom).'
'; + if (!exists($orders{$partid})) { $orders{$partid}={}; } + if (!exists($orders{$partid}->{$responseId})) { + $orders{$partid}->{$responseId}= + &get_order($partid,$responseId,$symb,$uname,$udom, + $no_increment); + } + $displaySub[0].=''; # /nobreak + $displaySub[0].='  '. + &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom).'
'; + } } } if (exists($$record{"$where.$partid.checkedin"})) { @@ -4621,7 +4610,7 @@ sub displaySubByDates { } sub updateGradeByPage { - my ($request) = shift; + my ($request,$symb) = @_; my $cdom = $env{"course.$env{'request.course.id'}.domain"}; my $cnum = $env{"course.$env{'request.course.id'}.num"}; @@ -4651,7 +4640,6 @@ sub updateGradeByPage { my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps if (!$map) { $request->print(''.&mt('Unable to grade requested sequence ([_1]).',$resUrl).''); - my ($symb)=&get_symb($request); $request->print(&show_grading_menu_form($symb)); return; } @@ -4856,9 +4844,7 @@ the homework problem. sub defaultFormData { my ($symb)=@_; - return ''."\n". - ''."\n". - ''."\n"; + return ''; } @@ -5144,8 +5130,7 @@ sub scantron_CODEunique { =cut sub scantron_selectphase { - my ($r,$file2grade) = @_; - my ($symb)=&get_symb($r); + my ($r,$file2grade,$symb) = @_; if (!$symb) {return '';} my $map_error; my $sequence_selector=&getSequenceDropDown($symb,\$map_error); @@ -5163,6 +5148,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.').' + + '.&Apache::loncommon::end_data_table_header_row().' + '.&Apache::loncommon::start_data_table_row().' + +'); + my $default_form_data=&defaultFormData($symb); + 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(' + + '.&Apache::loncommon::end_data_table_row().' + '.&Apache::loncommon::end_data_table().' +'); + } + # Chunk of form to prompt for a file to grade and how: $result.= ' @@ -5210,53 +5241,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().' - -  '.&mt('Specify a bubblesheet data file to upload.').' - - '.&Apache::loncommon::end_data_table_header_row().' - '.&Apache::loncommon::start_data_table_row().' - -'); - 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(' - - -
- '.$default_form_data.' - - - - '.&mt('File to upload: [_1]','').' -
- -
-'); - $r->print(' - - '.&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. @@ -6216,8 +6201,7 @@ sub scantron_warning_screen { =cut sub scantron_do_warning { - my ($r)=@_; - my ($symb)=&get_symb($r); + my ($r,$symb)=@_; if (!$symb) {return '';} my $default_form_data=&defaultFormData($symb); $r->print(&scantron_form_start().$default_form_data); @@ -6298,8 +6282,7 @@ SCANTRONFORM =cut sub scantron_validate_file { - my ($r) = @_; - my ($symb)=&get_symb($r); + my ($r,$symb) = @_; if (!$symb) {return '';} my $default_form_data=&defaultFormData($symb); @@ -6926,8 +6909,7 @@ sub scantron_get_correction { $r->print("\n
"); } - $r->print(< + $r->print(&Apache::lonhtmlcommon::scripttag(< ENDSCRIPT my $href="/adm/pickcode?". "form=".&escape("scantronupload"). @@ -7007,8 +6988,7 @@ sub verify_bubbles_checked { my (@ansnums) = @_; my $ansnumstr = join('","',@ansnums); my $warning = &mt("A bubble or 'No bubble' selection has not been made for one or more lines."); - my $output = (< + my $output = &Apache::lonhtmlcommon::scripttag((< ENDSCRIPT return $output; } @@ -7434,6 +7413,7 @@ sub scantron_get_maxbubble { if (ref($nav_error)) { $$nav_error = 1; } + return; } my $map=$navmap->getResourceByUrl($sequence); my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); @@ -7574,10 +7554,9 @@ sub scantron_validate_missingbubbles { sub scantron_process_students { - my ($r) = @_; + my ($r,$symb) = @_; my (undef,undef,$sequence)=&Apache::lonnet::decode_symb($env{'form.selectpage'}); - my ($symb)=&get_symb($r); if (!$symb) { return ''; } @@ -7597,8 +7576,15 @@ sub scantron_process_students { my (%grader_partids_by_symb,%grader_randomlists_by_symb); &graders_resources_pass(\@resources,\%grader_partids_by_symb, \%grader_randomlists_by_symb); + my $resource_error; foreach my $resource (@resources) { - my $ressymb = $resource->symb(); + my $ressymb; + if (ref($resource)) { + $ressymb = $resource->symb(); + } else { + $resource_error = 1; + last; + } my ($analysis,$parts) = &scantron_partids_tograde($resource,$env{'request.course.id'}, $env{'user.name'},$env{'user.domain'},1); @@ -7610,6 +7596,10 @@ sub scantron_process_students { } } } + if ($resource_error) { + $r->print(&navmap_errormsg()); + return ''; + } my ($uname,$udom); my $result= <symb(); + my $ressymb; + if (ref($resource)) { + $ressymb = $resource->symb(); + } else { + $res_error = 1; + last; + } if ((exists($grader_randomlists_by_symb{$ressymb})) || (ref($grader_partids_by_symb{$ressymb}) ne 'ARRAY')) { my ($analysis,$parts) = @@ -7693,6 +7689,12 @@ SCANTRONFORM } } + if ($res_error) { + &scantron_add_delay(\@delayqueue,$line, + 'An error occurred while grading student '.$uname,2); + next; + } + &Apache::lonxml::clear_problem_counter(); &Apache::lonnet::appenv($scan_record); @@ -7854,7 +7856,7 @@ sub grade_student_bubbles { } sub scantron_upload_scantron_data { - my ($r)=@_; + my ($r,$symb)=@_; my $dom = $env{'request.role.domain'}; my $domdesc = &Apache::lonnet::domain($dom,'description'); $r->print(&Apache::loncommon::coursebrowser_javascript($dom)); @@ -7863,11 +7865,10 @@ sub scantron_upload_scantron_data { 'coursename',$dom); my $syllabuslink = ''.&mt('Syllabus').''. (' 'x2).&mt('(shows course personnel)'); - my $default_form_data=&defaultFormData(&get_symb($r,1)); + my $default_form_data=&defaultFormData($symb); my $nofile_alert = &mt('Please use the browse button to select a file from your local directory.'); my $nocourseid_alert = &mt("Please use the 'Select Course' link to open a separate window where you can search for a course to which a file can be uploaded."); - $r->print(' - - +')); + $r->print('

'.&mt('Send scanned bubblesheet data to a course').'

@@ -7916,7 +7917,7 @@ sub scantron_upload_scantron_data { &Apache::lonhtmlcommon::end_pick_box().'
- +
'); return ''; @@ -7924,8 +7925,7 @@ sub scantron_upload_scantron_data { sub scantron_upload_scantron_data_save { - my($r)=@_; - my ($symb)=&get_symb($r,1); + my($r,$symb)=@_; my $doanotherupload= '
'."\n". ''."\n". @@ -7965,7 +7965,7 @@ sub scantron_upload_scantron_data_save { } } if ($symb) { - $r->print(&scantron_selectphase($r,$uploadedfile)); + $r->print(&scantron_selectphase($r,$uploadedfile,$symb)); } else { $r->print($doanotherupload); } @@ -8067,8 +8067,8 @@ sub valid_file { } sub scantron_download_scantron_data { - my ($r)=@_; - my $default_form_data=&defaultFormData(&get_symb($r,1)); + my ($r,$symb)=@_; + my $default_form_data=&defaultFormData($symb); my $cname=$env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; my $file=$env{'form.scantron_selectfile'}; @@ -8078,7 +8078,7 @@ sub scantron_download_scantron_data { '.&mt('The requested file name was invalid.').'

'); - $r->print(&show_grading_menu_form(&get_symb($r,1))); + $r->print(&show_grading_menu_form($symb)); return; } my $orig='/uploaded/'.$cdom.'/'.$cname.'/scantron_orig_'.$file; @@ -8101,13 +8101,12 @@ sub scantron_download_scantron_data { '','').'

'); - $r->print(&show_grading_menu_form(&get_symb($r,1))); + $r->print(&show_grading_menu_form($symb)); return ''; } sub checkscantron_results { - my ($r) = @_; - my ($symb)=&get_symb($r); + my ($r,$symb) = @_; if (!$symb) {return '';} my $grading_menu_button=&show_grading_menu_form($symb); my $cid = $env{'request.course.id'}; @@ -8409,43 +8408,32 @@ sub show_grading_menu_form { my ($symb)=@_; my $result.='
'."\n". ''."\n". - ''."\n". ''."\n". ''."\n". '
'."\n"; 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); + my ($request,$symb) = @_; if (!$symb) {return '';} - my $probTitle = &Apache::lonnet::gettitle($symb); - my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle); - $request->print($table); my %fields = ('symb'=>&Apache::lonenc::check_encrypt($symb), - 'handgrade'=>$hdgrade, - 'probTitle'=>$probTitle, - 'command'=>'submit_options', - 'saveState'=>"", + 'command'=>'individual', 'gradingMenu'=>1, 'showgrading'=>"yes"); - my $url1 = &Apache::lonhtmlcommon::build_url('grades/',\%fields); - + my $url1a = &Apache::lonhtmlcommon::build_url('grades/',\%fields); + + $fields{'command'}='ungraded'; + my $url1b=&Apache::lonhtmlcommon::build_url('grades/',\%fields); + + $fields{'command'}='table'; + my $url1c=&Apache::lonhtmlcommon::build_url('grades/',\%fields); + + $fields{'command'}='all_for_one'; + my $url1d=&Apache::lonhtmlcommon::build_url('grades/',\%fields); + $fields{'command'} = 'csvform'; my $url2 = &Apache::lonhtmlcommon::build_url('grades/',\%fields); @@ -8454,15 +8442,40 @@ 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=>'Course Grading', + my @menu = ({ categorytitle=>'Hand Grading', items =>[ - { linktext => 'Manual Grading/View Submissions', - url => $url1, + { linktext => 'Select individual students to grade', + url => $url1a, permission => 'F', icon => 'edit-find-replace.png', - linktitle => 'Start the process of hand grading submissions.' + linktitle => 'Grade current resource for a selection of students.' + }, + { linktext => 'Grade ungraded submissions.', + url => $url1b, + permission => 'F', + icon => 'edit-find-replace.png', + linktitle => 'Grade all submissions that have not been graded yet.' + }, + + { linktext => 'Grading table', + url => $url1c, + permission => 'F', + icon => 'edit-find-replace.png', + linktitle => 'Grade current resource for all students.' }, + { linktext => 'Grade complete page/sequence/folder for one student', + url => $url1d, + permission => 'F', + icon => 'edit-find-replace.png', + linktitle => 'Grade all resources in current page/sequence/folder for one student.' + }]}, + { categorytitle=>'Automated Grading', + items =>[ + { linktext => 'Upload Scores', url => $url2, permission => 'F', @@ -8475,171 +8488,131 @@ sub grading_menu { icon => 'addClickerInfoFile.png', linktitle => 'Specify a file containing the clicker information for this resource.' }, - { linktext => 'Grade/Manage/Review Bubblesheet Forms', + { linktext => 'Grade/Manage/Review Bubblesheets', url => $url4, 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 .= &Apache::lonhtmlcommon::generate_menu(@menu); + return $Str; +} - $Str .="
\n"; - my $receiptalert = &mt("Please enter a receipt number given by a student in the receipt box."); - $request->print(< - function checkChoice(formname,val,cmdx) { - if (val <= 2) { - var cmd = radioSelection(formname.radioChoice); - var cmdsave = cmd; - } else { - cmd = cmdx; - cmdsave = 'submission'; - } - formname.command.value = cmd; - if (val < 5) formname.submit(); - if (val == 5) { - if (!checkReceiptNo(formname,'notOK')) { - return false; - } else { - formname.submit(); - } - } - } - function checkReceiptNo(formname,nospace) { - var receiptNo = formname.receipt.value; - var checkOpt = false; - if (nospace == "OK" && isNaN(receiptNo)) {checkOpt = true;} - if (nospace == "notOK" && (isNaN(receiptNo) || receiptNo == "")) {checkOpt = true;} - if (checkOpt) { - alert("$receiptalert"); - formname.receipt.value = ""; - formname.receipt.focus(); - return false; - } - return true; - } - -GRADINGMENUJS +sub ungraded { + my ($request)=@_; + &submit_options($request); +} + +sub submit_options_sequence { + my ($request,$symb) = @_; + if (!$symb) {return '';} &commonJSfunctions($request); - return $Str; + my $result; + + $result.='
'."\n". + ''."\n". + ''."\n". + ''."\n"; + + $result.=' +

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

'. + &selectfield(0). + ' +
+ +
+
+ '; + $result .= &show_grading_menu_form($symb); + return $result; +} + +sub submit_options_table { + my ($request,$symb) = @_; + 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); + my ($request,$symb) = @_; 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(< - function checkChoice(formname,val,cmdx) { - if (val <= 2) { - var cmd = radioSelection(formname.radioChoice); - var cmdsave = cmd; - } else { - cmd = cmdx; - cmdsave = 'submission'; - } - formname.command.value = cmd; - formname.saveState.value = "saveCmd="+cmdsave+":saveSec="+pullDownSelection(formname.section)+ - ":saveSub="+pullDownSelection(formname.submitonly)+":saveStatus="+pullDownSelection(formname.Status); - if (val < 5) formname.submit(); - if (val == 5) { - if (!checkReceiptNo(formname,'notOK')) { return false;} - formname.submit(); - } - if (val < 7) formname.submit(); - } - - function checkReceiptNo(formname,nospace) { - var receiptNo = formname.receipt.value; - var checkOpt = false; - if (nospace == "OK" && isNaN(receiptNo)) {checkOpt = true;} - if (nospace == "notOK" && (isNaN(receiptNo) || receiptNo == "")) {checkOpt = true;} - if (checkOpt) { - alert("$receiptalert"); - formname.receipt.value = ""; - formname.receipt.focus(); - return false; - } - return true; - } - -GRADINGMENUJS &commonJSfunctions($request); - my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle); my $result; - my (undef,$sections) = &getclasslist('all','0'); - my $savedState = &savedState(); - my $saveCmd = ($$savedState{'saveCmd'} eq '' ? 'submission' : $$savedState{'saveCmd'}); - my $saveSec = ($$savedState{'saveSec'} eq '' ? 'all' : $$savedState{'saveSec'}); - my $saveSub = ($$savedState{'saveSub'} eq '' ? 'all' : $$savedState{'saveSub'}); - my $saveStatus = ($$savedState{'saveStatus'} eq '' ? 'Active' : $$savedState{'saveStatus'}); - - # Preselect sections - my $selsec=""; - if (ref($sections)) { - foreach my $section (sort(@$sections)) { - $selsec.=''."\n"; - } - } $result.='
'."\n". ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n". ''."\n". ''."\n"; $result.='

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

-
- '.$table.' -
+ '.&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).'
@@ -8653,63 +8626,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; } @@ -8797,18 +8732,14 @@ sub clicker_grading_parameters { } sub process_clicker { - my ($r)=@_; - my ($symb)=&get_symb($r); + my ($r,$symb)=@_; 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.=''."\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', @@ -8838,8 +8769,7 @@ sub process_clicker { ('iclicker' => 'i>clicker', 'interwrite' => 'interwrite PRS')); $symb = &Apache::lonenc::check_encrypt($symb); - $result.=< + $result.= &Apache::lonhtmlcommon::scripttag(< +ENDUPFORM + $result.= < - -
-
-
-
+
+
+
-
+

    -
-
-
- +
+
+
+' ENDUPFORM $result.='
'."\n". '


'."\n"; @@ -8905,15 +8834,13 @@ ENDUPFORM } sub process_clicker_file { - my ($r)=@_; - my ($symb)=&get_symb($r); + my ($r,$symb)=@_; if (!$symb) {return '';} my %Saveable_Parameters=&clicker_grading_parameters(); &Apache::loncommon::store_course_settings('grades_clicker', \%Saveable_Parameters); - - my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); + my $result=''; 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); @@ -8990,8 +8917,6 @@ sub process_clicker_file {
- - @@ -9140,8 +9065,7 @@ sub interwrite_eval { } sub assign_clicker_grades { - my ($r)=@_; - my ($symb)=&get_symb($r); + my ($r,$symb)=@_; if (!$symb) {return '';} # See which part we are saving to my $res_error; @@ -9152,7 +9076,7 @@ sub assign_clicker_grades { # FIXME: This should probably look for the first handgradeable part my $part=$$partlist[0]; # Start screen output - my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); + my $result=''; my $heading=&mt('Assigning grades based on clicker file'); $result.=(<'. &mt('An error occurred retrieving information about resources in the course.').'
'. - &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this grading page..','',''). + &mt('It is recommended that you [_1]re-initialize the course[_2] and then return to this grading page.','',''). ''; } +sub startpage { + my ($r,$symb,$crumbs,$onlyfolderflag,$nodisplayflag) = @_; + unshift(@$crumbs,{href=>"/adm/grades?command=gradingmenu&symb=".&HTML::Entities::encode($symb,'<>&"'),text=>"Grading"}); + $r->print(&Apache::loncommon::start_page('Grading',undef, + {'bread_crumbs' => $crumbs})); + unless ($nodisplayflag) { + $r->print(&Apache::lonhtmlcommon::resource_info_box($symb,$onlyfolderflag)); + } +} + sub handler { my $request=$_[0]; &reset_caches(); @@ -9270,7 +9204,9 @@ sub handler { $request->send_http_header; return '' if $request->header_only; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); - my $symb=&get_symb($request,1); + +# see what command we need to execute + my @commands=&Apache::loncommon::get_env_multiple('form.command'); my $command=$commands[0]; @@ -9278,107 +9214,133 @@ sub handler { &Apache::lonnet::logthis("grades got multiple commands ".join(':',@commands)); } +# see what the symb is + + my $symb=$env{'form.symb'}; + unless ($symb) { + (my $url=$env{'form.url'}) =~ s-^https*://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; + $symb=&Apache::lonnet::symbread($url); + } + &Apache::lonenc::check_decrypt(\$symb); + $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'}) { - ($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0)); + &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}]); + ($env{'form.student'} eq '' ? &listStudents($request,$symb) : &submission($request,0,0,$symb)); } elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) { - &pickStudentPage($request); + &startpage($request,$symb); + &pickStudentPage($request,$symb); } elsif ($command eq 'displayPage' && $perm{'vgr'}) { - &displayPage($request); + &startpage($request,$symb); + &displayPage($request,$symb); } elsif ($command eq 'gradeByPage' && $perm{'mgr'}) { - &updateGradeByPage($request); + &startpage($request,$symb); + &updateGradeByPage($request,$symb); } elsif ($command eq 'processGroup' && $perm{'vgr'}) { - &processGroup($request); + &startpage($request,$symb); + &processGroup($request,$symb); } elsif ($command eq 'gradingmenu' && $perm{'vgr'}) { - $request->print(&grading_menu($request)); - } elsif ($command eq 'submit_options' && $perm{'vgr'}) { - $request->print(&submit_options($request)); + &startpage($request,$symb); + $request->print(&grading_menu($request,$symb)); + } elsif ($command eq 'individual' && $perm{'vgr'}) { + &startpage($request,$symb); + $request->print(&submit_options($request,$symb)); + } elsif ($command eq 'ungraded' && $perm{'vgr'}) { + &startpage($request,$symb); + $request->print(&submit_options($request,$symb)); + } elsif ($command eq 'table' && $perm{'vgr'}) { + &startpage($request,$symb,[{href=>"", text=>"Grading table"}],1); + $request->print(&submit_options_table($request,$symb)); + } elsif ($command eq 'all_for_one' && $perm{'vgr'}) { + &startpage($request,$symb); + $request->print(&submit_options_sequence($request,$symb)); } elsif ($command eq 'viewgrades' && $perm{'vgr'}) { - $request->print(&viewgrades($request)); + &startpage($request,$symb,[{href=>"/adm/grades?symb=".&HTML::Entities::encode($symb,'<>&"')."&command=table", text=>"Grading table"},{href=>'', text=>"Modify grades"}],1); + $request->print(&viewgrades($request,$symb)); } elsif ($command eq 'handgrade' && $perm{'mgr'}) { - $request->print(&processHandGrade($request)); + &startpage($request,$symb); + $request->print(&processHandGrade($request,$symb)); } elsif ($command eq 'editgrades' && $perm{'mgr'}) { - $request->print(&editgrades($request)); + &startpage($request,$symb); + $request->print(&editgrades($request,$symb)); + } elsif ($command eq 'initialverifyreceipt' && $perm{'vgr'}) { + &startpage($request,$symb); + $request->print(&initialverifyreceipt($request,$symb)); } elsif ($command eq 'verify' && $perm{'vgr'}) { - $request->print(&verifyreceipt($request)); + &startpage($request,$symb); + $request->print(&verifyreceipt($request,$symb)); } elsif ($command eq 'processclicker' && $perm{'mgr'}) { - $request->print(&process_clicker($request)); + &startpage($request,$symb); + $request->print(&process_clicker($request,$symb)); } elsif ($command eq 'processclickerfile' && $perm{'mgr'}) { - $request->print(&process_clicker_file($request)); + &startpage($request,$symb); + $request->print(&process_clicker_file($request,$symb)); } elsif ($command eq 'assignclickergrades' && $perm{'mgr'}) { - $request->print(&assign_clicker_grades($request)); + &startpage($request,$symb); + $request->print(&assign_clicker_grades($request,$symb)); } elsif ($command eq 'csvform' && $perm{'mgr'}) { - $request->print(&upcsvScores_form($request)); + &startpage($request,$symb); + $request->print(&upcsvScores_form($request,$symb)); } elsif ($command eq 'csvupload' && $perm{'mgr'}) { - $request->print(&csvupload($request)); + &startpage($request,$symb); + $request->print(&csvupload($request,$symb)); } elsif ($command eq 'csvuploadmap' && $perm{'mgr'} ) { - $request->print(&csvuploadmap($request)); + &startpage($request,$symb); + $request->print(&csvuploadmap($request,$symb)); } elsif ($command eq 'csvuploadoptions' && $perm{'mgr'}) { if ($env{'form.associate'} ne 'Reverse Association') { - $request->print(&csvuploadoptions($request)); + &startpage($request,$symb); + $request->print(&csvuploadoptions($request,$symb)); } else { if ( $env{'form.upfile_associate'} ne 'reverse' ) { $env{'form.upfile_associate'} = 'reverse'; } else { $env{'form.upfile_associate'} = 'forward'; } - $request->print(&csvuploadmap($request)); + &startpage($request,$symb); + $request->print(&csvuploadmap($request,$symb)); } } elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) { - $request->print(&csvuploadassign($request)); + &startpage($request,$symb); + $request->print(&csvuploadassign($request,$symb)); } elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) { - $request->print(&scantron_selectphase($request)); + &startpage($request,$symb); + $request->print(&scantron_selectphase($request,undef,$symb)); } elsif ($command eq 'scantron_warning' && $perm{'mgr'}) { - $request->print(&scantron_do_warning($request)); + &startpage($request,$symb); + $request->print(&scantron_do_warning($request,$symb)); } elsif ($command eq 'scantron_validate' && $perm{'mgr'}) { - $request->print(&scantron_validate_file($request)); + &startpage($request,$symb); + $request->print(&scantron_validate_file($request,$symb)); } elsif ($command eq 'scantron_process' && $perm{'mgr'}) { - $request->print(&scantron_process_students($request)); + &startpage($request,$symb); + $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'}))) { - $request->print(&scantron_upload_scantron_data($request)); + &startpage($request,$symb); + $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'}))) { - $request->print(&scantron_upload_scantron_data_save($request)); + &startpage($request,$symb); + $request->print(&scantron_upload_scantron_data_save($request,$symb)); } elsif ($command eq 'scantron_download' && &Apache::lonnet::allowed('usc',$env{'request.course.id'})) { - $request->print(&scantron_download_scantron_data($request)); + &startpage($request,$symb); + $request->print(&scantron_download_scantron_data($request,$symb)); } elsif ($command eq 'checksubmissions' && $perm{'vgr'}) { - $request->print(&checkscantron_results($request)); + &startpage($request,$symb); + $request->print(&checkscantron_results($request,$symb)); } elsif ($command) { + &startpage($request,$symb); $request->print('

'.&mt('Access Denied ([_1])',$command).'

'); } }