Diff for /loncom/homework/grades.pm between versions 1.596.2.12.2.41.2.6 and 1.596.2.12.2.49

version 1.596.2.12.2.41.2.6, 2019/02/23 17:34:59 version 1.596.2.12.2.49, 2019/08/17 17:43:43
Line 44  use Apache::Constants qw(:common :http); Line 44  use Apache::Constants qw(:common :http);
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonenc;  use Apache::lonenc;
 use Apache::bridgetask();  use Apache::bridgetask();
   use Apache::lontexconvert();
 use HTML::Parser();  use HTML::Parser();
 use File::MMagic;  use File::MMagic;
 use String::Similarity;  use String::Similarity;
Line 474  sub cleanRecord { Line 475  sub cleanRecord {
     $env{'form.kwstyle'}  = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';      $env{'form.kwstyle'}  = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
     $env{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.      $env{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.
  }   }
           $answer = &Apache::lontexconvert::msgtexconverted($answer);
  return '<br /><br /><blockquote><tt>'.&keywords_highlight($answer).'</tt></blockquote>';   return '<br /><br /><blockquote><tt>'.&keywords_highlight($answer).'</tt></blockquote>';
     } elsif ( $response eq 'organic') {      } elsif ( $response eq 'organic') {
         my $result=&mt('Smile representation: [_1]',          my $result=&mt('Smile representation: [_1]',
Line 2053  sub submission { Line 2055  sub submission {
     $env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq '';      $env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq '';
     my ($symb) = &get_symb($request);       my ($symb) = &get_symb($request); 
     if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; }      if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; }
       my ($essayurl,%coursedesc_by_cid);
   
     if (!&canview($usec)) {      if (!&canview($usec)) {
         $request->print(          $request->print(
Line 2190  sub submission { Line 2193  sub submission {
 #  #
 # Load the other essays for similarity check  # Load the other essays for similarity check
 #  #
             my (undef,undef,$essayurl) = &Apache::lonnet::decode_symb($symb);              (undef,undef,$essayurl) = &Apache::lonnet::decode_symb($symb);
     my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);              if ($essayurl eq 'lib/templates/simpleproblem.problem') {
     $apath=&escape($apath);                  my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     $apath=~s/\W/\_/gs;                  my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
             &init_old_essays($symb,$apath,$adom,$aname);                  if ($cdom ne '' && $cnum ne '') {
                       my ($map,$id,$res) = &Apache::lonnet::decode_symb($symb);
                       if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(default(?:|_\d+)\.(?:sequence|page))$}) {
                           my $apath = $1.'_'.$id;
                           $apath=~s/\W/\_/gs;
                           &init_old_essays($symb,$apath,$cdom,$cnum);
                       }
                   }
               } else {
           my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);
           $apath=&escape($apath);
           $apath=~s/\W/\_/gs;
                   &init_old_essays($symb,$apath,$adom,$aname);
               }
         }          }
     }      }
   
Line 2335  sub submission { Line 2351  sub submission {
     &most_similar($uname,$udom,$symb,$subval);      &most_similar($uname,$udom,$symb,$subval);
  if ($osim) {   if ($osim) {
     $osim=int($osim*100.0);      $osim=int($osim*100.0);
     my %old_course_desc =   
  &Apache::lonnet::coursedescription($ocrsid,  
    {'one_time' => 1});  
   
                             if ($hide eq 'anon') {                              if ($hide eq 'anon') {
                                 $similar='<hr /><span class="LC_warning">'.&mt("Essay was found to be similar to another essay submitted for this assignment.").'<br />'.                                  $similar='<hr /><span class="LC_warning">'.&mt("Essay was found to be similar to another essay submitted for this assignment.").'<br />'.
                                          &mt('As the current submission is for an anonymous survey, no other details are available.').'</span><hr />';                                           &mt('As the current submission is for an anonymous survey, no other details are available.').'</span><hr />';
                             } else {                              } else {
         $similar="<hr /><h3><span class=\"LC_warning\">".          $similar='<hr />';
     &mt('Essay is [_1]% similar to an essay by [_2] in course [_3] (course id [_4]:[_5])',                                  if ($essayurl eq 'lib/templates/simpleproblem.problem') {
         $osim,                                      $similar .= '<h3><span class="LC_warning">'.
         &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')',                                                  &mt('Essay is [_1]% similar to an essay by [_2]',
         $old_course_desc{'description'},                                                      $osim,
         $old_course_desc{'num'},                                                      &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')').
         $old_course_desc{'domain'}).                                                  '</span></h3>';
     '</span></h3><blockquote><i>'.                                  } elsif ($ocrsid ne '') {
     &keywords_highlight($oessay).                                      my %old_course_desc;
     '</i></blockquote><hr />';                                      if (ref($coursedesc_by_cid{$ocrsid}) eq 'HASH') {
                             }                                          %old_course_desc = %{$coursedesc_by_cid{$ocrsid}};
  }                                      } else {
     }                                          my $args;
                                           if ($ocrsid ne $env{'request.course.id'}) {
                                               $args = {'one_time' => 1};
                                           }
                                           %old_course_desc =
                                               &Apache::lonnet::coursedescription($ocrsid,$args);
                                           $coursedesc_by_cid{$ocrsid} = \%old_course_desc;
                                       }
                                       $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'}).
               '</span></h3>';
                                   } else {
                                       $similar .=
                                           '<h3><span class="LC_warning">'.
                                           &mt('Essay is [_1]% similar to an essay by [_2] in an unknown course',
                                               $osim,
                                               &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')').
                                           '</span></h3>';
                                   }
                                   $similar .= '<blockquote><i>'.
                                               &keywords_highlight($oessay).
                                               '</i></blockquote><hr />';
               }
                           }
                       }
     my $order=&get_order($partid,$respid,$symb,$uname,$udom,      my $order=&get_order($partid,$respid,$symb,$uname,$udom,
                                          undef,$type,$trial,$rndseed);                                           undef,$type,$trial,$rndseed);
                     if ($env{'form.lastSub'} eq 'lastonly' || $env{'form.lastSub'} eq 'datesub' || $env{'form.lastSub'} =~ /^(last|all)$/ || ($env{'form.lastSub'} eq 'hdgrade' &&                      if ($env{'form.lastSub'} eq 'lastonly' || $env{'form.lastSub'} eq 'datesub' || $env{'form.lastSub'} =~ /^(last|all)$/ || ($env{'form.lastSub'} eq 'hdgrade' &&
Line 4216  sub editgrades { Line 4257  sub editgrades {
  my ($uname,$udom)=split(/:/,$user);   my ($uname,$udom)=split(/:/,$user);
  my %newrecord;   my %newrecord;
  my $updateflag = 0;   my $updateflag = 0;
  my $usec=$classlist->{"$uname:$udom"}[5];          my $usec=$classlist->{"$uname:$udom"}[5];
         my $canmodify = &canmodify($usec);          my $canmodify = &canmodify($usec);
         my $line = '<td'.($canmodify?'':' colspan="2"').'>'.          my $line = '<td'.($canmodify?'':' colspan="2"').'>'.
                    &nameUserString(undef,$$fullname{$user},$uname,$udom).'</td>';                     &nameUserString(undef,$$fullname{$user},$uname,$udom).'</td>';
Line 4609  sub csvuploadmap { Line 4650  sub csvuploadmap {
  $datatoken=&Apache::loncommon::upfile_store($request);   $datatoken=&Apache::loncommon::upfile_store($request);
     } else {      } else {
         $datatoken=&Apache::loncommon::valid_datatoken($env{'form.datatoken'});          $datatoken=&Apache::loncommon::valid_datatoken($env{'form.datatoken'});
         if ($datatoken ne '') {          if ($datatoken ne '') { 
             &Apache::loncommon::load_tmp_file($request,$datatoken);      &Apache::loncommon::load_tmp_file($request,$datatoken);
         }          }
     }      }
     my @records=&Apache::loncommon::upfile_record_sep();      my @records=&Apache::loncommon::upfile_record_sep();
Line 4871  LISTJAVASCRIPT Line 4912  LISTJAVASCRIPT
     my $cdom      = $env{"course.$env{'request.course.id'}.domain"};      my $cdom      = $env{"course.$env{'request.course.id'}.domain"};
     my $cnum      = $env{"course.$env{'request.course.id'}.num"};      my $cnum      = $env{"course.$env{'request.course.id'}.num"};
     my $getsec    = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};      my $getsec    = $env{'form.section'} eq '' ? 'all' : $env{'form.section'};
       my $getgroup  = $env{'form.group'} eq '' ? 'all' : $env{'form.group'};
   
     my $result='<h3><span class="LC_info">&nbsp;'.      my $result='<h3><span class="LC_info">&nbsp;'.
  &mt('Manual Grading by Page or Sequence').'</span></h3>';   &mt('Manual Grading by Page or Sequence').'</span></h3>';
Line 4941  LISTJAVASCRIPT Line 4983  LISTJAVASCRIPT
  '<th>'.&nameUserString('header').'</th>'.   '<th>'.&nameUserString('header').'</th>'.
  &Apache::loncommon::end_data_table_header_row();   &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;      my $ptr = 1;
     foreach my $student (sort       foreach my $student (sort 
  {   {
Line 5817  sub scantron_selectphase { Line 5859  sub scantron_selectphase {
   
         $r->print('          $r->print('
     <br />');      <br />');
     my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'};          my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'};          my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'};
     my $alertmsg = &mt('Please use the browse button to select a file from your local directory.');          my $alertmsg = &mt('Please use the browse button to select a file from your local directory.');
     &js_escape(\$alertmsg);          &js_escape(\$alertmsg);
     my ($formatoptions,$formattitle,$formatjs) = &scantron_upload_dataformat($cdom);          my ($formatoptions,$formattitle,$formatjs) = &scantron_upload_dataformat($cdom);
     $r->print(&Apache::lonhtmlcommon::scripttag('          $r->print(&Apache::lonhtmlcommon::scripttag('
     function checkUpload(formname) {      function checkUpload(formname) {
         if (formname.upfile.value == "") {          if (formname.upfile.value == "") {
             alert("'.$alertmsg.'");              alert("'.$alertmsg.'");
Line 5830  sub scantron_selectphase { Line 5872  sub scantron_selectphase {
         }          }
         formname.submit();          formname.submit();
     }'."\n".$formatjs));      }'."\n".$formatjs));
     $r->print('          $r->print('
               <form enctype="multipart/form-data" action="/adm/grades" name="rules" method="post">                <form enctype="multipart/form-data" action="/adm/grades" name="rules" method="post">
                 '.$default_form_data.'                  '.$default_form_data.'
                 <input name="courseid" type="hidden" value="'.$cnum.'" />                  <input name="courseid" type="hidden" value="'.$cnum.'" />
Line 5845  sub scantron_selectphase { Line 5887  sub scantron_selectphase {
               '.&Apache::loncommon::start_data_table_row().'                '.&Apache::loncommon::start_data_table_row().'
             <td>              <td>
                 '.&mt('File to upload: [_1]','<input type="file" name="upfile" size="50" />').'<br />'."\n");                  '.&mt('File to upload: [_1]','<input type="file" name="upfile" size="50" />').'<br />'."\n");
     if ($formatoptions) {          if ($formatoptions) {
         $r->print('</td>              $r->print('</td>
                  '.&Apache::loncommon::end_data_table_row().'                   '.&Apache::loncommon::end_data_table_row().'
                  '.&Apache::loncommon::start_data_table_row().'                   '.&Apache::loncommon::start_data_table_row().'
                  <td>'.$formattitle.('&nbsp;'x2).$formatoptions.'                   <td>'.$formattitle.('&nbsp;'x2).$formatoptions.'
Line 5854  sub scantron_selectphase { Line 5896  sub scantron_selectphase {
                  '.&Apache::loncommon::end_data_table_row().'                   '.&Apache::loncommon::end_data_table_row().'
                  '.&Apache::loncommon::start_data_table_row().'                   '.&Apache::loncommon::start_data_table_row().'
                  <td>'                   <td>'
         );              );
     } else {          } else {
         $r->print(' <br />');              $r->print(' <br />');
     }          }
     $r->print('<input type="button" onclick="javascript:checkUpload(this.form);" value="'.&mt('Upload Bubblesheet Data').'" />          $r->print('<input type="button" onclick="javascript:checkUpload(this.form);" value="'.&mt('Upload Bubblesheet Data').'" />
               </td>                </td>
              '.&Apache::loncommon::end_data_table_row().'               '.&Apache::loncommon::end_data_table_row().'
              '.&Apache::loncommon::end_data_table().'               '.&Apache::loncommon::end_data_table().'
              </form>'               </form>'
     );          );
   
     }      }
   
Line 10763  sub handler { Line 10805  sub handler {
         }          }
         &Apache::loncommon::content_type($request,'text/html');          &Apache::loncommon::content_type($request,'text/html');
         $request->send_http_header;          $request->send_http_header;
         if (($command eq 'scantron_selectphase' && $perm{'mgr'}) ||           if (($command eq 'scantron_selectphase' && $perm{'mgr'}) ||
             (($command eq 'scantronupload') &&              (($command eq 'scantronupload') &&
              (&Apache::lonnet::allowed('usc',$env{'request.role.domain'}) ||               (&Apache::lonnet::allowed('usc',$env{'request.role.domain'}) ||
               &Apache::lonnet::allowed('usc',$env{'request.course.id'})))) {                &Apache::lonnet::allowed('usc',$env{'request.course.id'})))) {
Line 10771  sub handler { Line 10813  sub handler {
                        undef,undef,undef,undef,'toggleScantab(document.rules);');                         undef,undef,undef,undef,'toggleScantab(document.rules);');
         } else {          } else {
             unless ((($command eq 'submission' || $command eq 'versionsub')) && ($perm{'vgr'})) {              unless ((($command eq 'submission' || $command eq 'versionsub')) && ($perm{'vgr'})) {
                 $request->print($start_page);                   $request->print($start_page);
             }              }
         }          }
  if ($command eq 'submission' && $perm{'vgr'}) {   if ($command eq 'submission' && $perm{'vgr'}) {

Removed from v.1.596.2.12.2.41.2.6  
changed lines
  Added in v.1.596.2.12.2.49


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>