--- loncom/homework/grades.pm 2010/12/22 17:11:12 1.596.2.3 +++ loncom/homework/grades.pm 2010/03/11 16:29:42 1.597 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.596.2.3 2010/12/22 17:11:12 raeburn Exp $ +# $Id: grades.pm,v 1.597 2010/03/11 16:29:42 wenzelju Exp $ # # Copyright Michigan State University Board of Trustees # @@ -271,13 +271,8 @@ sub reset_caches { } sub get_analyze { - my ($symb,$uname,$udom,$no_increment,$add_to_hash,$type,$trial,$rndseed)=@_; + my ($symb,$uname,$udom,$no_increment,$add_to_hash)=@_; my $key = "$symb\0$uname\0$udom"; - if ($type eq 'randomizetry') { - if ($trial ne '') { - $key .= "\0".$trial; - } - } if (exists($analyze_cache{$key})) { my $getupdate = 0; if (ref($add_to_hash) eq 'HASH') { @@ -305,15 +300,9 @@ sub reset_caches { 'grade_courseid' => $env{'request.course.id'}, 'grade_username' => $uname, 'grade_noincrement' => $no_increment); - if ($type eq 'randomizetry') { - $form{'grade_questiontype'} = $type; - if ($rndseed ne '') { - $form{'grade_rndseed'} = $rndseed; - } - } if (ref($add_to_hash)) { %form = (%form,%{$add_to_hash}); - } + } my $subresult=&ssi_with_retries($url, $ssi_retries,%form); (undef,$subresult)=split(/_HASH_REF__/,$subresult,2); my %analyze=&Apache::lonnet::str2hash($subresult); @@ -326,15 +315,15 @@ sub reset_caches { } sub get_order { - my ($partid,$respid,$symb,$uname,$udom,$no_increment,$type,$trial,$rndseed)=@_; - my $analyze = &get_analyze($symb,$uname,$udom,$no_increment,undef,$type,$trial,$rndseed); + my ($partid,$respid,$symb,$uname,$udom,$no_increment)=@_; + my $analyze = &get_analyze($symb,$uname,$udom,$no_increment); return $analyze->{"$partid.$respid.shown"}; } sub get_radiobutton_correct_foil { - my ($partid,$respid,$symb,$uname,$udom,$type,$trial,$rndseed)=@_; - my $analyze = &get_analyze($symb,$uname,$udom,undef,undef,$type,$trial,$rndseed); - my $foils = &get_order($partid,$respid,$symb,$uname,$udom,undef,$type,$trial,$rndseed); + my ($partid,$respid,$symb,$uname,$udom)=@_; + my $analyze = &get_analyze($symb,$uname,$udom); + my $foils = &get_order($partid,$respid,$symb,$uname,$udom); if (ref($foils) eq 'ARRAY') { foreach my $foil (@{$foils}) { if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') { @@ -376,7 +365,7 @@ sub reset_caches { # response types only. sub cleanRecord { my ($answer,$response,$symb,$partid,$respid,$record,$order,$version, - $uname,$udom,$type,$trial,$rndseed) = @_; + $uname,$udom) = @_; my $grayFont = ''; if ($response =~ /^(option|rank)$/) { my %answer=&Apache::lonnet::str2hash($answer); @@ -393,7 +382,7 @@ sub cleanRecord { return '
'. ''.$toprow.''. ''. - $bottomrow.'
'.&mt('Answer').'
'.$grayFont.&mt('Option ID').'
'; + $grayFont.$bottomrow.''.''; } elsif ($response eq 'match') { my %answer=&Apache::lonnet::str2hash($answer); my %grading=&Apache::lonnet::str2hash($record->{$version."resource.$partid.$respid.submissiongrading"}); @@ -420,7 +409,7 @@ sub cleanRecord { my %answer=&Apache::lonnet::str2hash($answer); my ($toprow,$bottomrow); my $correct = - &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom,$type,$trial,$rndseed); + &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom); foreach my $foil (@$order) { if (exists($answer{$foil})) { if ($foil eq $correct) { @@ -436,7 +425,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', @@ -498,8 +487,7 @@ sub cleanRecord { #-- A couple of common js functions sub commonJSfunctions { my $request = shift; - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< 1) { @@ -527,7 +515,6 @@ sub commonJSfunctions { return selectOne.value; } } - COMMONJSFUNCTIONS } @@ -682,13 +669,13 @@ 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". @@ -897,8 +884,7 @@ sub listStudents { '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); @@ -1163,7 +1148,7 @@ LISTJAVASCRIPT sub check_script { my ($form, $type)=@_; - my $chkallscript=''."\n"; +'."\n"); return $chkallscript; } @@ -1233,8 +1218,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 } @@ -1412,8 +1395,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 = @@ -1489,8 +1468,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(< SUBJAVASCRIPT } @@ -2215,7 +2192,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; @@ -2226,12 +2203,6 @@ KEYWORDS my ($ressub,$hide,$subval) = split(/:/,$submission,3); # Similarity check my $similar=''; - my ($type,$trial,$rndseed); - if ($hide eq 'rand') { - $type = 'randomizetry'; - $trial = $record{"resource.$partid.tries"}; - $rndseed = $record{"resource.$partid.rndseed"}; - } if($env{'form.checkPlag'}){ my ($oname,$odom,$ocrsid,$oessay,$osim)= &most_similar($uname,$udom,$subval,\%old_essays); @@ -2241,7 +2212,7 @@ KEYWORDS &Apache::lonnet::coursedescription($ocrsid, {'one_time' => 1}); - if ($hide eq 'anon') { + 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 { @@ -2258,8 +2229,7 @@ KEYWORDS } } } - my $order=&get_order($partid,$respid,$symb,$uname,$udom, - undef,$type,$trial,$rndseed); + my $order=&get_order($partid,$respid,$symb,$uname,$udom); if ($env{'form.lastSub'} eq 'lastonly' || ($env{'form.lastSub'} eq 'hdgrade' && $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) { @@ -2268,10 +2238,10 @@ KEYWORDS ''.&mt('Part: [_1]',$display_part).''. ' '. '('.&mt('Part ID: [_1]',$respid).')'. - '   '; + '   '; my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); if (@$files) { - if ($hide eq 'anon') { + 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').'
'; @@ -2282,12 +2252,12 @@ KEYWORDS } $lastsubonly.='
'; } - if ($hide eq 'anon') { + if ($hide) { $lastsubonly.=''.&mt('Anonymous Survey').''; } else { $lastsubonly.=''.&mt('Submitted Answer:').' '. &cleanRecord($subval,$responsetype,$symb,$partid, - $respid,\%record,$order,undef,$uname,$udom,$type,$trial,$rndseed); + $respid,\%record,$order,undef,$uname,$udom); } if ($similar) {$lastsubonly.="

$similar\n";} $lastsubonly.=''; @@ -2495,51 +2465,35 @@ sub get_last_submission { &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'}); } } - my (%typeparts,%randombytry); + 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') || - ($lasthash{$key} eq 'randomizetry')) { + ($lasthash{$key} eq 'anonsurveycred')) { my ($ign,@parts) = split(/\./,$key); pop(@parts); - my $id = join('.',@parts); - if ($lasthash{$key} eq 'randomizetry') { - $randombytry{$ign.'.'.$id} = $lasthash{$key}; - } else { - unless ($showsurv) { - $typeparts{$ign.'.'.$id} = $lasthash{$key}; - } + unless ($showsurv) { + my $id = join(',',@parts); + $typeparts{$ign.'.'.$id} = $lasthash{$key}; } delete($lasthash{$key}); } } } my @hidden = keys(%typeparts); - my @randomize = keys(%randombytry); foreach my $key (keys(%lasthash)) { next if ($key !~ /\.submission$/); my $hide; if (@hidden) { foreach my $id (@hidden) { if ($key =~ /^\Q$id\E/) { - $hide = 'anon'; + $hide = 1; last; } } } - unless ($hide) { - if (@randomize) { - foreach my $id (@hidden) { - if ($key =~ /^\Q$id\E/) { - $hide = 'rand'; - last; - } - } - } - } my ($partid,$foo) = split(/submission$/,$key); my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ? 'Draft Copy ' : ''; @@ -3204,8 +3158,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 } @@ -3969,10 +3921,8 @@ to this page if the data selected is ins
- ENDPICK + $request->print(&Apache::lonhtmlcommon::scripttag($javascript)); return ''; } @@ -4017,8 +3967,7 @@ 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; } @@ -4300,8 +4248,7 @@ sub pickStudentPage { my ($request) = shift; my $alertmsg = &mt('Please select the student you wish to grade.'); - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< LISTJAVASCRIPT &commonJSfunctions($request); my ($symb) = &get_symb($request); @@ -4549,8 +4495,8 @@ sub displayPage { &Apache::loncommon::start_data_table_row(). ''.$prob. (scalar(@{$parts}) == 1 ? '' - : '
('.&mt('[_1]parts)', - scalar(@{$parts}).' ') + : '
('.&mt('[_1] parts)', + scalar(@{$parts})) ). ''; $studentTable.=''; @@ -4645,7 +4591,6 @@ sub displaySubByDates { my $interaction; my $no_increment = 1; - my %lastrndseed; for ($version=1;$version<=$$record{'version'};$version++) { my $timestamp = &Apache::lonlocal::locallocaltime($$record{$version.':timestamp'}); @@ -4663,9 +4608,9 @@ sub displaySubByDates { my @versionKeys = split(/\:/,$$record{$version.':keys'}); my @displaySub = (); foreach my $partid (@{$parts}) { - my ($hidden,$type); - $type = $$record{$version.':resource.'.$partid.'.type'}; - if (($type eq 'anonsurvey') || ($type eq 'anonsurveycred')) { + 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) @@ -4688,33 +4633,23 @@ sub displaySubByDates { if ($hidden) { $displaySub[0].= &mt('Anonymous Survey').''; } else { - my ($trial,$rndseed,$newvariation); - if ($type eq 'randomizetry') { - $trial = $$record{"$where.$partid.tries"}; - $rndseed = $$record{"$where.$partid.rndseed"}; - } if ($$record{"$where.$partid.tries"} eq '') { $displaySub[0].=&mt('Trial not counted'); } else { $displaySub[0].=&mt('Trial: [_1]', $$record{"$where.$partid.tries"}); - if ($rndseed || $lastrndseed{$partid}) { - if ($rndseed ne $lastrndseed{$partid}) { - $newvariation = ' ('.&mt('New variation this try').')'; - } - } } my $responseType=($isTask ? 'Task' : $responseType->{$partid}->{$responseId}); if (!exists($orders{$partid})) { $orders{$partid}={}; } - if ((!exists($orders{$partid}->{$responseId})) || ($trial)) { + if (!exists($orders{$partid}->{$responseId})) { $orders{$partid}->{$responseId}= &get_order($partid,$responseId,$symb,$uname,$udom, - $no_increment,$type,$trial,$rndseed); + $no_increment); } - $displaySub[0].=''.$newvariation.''; # /nobreak + $displaySub[0].=''; # /nobreak $displaySub[0].='  '. - &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom,$type,$trial,$rndseed).'
'; + &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom).'
'; } } } @@ -4816,7 +4751,7 @@ sub updateGradeByPage { &Apache::loncommon::start_data_table_row(). ''.$prob. (scalar(@{$parts}) == 1 ? '' - : '
('.&mt('[quant,_1,part]',scalar(@{$parts})) + : '
('.&mt('[quant,_1, part]',scalar(@{$parts})) .')').''; $studentTable.=' '.$title.' '; @@ -5363,17 +5298,15 @@ sub scantron_selectphase { 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(' - - + }')); + $r->print(' '.$default_form_data.' @@ -7060,8 +6993,7 @@ sub scantron_get_correction { $r->print("\n
"); } - $r->print(< + $r->print(&Apache::lonhtmlcommon::scripttag(< ENDSCRIPT my $href="/adm/pickcode?". "form=".&escape("scantronupload"). @@ -7141,8 +7072,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; } @@ -8024,8 +7953,7 @@ sub scantron_upload_scantron_data { my $default_form_data=&defaultFormData(&get_symb($r,1)); 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').'

@@ -8667,8 +8595,7 @@ sub grading_menu { $Str .="\n"; my $receiptalert = &mt("Please enter a receipt number given by a student in the receipt box."); - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< GRADINGMENUJS &commonJSfunctions($request); return $Str; @@ -8716,8 +8642,7 @@ sub submit_options { my $probTitle = &Apache::lonnet::gettitle($symb); my $receiptalert = &mt("Please enter a receipt number given by a student in the receipt box."); - $request->print(< + $request->print(&Apache::lonhtmlcommon::scripttag(< GRADINGMENUJS &commonJSfunctions($request); my ($table,undef,$hdgrade) = &showResourceInfo($symb,$probTitle); @@ -8993,11 +8917,10 @@ sub process_clicker { my $pcorrect=&mt("Percentage points for correct solution"); my $pincorrect=&mt("Percentage points for incorrect solution"); my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype', - {'iclicker' => 'i>clicker', - 'interwrite' => 'interwrite PRS'}); + ('iclicker' => 'i>clicker', + 'interwrite' => 'interwrite PRS')); $symb = &Apache::lonenc::check_encrypt($symb); - $result.=< + $result.= &Apache::lonhtmlcommon::scripttag(< +ENDUPFORM + $result.= < @@ -9054,7 +8978,7 @@ function sanitycheck() {


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

'."\n";