--- loncom/homework/grades.pm 2010/04/20 19:04:54 1.625 +++ loncom/homework/grades.pm 2011/04/06 13:50:38 1.647 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.625 2010/04/20 19:04:54 www Exp $ +# $Id: grades.pm,v 1.647 2011/04/06 13:50:38 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,10 +40,11 @@ use Apache::lonhomework; use Apache::lonpickcode; use Apache::loncoursedata; use Apache::lonmsg(); -use Apache::Constants qw(:common); +use Apache::Constants qw(:common :http); use Apache::lonlocal; use Apache::lonenc; use Apache::lonstathelpers; +use Apache::lonquickgrades; use String::Similarity; use LONCAPA; @@ -212,8 +213,13 @@ sub reset_caches { } sub get_analyze { - my ($symb,$uname,$udom,$no_increment,$add_to_hash)=@_; + my ($symb,$uname,$udom,$no_increment,$add_to_hash,$type,$trial,$rndseed)=@_; 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') { @@ -241,9 +247,15 @@ 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); @@ -256,15 +268,15 @@ sub reset_caches { } sub get_order { - my ($partid,$respid,$symb,$uname,$udom,$no_increment)=@_; - my $analyze = &get_analyze($symb,$uname,$udom,$no_increment); + my ($partid,$respid,$symb,$uname,$udom,$no_increment,$type,$trial,$rndseed)=@_; + my $analyze = &get_analyze($symb,$uname,$udom,$no_increment,undef,$type,$trial,$rndseed); return $analyze->{"$partid.$respid.shown"}; } 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); + 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); if (ref($foils) eq 'ARRAY') { foreach my $foil (@{$foils}) { if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') { @@ -306,7 +318,7 @@ sub reset_caches { # response types only. sub cleanRecord { my ($answer,$response,$symb,$partid,$respid,$record,$order,$version, - $uname,$udom) = @_; + $uname,$udom,$type,$trial,$rndseed) = @_; my $grayFont = ''; if ($response =~ /^(option|rank)$/) { my %answer=&Apache::lonnet::str2hash($answer); @@ -350,7 +362,7 @@ sub cleanRecord { my %answer=&Apache::lonnet::str2hash($answer); my ($toprow,$bottomrow); my $correct = - &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom); + &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom,$type,$trial,$rndseed); foreach my $foil (@$order) { if (exists($answer{$foil})) { if ($foil eq $correct) { @@ -820,9 +832,7 @@ sub listStudents { $submitonly= $env{'form.submitonly'} eq '' ? 'all' : $env{'form.submitonly'}; } - my $result='

 ' - .&mt("View/Grade/Regrade Submissions for a Student or a Group of Students") - .'

'; + my $result=''; my $res_error; my ($partlist,$handgrade,$responseType) = &response_type($symb,\$res_error); @@ -891,7 +901,7 @@ LISTJAVASCRIPT '
'."\n". ''. - ''."\n". ''. '   '; my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); if (@$files) { - if ($hide) { + 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').'
'; @@ -2186,12 +2200,12 @@ KEYWORDS } $lastsubonly.='
'; } - if ($hide) { + if ($hide eq 'anon') { $lastsubonly.=''.&mt('Anonymous Survey').''; } else { $lastsubonly.=''.&mt('Submitted Answer:').' '. &cleanRecord($subval,$responsetype,$symb,$partid, - $respid,\%record,$order,undef,$uname,$udom); + $respid,\%record,$order,undef,$uname,$udom,$type,$trial,$rndseed); } if ($similar) {$lastsubonly.="

$similar\n";} $lastsubonly.=''; @@ -2213,13 +2227,8 @@ KEYWORDS $request->print(''."\n"); # return if view submission with no grading option -# FIXME: the logic seems off here. Why show the grade button if you cannot grade? if (!&canmodify($usec)) { - my $toGrade.='  '."\n" if (&canmodify($usec)); - $toGrade.=''."\n"; - $request->print($toGrade); + $request->print('

