--- loncom/homework/grades.pm 2012/05/02 15:21:00 1.596.2.12.2.3
+++ loncom/homework/grades.pm 2013/08/14 03:33:54 1.596.2.12.2.18
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.12.2.3 2012/05/02 15:21:00 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.18 2013/08/14 03:33:54 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,6 +52,7 @@ use POSIX qw(floor);
my %perm=();
+my %old_essays=();
# These variables are used to recover from ssi errors
@@ -124,13 +125,16 @@ sub getpartlist {
# --- 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(&mt("Unable to handle ambiguous references: [_1].",$url));
- return ();
- }
+ my $symb=$env{'form.symb'};
+ unless ($symb) {
+ (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
+ $symb = &Apache::lonnet::symbread($url);
+ if ($symb eq '') {
+ if (!$silent) {
+ $request->print(&mt("Unable to handle ambiguous references: [_1].",$url));
+ return ();
+ }
+ }
}
&Apache::lonenc::check_decrypt(\$symb);
return ($symb);
@@ -249,7 +253,7 @@ sub showResourceInfo {
$result.='
'.$display_part.' | '
.''.''.$resID.' | '
.''.&mt($responsetype).' | '
-# .''.&mt('Handgrade: [_1]',$handgrade).' | '
+# .''.&mt('Handgrade: [_1]',$handgrade).' | '
.&Apache::loncommon::end_data_table_row();
}
}
@@ -260,6 +264,7 @@ sub showResourceInfo {
sub reset_caches {
&reset_analyze_cache();
&reset_perm();
+ &reset_old_essays();
}
{
@@ -743,7 +748,11 @@ sub compute_points {
#
sub most_similar {
- my ($uname,$udom,$uessay,$old_essays)=@_;
+ my ($uname,$udom,$symb,$uessay)=@_;
+
+ unless ($symb) { return ''; }
+
+ unless (ref($old_essays{$symb}) eq 'HASH') { return ''; }
# ignore spaces and punctuation
@@ -760,11 +769,11 @@ sub most_similar {
my $scrsid='';
my $sessay='';
# go through all essays ...
- foreach my $tkey (keys(%$old_essays)) {
+ foreach my $tkey (keys(%{$old_essays{$symb}})) {
my ($tname,$tdom,$tcrsid)=map {&unescape($_)} (split(/\./,$tkey));
# ... except the same student
next if (($tname eq $uname) && ($tdom eq $udom));
- my $tessay=$old_essays->{$tkey};
+ my $tessay=$old_essays{$symb}{$tkey};
$tessay=~s/\W+/ /gs;
# String similarity gives up if not even limit
my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit);
@@ -774,7 +783,7 @@ sub most_similar {
$sname=$tname;
$sdom=$tdom;
$scrsid=$tcrsid;
- $sessay=$old_essays->{$tkey};
+ $sessay=$old_essays{$symb}{$tkey};
}
}
if ($limit>0.6) {
@@ -1610,17 +1619,15 @@ INNERJS
function savedMsgHeader(Nmsg,usrctr,fullname) {
var height = 70*Nmsg+250;
- var scrollbar = "no";
if (height > 600) {
height = 600;
- scrollbar = "yes";
}
var xpos = (screen.width-600)/2;
xpos = (xpos < 0) ? '0' : xpos;
var ypos = (screen.height-height)/2-30;
ypos = (ypos < 0) ? '0' : ypos;
- pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=700,height='+height);
+ pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars=yes,screenx='+xpos+',screeny='+ypos+',width=700,height='+height);
pWin.focus();
pDoc = pWin.document;
pDoc.$docopen;
@@ -1786,7 +1793,7 @@ sub gradeBox {
$wgt = ($wgt > 0 ? $wgt : '1');
my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ?
'' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt));
- my $result=''."\n";
+ my $data_WGT=''."\n";
my $display_part= &get_display_part($partid,$symb);
my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
[$partid]);
@@ -1794,7 +1801,7 @@ sub gradeBox {
if ($last_resets{$partid}) {
$aggtries = &get_num_tries($record,$last_resets{$partid},$partid);
}
- $result.=&Apache::loncommon::start_data_table_row();
+ my $result=&Apache::loncommon::start_data_table_row();
my $ctr = 0;
my $thisweight = 0;
my $increment = &get_increment();
@@ -1831,8 +1838,8 @@ sub gradeBox {
$result .=
- ''.$display_part.' | '.$radio.' | '.&mt('or').' | '.$line.' | ';
- $result.=&Apache::loncommon::end_data_table_row();
+ ''.$data_WGT.$display_part.' | '.$radio.' | '.&mt('or').' | '.$line.' | ';
+ $result.=&Apache::loncommon::end_data_table_row().'';
$result.=''."\n".
''."\n".
''."\n";
my $res_error;
$result.=&handback_box($symb,$uname,$udom,$counter,$partid,$record,\$res_error);
+ $result.=' | '.&Apache::loncommon::end_data_table_row();
if ($res_error) {
return &navmap_errormsg();
}
@@ -1916,14 +1924,27 @@ sub show_problem {
$companswer=~s|||g;
$companswer=~s|name="submit"|name="would_have_been_submit"|g;
}
+ my $renderheading = &mt('View of the problem');
+ my $answerheading = &mt('Correct answer');
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
+ my $stu_fullname = $env{'form.fullname'};
+ if ($stu_fullname eq '') {
+ $stu_fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
+ }
+ my $forwhom = &nameUserString(undef,$stu_fullname,$uname,$udom);
+ if ($forwhom ne '') {
+ $renderheading = &mt('View of the problem for[_1]',$forwhom);
+ $answerheading = &mt('Correct answer for[_1]',$forwhom);
+ }
+ }
$rendered=
''
- .'
'.&mt('View of the problem').'
'
+ .''.$renderheading.'
'
.$rendered
.'';
$companswer=
''
- .'
'.&mt('Correct answer').'
'
+ .''.$answerheading.'
'
.$companswer
.'';
my $result;
@@ -1994,7 +2015,7 @@ sub submission {
$udom = ($udom eq '' ? $env{'user.domain'} : $udom); #has form.userdom changed for a student?
my $usec = &Apache::lonnet::getsection($udom,$uname,$env{'request.course.id'});
$env{'form.fullname'} = &Apache::loncommon::plainname($uname,$udom,'lastname') if $env{'form.fullname'} eq '';
- my $symb = &get_symb($request);
+ my ($symb) = &get_symb($request);
if ($symb eq '') { $request->print("Unable to handle ambiguous references:."); return ''; }
if (!&canview($usec)) {
@@ -2013,7 +2034,6 @@ sub submission {
'" src="'.$request->dir_config('lonIconsURL').
'/check.gif" height="16" border="0" />';
- my %old_essays;
# header info
if ($counter == 0) {
&sub_page_js($request);
@@ -2119,7 +2139,7 @@ sub submission {
$lt{'keyw'}:
$lt{'list'}
$lt{'past'}
+ class="page">$lt{'past'}
$lt{'high'}
KEYWORDS
#
@@ -2129,7 +2149,7 @@ KEYWORDS
my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);
$apath=&escape($apath);
$apath=~s/\W/\_/gs;
- %old_essays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
+ &init_old_essays($symb,$apath,$adom,$aname);
}
}
@@ -2233,13 +2253,14 @@ KEYWORDS
if ($env{"form.$uname:$udom:$partid:submitted_by"}) {
if (exists($seenparts{$partid})) { next; }
$seenparts{$partid}=1;
- my $submitby='Part: '.$display_part.
- ' Collaborative submission by: '.
- ''.
- $$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.'
';
- $request->print($submitby);
+ $request->print(
+ ''.&mt('Part: [_1]',$display_part).''.
+ ' '.&mt('Collaborative submission by: [_1]',
+ ''.
+ $$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.'').
+ '
');
next;
}
my $responsetype = $responseType->{$partid}->{$respid};
@@ -2266,7 +2287,7 @@ KEYWORDS
}
if($env{'form.checkPlag'}){
my ($oname,$odom,$ocrsid,$oessay,$osim)=
- &most_similar($uname,$udom,$subval,\%old_essays);
+ &most_similar($uname,$udom,$symb,$subval);
if ($osim) {
$osim=int($osim*100.0);
my %old_course_desc =
@@ -2306,18 +2327,26 @@ KEYWORDS
if ($hide eq 'anon') {
$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').'
';
+ $lastsubonly.='
'.''.&mt('Submitted Files:').''
+ .'
';
+ if(@$files == 1) {
+ $lastsubonly .= &mt('Like all files provided by users, this file may contain viruses!');
+ } else {
+ $lastsubonly .= &mt('Like all files provided by users, these files may contain viruses!');
+ }
+ $lastsubonly .= '';
+
foreach my $file (@$files) {
&Apache::lonnet::allowuploaded('/adm/grades',$file);
- $lastsubonly.='
'.$file.'';
+ $lastsubonly.='
'.$file.'';
}
}
$lastsubonly.='
';
}
if ($hide eq 'anon') {
- $lastsubonly.=''.&mt('Anonymous Survey').'';
+ $lastsubonly.='
'.&mt('Anonymous Survey').'';
} else {
- $lastsubonly.=''.&mt('Submitted Answer:').' '.
+ $lastsubonly.='
'.&mt('Submitted Answer:').' '.
&cleanRecord($subval,$responsetype,$symb,$partid,
$respid,\%record,$order,undef,$uname,$udom,$type,$trial,$rndseed);
}
@@ -2374,9 +2403,9 @@ KEYWORDS
''."\n";
$result.=' '.
- &mt('Compose message to student').(scalar(@$col_fullnames) >= 1 ? 's' : '').'