--- loncom/homework/grades.pm 2010/04/20 23:29:22 1.628 +++ loncom/homework/grades.pm 2010/12/04 15:02:26 1.639 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.628 2010/04/20 23:29:22 www Exp $ +# $Id: grades.pm,v 1.639 2010/12/04 15:02:26 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -44,6 +44,7 @@ use Apache::Constants qw(:common); use Apache::lonlocal; use Apache::lonenc; use Apache::lonstathelpers; +use Apache::lonquickgrades; use String::Similarity; use LONCAPA; @@ -820,9 +821,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); @@ -1269,12 +1268,6 @@ sub sub_page_js { } } - if (val == "Grade Student") { - if (formname.Status.value == "") { - formname.Status.value = "Active"; - } - formname.studentNo.value = total; - } formname.submit(); } @@ -1323,7 +1316,8 @@ sub sub_page_kw_js { my $iconpath = $request->dir_config('lonIconsURL'); &commonJSfunctions($request); - my $inner_js_msg_central= &Apache::lonhtmlcommon::scripttag(< function checkInput() { opener.document.SCORE.msgsub.value = opener.checkEntities(document.msgcenter.msgsub.value); var nmsg = opener.document.SCORE.savemsgN.value; @@ -1360,9 +1354,11 @@ sub sub_page_kw_js { self.close() } + INNERJS - my $inner_js_highlight_central= &Apache::lonhtmlcommon::scripttag(< function updateChoice(flag) { opener.document.SCORE.kwclr.value = opener.radioSelection(document.hlCenter.kwdclr); opener.document.SCORE.kwsize.value = opener.radioSelection(document.hlCenter.kwdsize); @@ -1373,6 +1369,7 @@ INNERJS } self.close() } + INNERJS my $start_page_msg_central = @@ -1909,7 +1906,6 @@ sub submission { if ($counter == 0) { &sub_page_js($request); &sub_page_kw_js($request); - $request->print('

 '.&mt('Submission Record').'

'); # option to display problem, only once else it cause problems # with the form later since the problem has a form. @@ -2213,13 +2209,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 +2328,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 +2344,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.=''. @@ -2592,16 +2583,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 +2670,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 ''; @@ -3820,18 +3799,14 @@ sub csvuploadmap_header { $javascript=&csvupload_javascript_forward_associate(); } - my $result=''; $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 +3879,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'); @@ -3922,9 +3897,10 @@ $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; } @@ -3976,29 +3952,21 @@ sub csvuploadmap { sub csvuploadoptions { my ($request,$symb)= @_; + 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; } @@ -4038,7 +4006,6 @@ sub csvuploadassign { &Apache::loncommon::load_tmp_file($request); my @gradedata = &Apache::loncommon::upfile_record_sep(); my %fields=&get_fields(); - $request->print('

Assigning Grades

'); my $courseid=$env{'request.course.id'}; my ($classlist) = &getclasslist('all',0); my @notallowed; @@ -4091,6 +4058,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; @@ -8414,32 +8384,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', @@ -8460,13 +8430,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.' } @@ -8497,11 +8467,7 @@ sub submit_options_sequence { $result.='
'."\n". ''."\n"; - $result.=' -

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

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

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

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

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

'.&selectfield(1).' + $result.=&selectfield(1).'
@@ -8582,6 +8541,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='
@@ -8610,14 +8577,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.='

'; @@ -8711,11 +8671,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', @@ -8732,7 +8692,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"); @@ -8742,8 +8702,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

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

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


'."\n"; +ENDPERCFORM + $result.=''. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); return $result; } @@ -8884,11 +8851,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().(<
@@ -8936,7 +8904,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").": ". @@ -8976,8 +8948,9 @@ ENDHEADER } else { $result.='
'; } - $result.='
'."\n". - '


'."\n"; + $result.=''. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); return $result; } @@ -9051,14 +9024,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=(); @@ -9093,6 +9063,7 @@ ENDHEADER 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\:(.*)$/) { @@ -9106,7 +9077,13 @@ 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; @@ -9146,8 +9123,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; } @@ -9163,6 +9141,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,'grading'); unless ($nodisplayflag) { $r->print(&Apache::lonhtmlcommon::resource_info_box($symb,$onlyfolderflag)); } @@ -9170,7 +9149,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('
'); @@ -9207,9 +9186,9 @@ sub handler { &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); @@ -9355,6 +9334,7 @@ sub handler { if ($ssi_error) { &ssi_print_error($request); } + &Apache::lonquickgrades::endGradeScreen($request); $request->print(&Apache::loncommon::end_page()); &reset_caches(); return '';