'.&mt('No grading privileges').'

'); return; } else { $request->print(''."\n"); @@ -2337,10 +2346,10 @@ sub check_collaborators { next if ($record->{'resource.'.$part.'.collaborators'} eq ''); my (@good_collaborators, @bad_collaborators); foreach my $possible_collaborator - (split(/,?\s+/,$record->{'resource.'.$part.'.collaborators'})) { + (split(/[,;\s]+/,$record->{'resource.'.$part.'.collaborators'})) { $possible_collaborator =~ s/[\$\^\(\)]//g; next if ($possible_collaborator eq ''); - my ($co_name,$co_dom) = split(/\@|:/,$possible_collaborator); + my ($co_name,$co_dom) = split(/:/,$possible_collaborator); $co_dom = $udom if (! defined($co_dom) || $co_dom =~ /^domain$/i); next if ($co_name eq $uname && $co_dom eq $udom); # Doing this grep allows 'fuzzy' specification @@ -2353,13 +2362,13 @@ sub check_collaborators { } } if (scalar(@good_collaborators) != 0) { - $result.='
'.&mt('Collaborators: '); + $result.='
'.&mt('Collaborators:').'
    '; foreach my $name (@good_collaborators) { my ($lastname,$givenn) = split(/,/,$$fullname{$name}); push(@col_fullnames, $givenn.' '.$lastname); - $result.=$fullname->{$name}.'     '; + $result.='
  1. '.$fullname->{$name}.'
  2. '; } - $result.='
    '."\n"; + $result.='

'."\n"; my ($part)=split(/\./,$part); $result.=''. @@ -2395,35 +2404,51 @@ sub get_last_submission { &Apache::lonlocal::locallocaltime($$returnhash{$version.':timestamp'}); } } - my %typeparts; + my (%typeparts,%randombytry); 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 'anonsurveycred') || + ($lasthash{$key} eq 'randomizetry')) { my ($ign,@parts) = split(/\./,$key); pop(@parts); - unless ($showsurv) { - my $id = join(',',@parts); - $typeparts{$ign.'.'.$id} = $lasthash{$key}; + my $id = join('.',@parts); + if ($lasthash{$key} eq 'randomizetry') { + $randombytry{$ign.'.'.$id} = $lasthash{$key}; + } else { + unless ($showsurv) { + $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 = 1; + $hide = 'anon'; 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 ' : ''; @@ -2592,16 +2617,6 @@ sub processHandGrade { return ''; } -# Go directly to grade student - from submission or link from chart page -# FIXME: looks like reading off the button label! - if ($button eq 'Grade Student') { - my $processUser = $env{'form.unamedom'.$env{'form.studentNo'}}; - ($env{'form.student'},$env{'form.userdom'}) = split(/:/,$processUser); - $env{'form.fullname'} = $$fullname{$processUser}; - &submission($request,0,0,$symb); - return ''; - } - # Get the next/previous one or group of students my $firststu = $env{'form.unamedom0'}; my $laststu = $env{'form.unamedom'.($ngrade-1)}; @@ -2689,9 +2704,7 @@ sub processHandGrade { $ctr++; } if ($total < 0) { - my $the_end = '

'.&mt('LON-CAPA User Message').'


'."\n"; - $the_end.=&mt('Message: No more students for this section or class.').'

'."\n"; - $the_end.=&mt('Click on the button below to return to the grading menu.').'

'."\n"; + my $the_end.=&mt('Message: No more students for this section or class.').'

