--- loncom/homework/grades.pm 2019/02/23 15:18:33 1.760 +++ loncom/homework/grades.pm 2020/05/08 14:56:53 1.768 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.760 2019/02/23 15:18:33 raeburn Exp $ +# $Id: grades.pm,v 1.768 2020/05/08 14:56:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -315,7 +315,7 @@ sub reset_caches { $add_to_form = { 'code_for_randomlist' => $scancode,}; } } - my $analyze = + my $analyze = &get_analyze($symb,$uname,$udom,undef,$add_to_form, undef,undef,undef,$bubbles_per_row); if (ref($analyze) eq 'HASH') { @@ -345,7 +345,7 @@ sub cleanRecord { if ($response =~ /^(option|rank)$/) { my %answer=&Apache::lonnet::str2hash($answer); my @answer = %answer; - %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; + %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); my ($toprow,$bottomrow); foreach my $foil (@$order) { @@ -363,7 +363,7 @@ sub cleanRecord { } elsif ($response eq 'match') { my %answer=&Apache::lonnet::str2hash($answer); my @answer = %answer; - %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; + %answer = map {&HTML::Entities::encode($_, '"<>&')} @answer; my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); my @items=&Apache::lonnet::str2array($record->{$version."resource.$partid.$respid.submissionitems"}); my ($toprow,$middlerow,$bottomrow); @@ -422,7 +422,6 @@ sub cleanRecord { } $answer = &Apache::lontexconvert::msgtexconverted($answer); return '

'.&keywords_highlight($answer).'
'; - } elsif ( $response eq 'organic') { my $result=&mt('Smile representation: [_1]', '"'.&HTML::Entities::encode($answer, '"<>&').'"'); @@ -655,7 +654,7 @@ sub canmodify { #can modify the requested section return 1; } else { - # can't modify the request section + # can't modify the requested section return 0; } } @@ -668,19 +667,19 @@ sub canview { my ($sec)=@_; if ($perm{'vgr'}) { if (!defined($perm{'vgr_section'})) { - # can modify whole class + # can view whole class return 1; } else { if ($sec eq $perm{'vgr_section'}) { - #can modify the requested section + #can view the requested section return 1; } else { - # can't modify the request section + # can't view the requested section return 0; } } } - #can't modify + #can't view return 0; } @@ -821,14 +820,14 @@ sub initialverifyreceipt { #--- Check whether a receipt number is valid.--- sub verifyreceipt { - my ($request,$symb) = @_; + my ($request,$symb) = @_; my $courseid = $env{'request.course.id'}; my $receipt = &Apache::lonnet::recprefix($courseid).'-'. $env{'form.receipt'}; $receipt =~ s/[^\-\d]//g; - my $title.= + my $title = '

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

'."\n"; @@ -917,7 +916,7 @@ sub listStudents { my $getsec = $env{'form.section'} eq '' ? 'all' : $env{'form.section'}; my $getgroup = $env{'form.group'} eq '' ? 'all' : $env{'form.group'}; unless ($submitonly) { - $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'}; + $submitonly = $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'}; } my $result=''; @@ -1214,8 +1213,8 @@ LISTJAVASCRIPT #---- Called from the listStudents routine sub check_script { - my ($form, $type)=@_; - my $chkallscript= &Apache::lonhtmlcommon::scripttag(' + my ($form,$type) = @_; + my $chkallscript = &Apache::lonhtmlcommon::scripttag(' function checkall() { for (i=0; iprint(&mt('There are currently no submitted documents.')); - return; + $r->print(&mt('There are currently no submitted documents.')); + return; } my $all_students = join("\n", &Apache::loncommon::get_env_multiple('form.stuinfo')); @@ -4199,7 +4198,7 @@ sub editgrades { my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section')); my $title='

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

'; - $title.='

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

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

'.&mt('Section:').' '.$section_display.'

'."\n"; my $result= &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). @@ -4642,7 +4641,7 @@ ENDUPFORM sub csvuploadmap { - my ($request,$symb)= @_; + my ($request,$symb) = @_; if (!$symb) {return '';} my $datatoken; @@ -4738,7 +4737,7 @@ sub get_fields { } sub csvuploadassign { - my ($request,$symb)= @_; + my ($request,$symb) = @_; if (!$symb) {return '';} my $error_msg = ''; my $datatoken = &Apache::loncommon::valid_datatoken($env{'form.datatoken'}); @@ -4854,7 +4853,7 @@ sub csvuploadassign { $grades{$store_key}=$entries{$fields{$dest}}; } } - if (! %grades) { + if (! %grades) { push(@skipped,&mt("[_1]: no data to save","$username:$domain")); } else { $grades{"resource.regrader"}="$env{'user.name'}:$env{'user.domain'}"; @@ -4925,6 +4924,7 @@ LISTJAVASCRIPT 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 $result='

 '. &mt('Manual Grading by Page or Sequence').'

