--- loncom/homework/grades.pm 2009/03/21 20:02:28 1.528.2.12 +++ loncom/homework/grades.pm 2008/12/15 16:37:49 1.535 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.528.2.12 2009/03/21 20:02:28 raeburn Exp $ +# $Id: grades.pm,v 1.535 2008/12/15 16:37:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,6 +26,8 @@ # http://www.lon-capa.org/ # + + package Apache::grades; use strict; use Apache::style; @@ -58,46 +60,6 @@ my $ssi_error_resource; my $ssi_error_message; -# Do an ssi with retries: -# While I'd love to factor out this with the vesrion in lonprintout, -# that would either require a data coupling between modules, which I refuse to perpetuate -# (there's quite enough of that already), or would require the invention of another infrastructure -# I'm not quite ready to invent (e.g. an ssi_with_retry object). -# -# At least the logic that drives this has been pulled out into loncommon. - - -# -# ssi_with_retries - Does the server side include of a resource. -# if the ssi call returns an error we'll retry it up to -# the number of times requested by the caller. -# If we still have a proble, no text is appended to the -# output and we set some global variables. -# to indicate to the caller an SSI error occurred. -# All of this is supposed to deal with the issues described -# in LonCAPA BZ 5631 see: -# http://bugs.lon-capa.org/show_bug.cgi?id=5631 -# by informing the user that this happened. -# -# Parameters: -# resource - The resource to include. This is passed directly, without -# interpretation to lonnet::ssi. -# form - The form hash parameters that guide the interpretation of the resource -# -# retries - Number of retries allowed before giving up completely. -# Returns: -# On success, returns the rendered resource identified by the resource parameter. -# Side Effects: -# The following global variables can be set: -# ssi_error - If an unrecoverable error occurred this becomes true. -# It is up to the caller to initialize this to false -# if desired. -# ssi_error_resource - If an unrecoverable error occurred, this is the value -# of the resource that could not be rendered by the ssi -# call. -# ssi_error_message - The error string fetched from the ssi response -# in the event of an error. -# sub ssi_with_retries { my ($resource, $retries, %form) = @_; my ($content, $response) = &Apache::loncommon::ssi_with_retries($resource, $retries, %form); @@ -255,9 +217,9 @@ sub showResourceInfo { $partsseen{$partID}=1; } my $display_part=&get_display_part($partID,$symb); - $result.=''.&mt('Part').': '.$display_part. - ' '.$resID.''. - ''.&mt('Type').': '.$responsetype.''; + $result.=''.&mt('Part: [_1]',$display_part).' '. + $resID.''. + ''.&mt('Type: [_1]',$responsetype).''; # ''.&mt('Handgrade: [_1]',$handgrade).''; } } @@ -306,14 +268,11 @@ sub reset_caches { sub get_radiobutton_correct_foil { 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') { - return $foil; - } - } - } + foreach my $foil (@{&get_order($partid,$respid,$symb,$uname,$udom)}) { + if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') { + return $foil; + } + } } } @@ -740,7 +699,7 @@ sub verifyreceipt { my $title.= '

'. - &mt('Verifying Receipt No. [_1]',$receipt). + &mt('Verifying Submission Receipt [_1]',$receipt). '

'."\n". '

'.&mt('Resource: [_1]',$env{'form.probTitle'}). '

'."\n"; @@ -825,15 +784,17 @@ sub listStudents { &Apache::lonnet::gettitle($symb) : $env{'form.probTitle'}; my $result='

 '. - &mt("$viewgrade Submissions for a Student or a Group of Students") + &mt($viewgrade.' Submissions for a Student or a Group of Students') .'