'."\n"; $request->print($the_end); } return ''; @@ -3371,6 +3384,9 @@ sub viewgrades { if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); } my ($partid) = &split_part_type($part); push(@partids,$partid); +# +# FIXME: Looks like $display looks at English text +# my $display_part=&get_display_part($partid,$symb); if ($display =~ /^Partial Credit Factor/) { $result.=''. @@ -3817,21 +3833,14 @@ sub csvuploadmap_header { $javascript=&csvupload_javascript_forward_associate(); } - my $result=''; - my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); - my $ignore=&mt('Ignore First Line'); $symb = &Apache::lonenc::check_encrypt($symb); + $request->print('
'. + &mt('Total number of records found in file: [_1]',$distotal).'
'. + &mt('Associate entries from the uploaded file with as many fields as you can.')); + my $reverse=&mt("Reverse Association"); $request->print(< -

Uploading Class Grades

-$result -
-

Identify fields

-Total number of records found in file: $distotal
-Enter as many fields as you can. The system will inform you and bring you back -to this page if the data selected is insufficient to run your class.
- - +
+ @@ -3904,11 +3913,11 @@ sub upcsvScores_form { my ($request,$symb) = @_; if (!$symb) {return '';} my $result=&checkforfile_js(); - $result.='
'."\n"; - $result.=''."\n"; - $result.=''. + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row().'
'."\n"; - $result.=' '.&mt('Specify a file containing the class scores for current resource.'). - '
'."\n"; + $result.=&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Specify a file containing the class scores for current resource.').''; my $upload=&mt("Upload Scores"); my $upfile_select=&Apache::loncommon::upfile_select_html(); my $ignore=&mt('Ignore First Line'); @@ -3919,13 +3928,13 @@ sub upcsvScores_form { $upfile_select
- ENDUPFORM $result.=&Apache::loncommon::help_open_topic("Course_Convert_To_CSV", - &mt("How do I create a CSV file from a spreadsheet")) - .'
'."\n"; - $result.='


'."\n"; + &mt("How do I create a CSV file from a spreadsheet")). + ''. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); return $result; } @@ -3942,7 +3951,6 @@ sub csvuploadmap { &Apache::loncommon::load_tmp_file($request); } my @records=&Apache::loncommon::upfile_record_sep(); - if ($env{'form.noFirstLine'}) { shift(@records); } &csvuploadmap_header($request,$symb,$datatoken,$#records+1); my ($i,$keyfields); if (@records) { @@ -3978,31 +3986,21 @@ sub csvuploadmap { sub csvuploadoptions { my ($request,$symb)= @_; - my $checked=(($env{'form.noFirstLine'})?'1':'0'); - my $ignore=&mt('Ignore First Line'); + my $overwrite=&mt('Overwrite any existing score'); $request->print(< -

Uploading Class Grade Options

-

ENDPICK my %fields=&get_fields(); if (!defined($fields{'domain'})) { my $domform = &Apache::loncommon::select_dom_form($env{'request.role.domain'},'default_domain'); - $request->print("\n

Users are in domain: ".$domform."

\n"); + $request->print("\n

".&mt('Users are in domain: [_1]',$domform)."

\n"); } foreach my $key (sort(keys(%env))) { if ($key !~ /^form\.(.*)$/) { next; } @@ -4041,9 +4039,7 @@ sub csvuploadassign { my $error_msg = ''; &Apache::loncommon::load_tmp_file($request); my @gradedata = &Apache::loncommon::upfile_record_sep(); - if ($env{'form.noFirstLine'}) { shift(@gradedata); } my %fields=&get_fields(); - $request->print('

Assigning Grades

'); my $courseid=$env{'request.course.id'}; my ($classlist) = &getclasslist('all',0); my @notallowed; @@ -4096,6 +4092,9 @@ sub csvuploadassign { my $pcr=$entries{$fields{$dest}} / $wgt; my $award=($pcr == 0) ? 'incorrect_by_override' : 'correct_by_override'; + if ($pcr>1) { + push(@skipped,&mt("[_1]: point value larger than weight","$username:$domain")); + } $grades{"resource.$part.awarded"}=$pcr; $grades{"resource.$part.solved"}=$award; $points{$part}=1; @@ -4123,14 +4122,20 @@ sub csvuploadassign { $env{'request.course.id'}, $domain,$username); if ($result eq 'ok') { +# Successfully stored $request->print('.'); - } else { +# Remove from grading queue + &Apache::bridgetask::remove_from_queue('gradingqueue',$symb, + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}, + $domain,$username); + $countdone++; + } else { $request->print("

". &mt("Failed to save data for student [_1]. Message when trying to save was: [_2]", "$username:$domain",$result)."

"); } $request->rflush(); - $countdone++; } } $request->print('
'.&Apache::lonhtmlcommon::confirm_success(&mt("Saved scores for [quant,_1,student]",$countdone),$countdone==0)); @@ -4395,8 +4400,8 @@ sub displayPage { &Apache::loncommon::start_data_table_row(). ''.$prob. (scalar(@{$parts}) == 1 ? '' - : '
('.&mt('[_1] parts)', - scalar(@{$parts})) + : '
('.&mt('[_1]parts)', + scalar(@{$parts}).' ') ). ''; $studentTable.=''; @@ -4490,6 +4495,7 @@ 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'}); @@ -4507,9 +4513,9 @@ sub displaySubByDates { my @versionKeys = split(/\:/,$$record{$version.':keys'}); my @displaySub = (); foreach my $partid (@{$parts}) { - my $hidden; - if (($$record{$version.':resource.'.$partid.'.type'} eq 'anonsurvey') || - ($$record{$version.':resource.'.$partid.'.type'} eq 'anonsurveycred')) { + my ($hidden,$type); + $type = $$record{$version.':resource.'.$partid.'.type'}; + if (($type eq 'anonsurvey') || ($type eq 'anonsurveycred')) { $hidden = 1; } my @matchKey = ($isTask ? sort(grep /^resource\.\d+\.\Q$partid\E\.award$/,@versionKeys) @@ -4532,23 +4538,34 @@ 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').')'; + } + } + $lastrndseed{$partid} = $rndseed; } my $responseType=($isTask ? 'Task' : $responseType->{$partid}->{$responseId}); if (!exists($orders{$partid})) { $orders{$partid}={}; } - if (!exists($orders{$partid}->{$responseId})) { + if ((!exists($orders{$partid}->{$responseId})) || ($trial)) { $orders{$partid}->{$responseId}= &get_order($partid,$responseId,$symb,$uname,$udom, - $no_increment); + $no_increment,$type,$trial,$rndseed); } - $displaySub[0].=''; # /nobreak + $displaySub[0].=''.$newvariation.''; # /nobreak $displaySub[0].='  '. - &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom).'
'; + &cleanRecord($$record{$version.':'.$matchKey},$responseType,$symb,$partid,$responseId,$record,$orders{$partid}->{$responseId},"$version:",$uname,$udom,$type,$trial,$rndseed).'
'; } } } @@ -4647,7 +4664,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.' '; @@ -6182,15 +6199,15 @@ sub scantron_do_warning { if ( $env{'form.selectpage'} eq '' || $env{'form.scantron_selectfile'} eq '' || $env{'form.scantron_format'} eq '' ) { - $r->print("

".&mt('You have forgetten to specify some information. Please go Back and try again.')."

"); + $r->print("

".&mt('You have forgotten to specify some information. Please go Back and try again.')."

"); if ( $env{'form.selectpage'} eq '') { $r->print('

'.&mt('You have not selected a Sequence to grade').'

'); } if ( $env{'form.scantron_selectfile'} eq '') { - $r->print('

'.&mt('You have not selected a file that contains the student\'s response data.').'

'); + $r->print('

'.&mt("You have not selected a file that contains the student's response data.").'

'); } if ( $env{'form.scantron_format'} eq '') { - $r->print('

'.&mt('You have not selected a the format of the student\'s response data.').'

'); + $r->print('

'.&mt("You have not selected the format of the student's response data.").'

'); } } else { my $warning=&scantron_warning_screen('Grading: Validate Records'); @@ -8413,32 +8430,32 @@ sub grading_menu { { linktext => 'Select individual students to grade', url => $url1a, permission => 'F', - icon => 'edit-find-replace.png', + icon => 'grade_students.png', linktitle => 'Grade current resource for a selection of students.' }, { linktext => 'Grade ungraded submissions.', url => $url1b, permission => 'F', - icon => 'edit-find-replace.png', + icon => 'ungrade_sub.png', linktitle => 'Grade all submissions that have not been graded yet.' }, { linktext => 'Grading table', url => $url1c, permission => 'F', - icon => 'edit-find-replace.png', + icon => 'grading_table.png', linktitle => 'Grade current resource for all students.' }, { linktext => 'Grade page/folder for one student', url => $url1d, permission => 'F', - icon => 'edit-find-replace.png', + icon => 'grade_PageFolder.png', linktitle => 'Grade all resources in current page/sequence/folder for one student.' }, { linktext => 'Download submissions', url => $url1e, permission => 'F', - icon => 'edit-find-replace.png', + icon => 'download_sub.png', linktitle => 'Download all students submissions.' }]}, { categorytitle=>'Automated Grading', @@ -8459,13 +8476,13 @@ sub grading_menu { { linktext => 'Grade/Manage/Review Bubblesheets', url => $url4, permission => 'F', - icon => 'stat.png', + icon => 'bubblesheet.png', linktitle => 'Grade scantron exams, upload/download scantron data files, and review previously graded scantron exams.' }, { linktext => 'Verify Receipt Number', url => $url5, permission => 'F', - icon => 'edit-find-replace.png', + icon => 'receipt_number.png', linktitle => 'Verify a system-generated receipt number for correct problem solution.' } @@ -8496,11 +8513,7 @@ sub submit_options_sequence { $result.='
'."\n". ''."\n"; - $result.=' -

- '.&mt('Grade page/folder for one student').' -

'. - &selectfield(0). + $result.=&selectfield(0). '
@@ -8519,11 +8532,7 @@ sub submit_options_table { $result.=''."\n". ''."\n"; - $result.=' -

- '.&mt('Grading table').' -

'. - &selectfield(0). + $result.=&selectfield(0). '
@@ -8565,10 +8574,7 @@ sub submit_options { $result.=''."\n". ''."\n"; - $result.=' -

- '.&mt('Select individual students to grade').' -

'.&selectfield(1).' + $result.=&selectfield(1).'
@@ -8581,6 +8587,14 @@ sub submit_options { sub selectfield { my ($full)=@_; + my %options = + (&Apache::lonlocal::texthash( + 'yes' => 'with submissions', + 'queued' => 'in grading queue', + 'graded' => 'with ungraded submissions', + 'incorrect' => 'with incorrect submissions', + 'all' => 'with any status'), + 'select_form_order' => ['yes','queued','graded','incorrect','all']); my $result='
@@ -8609,14 +8623,7 @@ sub selectfield { '.&mt('Submission Status').' '. - &Apache::loncommon::select_form('all','submitonly', - (&Apache::lonlocal::texthash( - 'yes' => 'with submissions', - 'queued' => 'in grading queue', - 'graded' => 'with ungraded submissions', - 'incorrect' => 'with incorrect submissions', - 'all' => 'with any status'), - 'select_form_order' => ['yes','queued','graded','incorrect','all'])). + &Apache::loncommon::select_form('all','submitonly',\%options). '
'; } $result.='

'; @@ -8710,11 +8717,11 @@ sub process_clicker { my ($r,$symb)=@_; if (!$symb) {return '';} my $result=&checkforfile_js(); - $result.='
'."\n"; - $result.=''."\n"; - $result.=''. + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row()."'.&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::start_data_table_row().''.&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::start_data_table_row().'
'."\n"; - $result.=' '.&mt('Specify a file containing the clicker information for this resource.'). - '
'."\n"; + $result.=&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Specify a file containing clicker information and set grading options.').'\n"; # Attempt to restore parameters from last session, set defaults if not present my %Saveable_Parameters=&clicker_grading_parameters(); &Apache::loncommon::restore_course_settings('grades_clicker', @@ -8731,7 +8738,7 @@ sub process_clicker { } } - my $upload=&mt("Upload File"); + my $upload=&mt("Evaluate File"); my $type=&mt("Type"); my $attendance=&mt("Award points just for participation"); my $personnel=&mt("Correctness determined from response by course personnel"); @@ -8741,8 +8748,8 @@ 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.= &Apache::lonhtmlcommon::scripttag(<
-
+ENDUPFORM + $result.='
'.(<$attendance

@@ -8797,13 +8807,17 @@ ENDUPFORM
    -
+ENDGRADINGFORM + $result.='
'.(<$pcorrect:

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


'."\n"; +ENDPERCFORM + $result.=''. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); return $result; } @@ -8827,7 +8841,7 @@ sub process_clicker_file { if ($env{'form.gradingmechanism'} eq 'given') { $env{'form.givenanswer'}=~s/^\s*//gs; $env{'form.givenanswer'}=~s/\s*$//gs; - $env{'form.givenanswer'}=~s/[^a-zA-Z0-9\.\*\-]+/\,/g; + $env{'form.givenanswer'}=~s/[^a-zA-Z0-9\.\*\-\+]+/\,/g; $env{'form.givenanswer'}=uc($env{'form.givenanswer'}); my @answers=split(/\,/,$env{'form.givenanswer'}); $foundgiven=$#answers+1; @@ -8883,11 +8897,12 @@ sub process_clicker_file { $result.=&Apache::loncommon::studentbrowser_javascript(); $symb = &Apache::lonenc::check_encrypt($symb); - my $heading=&mt('Scanning clicker file'); - $result.=(<
-'. + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row().(<
@@ -8935,7 +8950,9 @@ ENDHEADER } elsif ($clicker_ids{$id}) { if ($clicker_ids{$id}=~/\,/) { # More than one user with the same clicker! - $result.="\n
".&mt('Clicker registered more than once').": ".$id."
"; + $result.="".&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::start_data_table_row()."
".&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::start_data_table_row()."
-$heading
+ $result.=&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Evaluate clicker file').'". + &mt('Clicker registered more than once').": ".$id."
"; $result.="\n".''. "
". + &mt('Unregistered Clicker')." ".$id."
"; $result.="\n".''. "\n".&mt("Username").":  ". "\n".&mt("Domain").": ". &Apache::loncommon::select_dom_form($env{'course.'.$env{'request.course.id'}.'.domain'},'udom'.$id).' '. - &Apache::loncommon::selectstudent_link('clickeranalysis','uname'.$id,'udom'.$id); + &Apache::loncommon::selectstudent_link('clickeranalysis','uname'.$id,'udom'.$id,0,$id); $unknown_count++; } } @@ -8975,8 +8994,9 @@ ENDHEADER } else { $result.='
'; } - $result.='
'."\n". - '


'."\n"; + $result.=''. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); return $result; } @@ -8999,6 +9019,7 @@ sub iclicker_eval { $id=~s/^[\#0]+//; for (my $i=0;$i<$number;$i++) { my $idx=3+$i*6; + $entries[$idx]=~s/[^a-zA-Z0-9\.\*\-\+]+//g; push(@idresponses,$entries[$idx]); } $$responses{$id}=join(',',@idresponses); @@ -9050,14 +9071,11 @@ sub assign_clicker_grades { # FIXME: This should probably look for the first handgradeable part my $part=$$partlist[0]; # Start screen output - my $result=''; - - my $heading=&mt('Assigning grades based on clicker file'); - $result.=(<
-'. + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row().'
-$heading
-ENDHEADER + my $result=&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Assigning grades based on clicker file').''; # Get correct result # FIXME: Possibly need delimiter other than ":" my @correct=(); @@ -9073,25 +9091,26 @@ ENDHEADER $result.='
'. &mt('More than one correct result given for question "[_1]": [_2] versus [_3].', $env{'form.question:'.$i},$correct[$i],$input[$i]).''; - } elsif ($input[$i]) { + } elsif (($input[$i]) || ($input[$i] eq '0')) { $correct[$i]=$input[$i]; } } } } for (my $i=0;$i<$number;$i++) { - if (!$correct[$i]) { + if ((!$correct[$i]) && ($correct[$i] ne '0')) { $result.='
'. &mt('No correct result given for question "[_1]"!', $env{'form.question:'.$i}).''; } } - $result.='
'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct)); + $result.='
'.&mt("Correct answer: [_1]",join(', ',map { ((($_) || ($_ eq '0'))?$_:'-') } @correct)); } # Start grading my $pcorrect=$env{'form.pcorrect'}; my $pincorrect=$env{'form.pincorrect'}; my $storecount=0; + my %users=(); foreach my $key (keys(%env)) { my $user=''; if ($key=~/^form\.student\:(.*)$/) { @@ -9105,24 +9124,42 @@ ENDHEADER $user=$env{'form.multi'.$id}; } } - if ($user) { + if ($user) { + if ($users{$user}) { + $result.='
'. + &mt("More than one entry found for [_1]!",$user). + '
'; + } + $users{$user}=1; my @answer=split(/\,/,$env{$key}); my $sum=0; my $realnumber=$number; for (my $i=0;$i<$number;$i++) { if ($correct[$i] eq '-') { $realnumber--; - } elsif ($answer[$i]) { + } elsif (($answer[$i]) || ($answer[$i]=~/^[0\.]+$/)) { if ($gradingmechanism eq 'attendance') { $sum+=$pcorrect; } elsif ($correct[$i] eq '*') { $sum+=$pcorrect; } else { - if ($answer[$i] eq $correct[$i]) { - $sum+=$pcorrect; - } else { - $sum+=$pincorrect; +# We actually grade if correct or not + my $increment=$pincorrect; +# Special case: numerical answer "0" + if ($correct[$i] eq '0') { + if ($answer[$i]=~/^[0\.]+$/) { + $increment=$pcorrect; + } +# General numerical answer, both evaluate to something non-zero + } elsif ((1.0*$correct[$i]!=0) && (1.0*$answer[$i]!=0)) { + if (1.0*$correct[$i]==1.0*$answer[$i]) { + $increment=$pcorrect; + } +# Must be just alphanumeric + } elsif ($answer[$i] eq $correct[$i]) { + $increment=$pcorrect; } + $sum+=$increment; } } } @@ -9145,8 +9182,9 @@ ENDHEADER } # We are done $result.='
'.&mt('Successfully stored grades for [quant,_1,student].',$storecount). - '
'."\n". - '


'."\n"; + ''. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); return $result; } @@ -9162,6 +9200,7 @@ sub startpage { unshift(@$crumbs,{href=>&href_symb_cmd($symb,'gradingmenu'),text=>"Grading"}); $r->print(&Apache::loncommon::start_page('Grading',undef, {'bread_crumbs' => $crumbs})); + &Apache::lonquickgrades::startGradeScreen($r,($env{'form.symb'}?'probgrading':'grading')); unless ($nodisplayflag) { $r->print(&Apache::lonhtmlcommon::resource_info_box($symb,$onlyfolderflag)); } @@ -9169,7 +9208,7 @@ sub startpage { sub select_problem { my ($r)=@_; - $r->print('

'.&mt('Select the problem or one of the problems you want to grade').'

'); + $r->print('

'.&mt('Select the problem or one of the problems you want to grade').'

'); $r->print(&Apache::lonstathelpers::problem_selector('.',undef,1)); $r->print(''); $r->print('
'); @@ -9178,15 +9217,25 @@ sub select_problem { sub handler { my $request=$_[0]; &reset_caches(); - if ($env{'browser.mathml'}) { - &Apache::loncommon::content_type($request,'text/xml'); - } else { - &Apache::loncommon::content_type($request,'text/html'); + if ($request->header_only) { + &Apache::loncommon::content_type($request,'text/html'); + $request->send_http_header; + return OK; } - $request->send_http_header; - return '' if $request->header_only; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); + &init_perm(); + if (!$env{'request.course.id'}) { + # Not in a course. + $env{'user.error.msg'}="/adm/grades::vgr:0:0:Cannot display grades page outside course context"; + return HTTP_NOT_ACCEPTABLE; + } elsif (!%perm) { + $request->internal_redirect('/adm/quickgrades'); + } + &Apache::loncommon::content_type($request,'text/html'); + $request->send_http_header; + + # see what command we need to execute my @commands=&Apache::loncommon::get_env_multiple('form.command'); @@ -9203,17 +9252,16 @@ sub handler { (my $url=$env{'form.url'}) =~ s-^https*://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; $symb=&Apache::lonnet::symbread($url); } - &Apache::lonenc::check_decrypt(\$symb); + &Apache::lonenc::check_decrypt(\$symb); $ssi_error = 0; - if ($symb eq '' || $command eq '') { + if (($symb eq '' || $command eq '') && ($env{'request.course.id'})) { # -# Not called from a resource +# Not called from a resource, but inside a course # &startpage($request,undef,[],1,1); &select_problem($request); } else { - &init_perm(); if ($command eq 'submission' && $perm{'vgr'}) { &startpage($request,$symb,[{href=>"", text=>"Student Submissions"}]); ($env{'form.student'} eq '' ? &listStudents($request,$symb) : &submission($request,0,0,$symb)); @@ -9285,17 +9333,17 @@ sub handler { {href=>'', text=>'Store grades'}]); $request->print(&assign_clicker_grades($request,$symb)); } elsif ($command eq 'csvform' && $perm{'mgr'}) { - &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1); + &startpage($request,$symb,[{href=>'', text=>'Upload Scores'}],1,1); $request->print(&upcsvScores_form($request,$symb)); } elsif ($command eq 'csvupload' && $perm{'mgr'}) { - &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1); + &startpage($request,$symb,[{href=>'', text=>'Upload Scores'}],1,1); $request->print(&csvupload($request,$symb)); } elsif ($command eq 'csvuploadmap' && $perm{'mgr'} ) { - &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1); + &startpage($request,$symb,[{href=>'', text=>'Upload Scores'}],1,1); $request->print(&csvuploadmap($request,$symb)); } elsif ($command eq 'csvuploadoptions' && $perm{'mgr'}) { if ($env{'form.associate'} ne 'Reverse Association') { - &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1); + &startpage($request,$symb,[{href=>'', text=>'Upload Scores'}],1,1); $request->print(&csvuploadoptions($request,$symb)); } else { if ( $env{'form.upfile_associate'} ne 'reverse' ) { @@ -9303,11 +9351,11 @@ sub handler { } else { $env{'form.upfile_associate'} = 'forward'; } - &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1); + &startpage($request,$symb,[{href=>'', text=>'Upload Scores'}],1,1); $request->print(&csvuploadmap($request,$symb)); } } elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) { - &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1); + &startpage($request,$symb,[{href=>'', text=>'Upload Scores'}],1,1); $request->print(&csvuploadassign($request,$symb)); } elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) { &startpage($request,$symb,[{href=>'', text=>'Grade/Manage/Review Bubblesheets'}],1,1); @@ -9354,9 +9402,10 @@ sub handler { if ($ssi_error) { &ssi_print_error($request); } + &Apache::lonquickgrades::endGradeScreen($request); $request->print(&Apache::loncommon::end_page()); &reset_caches(); - return ''; + return OK; } 1; 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.