'; @@ -5014,7 +5014,7 @@ LISTJAVASCRIPT ''.&nameUserString('header').''. &Apache::loncommon::end_data_table_header_row(); - my (undef,undef,$fullname) = &getclasslist($getsec,'1'); + my (undef,undef,$fullname) = &getclasslist($getsec,'1',$getgroup); my $ptr = 1; foreach my $student (sort { @@ -5654,7 +5654,7 @@ the homework problem. sub defaultFormData { my ($symb)=@_; - return ''; + return ''; } @@ -6001,8 +6001,6 @@ sub scantron_selectphase { $r->print($result); - - # Chunk of the form that prompts to view a scoring office file, # corrected file, skipped records in a file. @@ -7826,7 +7824,7 @@ sub verify_bubbles_checked { my $ansnumstr = join('","',@ansnums); my $warning = &mt("A bubble or 'No bubble' selection has not been made for one or more lines."); &js_escape(\$warning); - my $output = &Apache::lonhtmlcommon::scripttag((<'."\n". @@ -9367,7 +9365,7 @@ sub valid_file { } sub scantron_download_scantron_data { - my ($r,$symb)=@_; + 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'}; @@ -9738,7 +9736,6 @@ sub verify_scantron_grading { return ($counter,$record); } - #-------- end of section for handling grading scantron forms ------- # #------------------------------------------------------------------- @@ -9793,7 +9790,7 @@ sub grading_menu { icon => 'grade_students.png', linktitle => 'Grade current resource for a selection of students.' }, - { linktext => 'Grade ungraded submissions.', + { linktext => 'Grade ungraded submissions', url => $url1b, permission => 'F', icon => 'ungrade_sub.png', @@ -9859,7 +9856,6 @@ sub grading_menu { return $Str; } - sub ungraded { my ($request)=@_; &submit_options($request); @@ -9942,8 +9938,6 @@ sub submit_options { - - '; return $result; } @@ -10211,12 +10205,12 @@ ENDUPFORM ENDGRADINGFORM - $result.=''.&Apache::loncommon::end_data_table_row(). + $result.=''.&Apache::loncommon::end_data_table_row(). &Apache::loncommon::start_data_table_row().''.(<$pcorrect:

-' + ENDPERCFORM $result.=''. &Apache::loncommon::end_data_table_row(). @@ -10225,7 +10219,7 @@ ENDPERCFORM } sub process_clicker_file { - my ($r,$symb)=@_; + my ($r,$symb) = @_; if (!$symb) {return '';} my %Saveable_Parameters=&clicker_grading_parameters(); @@ -10399,7 +10393,7 @@ ENDHEADER "\n".&mt("Username").":  ". "\n".&mt("Domain").": ". &Apache::loncommon::select_dom_form($env{'course.'.$env{'request.course.id'}.'.domain'},'udom'.$id).' '. - &Apache::loncommon::selectstudent_link('clickeranalysis','uname'.$id,'udom'.$id,0,$id); + &Apache::loncommon::selectstudent_link('clickeranalysis','uname'.$id,'udom'.$id,'',$id); $unknown_count++; } } @@ -10555,7 +10549,7 @@ sub turning_eval { sub assign_clicker_grades { - my ($r,$symb)=@_; + my ($r,$symb) = @_; if (!$symb) {return '';} # See which part we are saving to my $res_error; @@ -10566,11 +10560,11 @@ sub assign_clicker_grades { # FIXME: This should probably look for the first handgradeable part my $part=$$partlist[0]; # Start screen output - my $result=&Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). - ''.&mt('Assigning grades based on clicker file').''. - &Apache::loncommon::end_data_table_header_row(). - &Apache::loncommon::start_data_table_row().''; + my $result = &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Assigning grades based on clicker file').''. + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row().''; # Get correct result # FIXME: Possibly need delimiter other than ":" my @correct=(); @@ -10632,7 +10626,7 @@ sub assign_clicker_grades { for (my $i=0;$i<$number;$i++) { if ($correct[$i] eq '-') { $realnumber--; - } elsif (($answer[$i]) || ($answer[$i]=~/^[0\.]+$/)) { + } elsif (($answer[$i]) || ($answer[$i]=~/^[0\.]+$/)) { if ($gradingmechanism eq 'attendance') { $sum+=$pcorrect; } elsif ($correct[$i] eq '*') { @@ -10706,7 +10700,9 @@ sub startpage { unshift(@$crumbs,{href=>&href_symb_cmd($symb,'gradingmenu'),text=>"Grading"}); $args{'bread_crumbs'} = $crumbs; $r->print(&Apache::loncommon::start_page('Grading',$js,\%args)); - &Apache::lonquickgrades::startGradeScreen($r,($env{'form.symb'}?'probgrading':'grading')); + if ($env{'request.course.id'}) { + &Apache::lonquickgrades::startGradeScreen($r,($env{'form.symb'}?'probgrading':'grading')); + } } unless ($nodisplayflag) { $r->print(&Apache::lonhtmlcommon::resource_info_box($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp)); @@ -10937,7 +10933,7 @@ sub handler { } if ($env{'form.inhibitmenu'}) { $request->print(&Apache::loncommon::end_page()); - } else { + } elsif ($env{'request.course.id'}) { &Apache::lonquickgrades::endGradeScreen($request); } &reset_caches();