'; my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes')); - my %lt = &Apache::lonlocal::texthash ( - '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.', - ); + my %lt = ( '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.", + ); + %lt = &Apache::lonlocal::texthash(%lt); $request->print(< function checkSelect(checkBox) { @@ -876,15 +837,17 @@ LISTJAVASCRIPT "\n".$table; $gradeTable .= - ' '.&mt('View Problem Text').': '. + ' '. + &mt('View Problem Text: [_1]', ''."\n". ''."\n". - '
'."\n"; + '').'
'."\n"; $gradeTable .= - ' '.&mt('View Answer').': '. + ' '. + &mt('View Answer: [_1]', ''."\n". ''."\n". - '
'."\n"; + '').'
'."\n"; my $submission_options; if ($env{'form.handgrade'} eq 'yes' && scalar(@$partlist) > 1) { @@ -900,16 +863,18 @@ LISTJAVASCRIPT ''."\n". ''; $gradeTable .= - ' '.&mt('Submissions').': '.$submission_options.'
'."\n"; + ' '. + &mt('Submissions: [_1]',$submission_options).'
'."\n"; $gradeTable .= - ' '.&mt('Grading Increments').': '. + ' '. + &mt('Grading Increments: [_1]', ''; + ''); $gradeTable .= &build_section_inputs(). @@ -928,14 +893,15 @@ LISTJAVASCRIPT &Apache::lonhtmlcommon::StatusOptions($saveStatus,undef,1,'javascript:reLoadList(this.form);')).'
'; } - $gradeTable.=&mt('To '.lc($viewgrade)." a submission or a group of submissions, click on the check box(es) next to the student's name(s). Then click on the Next button.").'
'."\n". + $gradeTable.=&mt('To '.lc($viewgrade).' a submission or a group of submissions, click on the check box(es) '. + 'next to the student\'s name(s). Then click on the Next button.').'
'."\n". ''."\n"; # checkall buttons $gradeTable.=&check_script('gradesub', 'stuinfo'); $gradeTable.='
'."\n"; + 'value="'.&mt('Next->').'" />
'."\n"; $gradeTable.=&check_buttons(); $gradeTable.=''; my ($classlist, undef, $fullname) = &getclasslist($getsec,'1',$getgroup); @@ -1055,7 +1021,7 @@ LISTJAVASCRIPT $gradeTable.=&Apache::loncommon::end_data_table()."\n". ''."\n"; + 'value="'.&mt('Next->').'" />'."\n"; if ($ctr == 0) { my $num_students=(scalar(keys(%$fullname))); if ($num_students eq 0) { @@ -1151,7 +1117,6 @@ sub processGroup { #--- Javascript to handle the submission page functionality --- sub sub_page_js { my $request = shift; - my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = '); $request->print(< function updateRadio(formname,id,weight) { @@ -1162,7 +1127,7 @@ sub sub_page_js { gradeBox.value = pts; var resetbox = false; if (isNaN(pts) || pts < 0) { - alert("$alertmsg"+pts); + alert("A number equal or greater than 0 is expected. Entered value = "+pts); for (var i=0; iprint(< @@ -1440,7 +1404,7 @@ INNERJS else return; var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," "); if (cleantxt=="") { - alert("$alertmsg"); + alert("Please select a word or group of words from document and then click this link."); return; } var nret = prompt("Add selection to keyword list? Edit if desired.",cleantxt); @@ -1695,7 +1659,7 @@ sub gradeBox { $wgt.')" />'."\n"; $line.='/'.$wgt.' '.$wgtmsg. ($$record{'resource.'.$partid.'.solved'} eq 'correct_by_student' ? ' '.$checkIcon : ''). - ' '.&mt('Grade Status').':'."\n"; + ' '."\n"; $line.=''."\n". @@ -2091,7 +2056,7 @@ KEYWORDS $lastsubonly.="\n".'
Part: '. $display_part.' ( ID '.$respid. ' )   '. - ''.&mt('Nothing submitted - no attempts.').'

'; + ''.&mt('Nothing submitted - no attempts').'

'; next; } foreach my $submission (@$string) { @@ -2132,7 +2097,7 @@ KEYWORDS ' )   '; my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); if (@$files) { - $lastsubonly.='
'.&mt('Like all files provided by users, this file may contain viruses').'
'; + $lastsubonly.='
'.&mt('Like all files provided by users, this file may contain virusses').'
'; my $file_counter = 0; foreach my $file (@$files) { $file_counter++; @@ -2143,7 +2108,7 @@ KEYWORDS } $lastsubonly.=''.&mt('Submitted Answer:').' '. &cleanRecord($subval,$responsetype,$symb,$partid, - $respid,\%record,$order,undef,$uname,$udom); + $respid,\%record,$order); if ($similar) {$lastsubonly.="

$similar\n";} $lastsubonly.=''; } @@ -2272,7 +2237,7 @@ KEYWORDS ''."\n"; my $nsel = ($env{'form.NTSTU'} ne '' ? $env{'form.NTSTU'} : '1'); $ntstu =~ s/