version 1.596.2.12.2.41.2.5, 2019/02/06 05:55:25
|
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 File::MMagic; |
use String::Similarity; |
use String::Similarity; |
use LONCAPA; |
use LONCAPA; |
|
|
Line 472 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 2051 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 2188 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 2333 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 4214 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 4607 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 4869 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"> '. |
my $result='<h3><span class="LC_info"> '. |
&mt('Manual Grading by Page or Sequence').'</span></h3>'; |
&mt('Manual Grading by Page or Sequence').'</span></h3>'; |
Line 4939 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 5815 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 5828 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 5843 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.(' 'x2).$formatoptions.' |
<td>'.$formattitle.(' 'x2).$formatoptions.' |
Line 5852 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 10262 sub process_clicker_file {
|
Line 10306 sub process_clicker_file {
|
$result .= |
$result .= |
&Apache::lonhtmlcommon::confirm_success( |
&Apache::lonhtmlcommon::confirm_success( |
&mt('No IDs found to determine correct answer'),1); |
&mt('No IDs found to determine correct answer'),1); |
return $result,.&show_grading_menu_form($symb); |
return $result.&show_grading_menu_form($symb); |
} |
} |
} |
} |
if (length($env{'form.upfile'}) < 2) { |
if (length($env{'form.upfile'}) < 2) { |
Line 10272 sub process_clicker_file {
|
Line 10316 sub process_clicker_file {
|
'<span class="LC_filename">'.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'</span>'),1); |
'<span class="LC_filename">'.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'</span>'),1); |
return $result.&show_grading_menu_form($symb); |
return $result.&show_grading_menu_form($symb); |
} |
} |
|
my $mimetype; |
|
if ($env{'form.upfiletype'} eq 'iclicker') { |
|
my $mm = new File::MMagic; |
|
$mimetype = $mm->checktype_contents($env{'form.upfile'}); |
|
unless (($mimetype eq 'text/plain') || ($mimetype eq 'text/html')) { |
|
$result.= '<p>'. |
|
&Apache::lonhtmlcommon::confirm_success( |
|
&mt('File format is neither csv (iclicker 6) nor xml (iclicker 7)'),1).'</p>'; |
|
return $result.&show_grading_menu_form($symb); |
|
} |
|
} elsif (($env{'form.upfiletype'} ne 'interwrite') && ($env{'form.upfiletype'} ne 'turning')) { |
|
$result .= '<p>'. |
|
&Apache::lonhtmlcommon::confirm_success( |
|
&mt('Invalid clicker type: choose one of: i>clicker, Interwrite PRS, or Turning Technologies.'),1).'</p>'; |
|
return $result.&show_grading_menu_form($symb); |
|
} |
|
|
# Were able to get all the info needed, now analyze the file |
# Were able to get all the info needed, now analyze the file |
|
|
Line 10299 ENDHEADER
|
Line 10359 ENDHEADER
|
my $errormsg=''; |
my $errormsg=''; |
my $number=0; |
my $number=0; |
if ($env{'form.upfiletype'} eq 'iclicker') { |
if ($env{'form.upfiletype'} eq 'iclicker') { |
($errormsg,$number)=&iclicker_eval(\@questiontitles,\%responses); |
if ($mimetype eq 'text/plain') { |
} |
($errormsg,$number)=&iclicker_eval(\@questiontitles,\%responses); |
if ($env{'form.upfiletype'} eq 'interwrite') { |
} elsif ($mimetype eq 'text/html') { |
|
($errormsg,$number)=&iclickerxml_eval(\@questiontitles,\%responses); |
|
} |
|
} elsif ($env{'form.upfiletype'} eq 'interwrite') { |
($errormsg,$number)=&interwrite_eval(\@questiontitles,\%responses); |
($errormsg,$number)=&interwrite_eval(\@questiontitles,\%responses); |
} |
} elsif ($env{'form.upfiletype'} eq 'turning') { |
if ($env{'form.upfiletype'} eq 'turning') { |
|
($errormsg,$number)=&turning_eval(\@questiontitles,\%responses); |
($errormsg,$number)=&turning_eval(\@questiontitles,\%responses); |
} |
} |
$result.='<br />'.&mt('Found [_1] question(s)',$number).'<br />'. |
$result.='<br />'.&mt('Found [_1] question(s)',$number).'<br />'. |
Line 10407 sub iclicker_eval {
|
Line 10469 sub iclicker_eval {
|
return ($errormsg,$number); |
return ($errormsg,$number); |
} |
} |
|
|
|
sub iclickerxml_eval { |
|
my ($questiontitles,$responses)=@_; |
|
my $number=0; |
|
my $errormsg=''; |
|
my @state; |
|
my %respbyid; |
|
my $p = HTML::Parser->new |
|
( |
|
xml_mode => 1, |
|
start_h => |
|
[sub { |
|
my ($tagname,$attr) = @_; |
|
push(@state,$tagname); |
|
if ("@state" eq "ssn p") { |
|
my $title = $attr->{qn}; |
|
$title =~ s/(^\s+|\s+$)//g; |
|
$questiontitles->[$number]=$title; |
|
} elsif ("@state" eq "ssn p v") { |
|
my $id = $attr->{id}; |
|
my $entry = $attr->{ans}; |
|
$id=~s/^[\#0]+//; |
|
$entry =~s/[^a-zA-Z0-9\.\*\-\+]+//g; |
|
$respbyid{$id}[$number] = $entry; |
|
} |
|
}, "tagname, attr"], |
|
end_h => |
|
[sub { |
|
my ($tagname) = @_; |
|
if ("@state" eq "ssn p") { |
|
$number++; |
|
} |
|
pop(@state); |
|
}, "tagname"], |
|
); |
|
|
|
$p->parse($env{'form.upfile'}); |
|
$p->eof; |
|
foreach my $id (keys(%respbyid)) { |
|
$responses->{$id}=join(',',@{$respbyid{$id}}); |
|
} |
|
return ($errormsg,$number); |
|
} |
|
|
sub interwrite_eval { |
sub interwrite_eval { |
my ($questiontitles,$responses)=@_; |
my ($questiontitles,$responses)=@_; |
my $number=0; |
my $number=0; |
Line 10700 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 10708 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'}) { |