--- loncom/homework/grades.pm 2003/03/27 21:26:07 1.78 +++ loncom/homework/grades.pm 2003/03/28 23:44:31 1.81 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.78 2003/03/27 21:26:07 albertel Exp $ +# $Id: grades.pm,v 1.81 2003/03/28 23:44:31 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -343,8 +343,8 @@ LISTJAVASCRIPT my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked'; my $gradeTable='
'."\n". - ' View Problem: no '."\n". - ' one student '."\n". + ' View Problem: no '."\n". + ' one student '."\n". ' all students
'."\n". ' Submissions: '."\n"; if ($ENV{'form.handgrade'} eq 'yes') { @@ -628,6 +628,7 @@ SUBJAVASCRIPT #--- javascript for essay type problem -- sub sub_page_kw_js { my $request = shift; + my $iconpath = $request->dir_config('lonIconsURL'); $request->print(< @@ -675,6 +676,12 @@ sub sub_page_kw_js { } //====================== Script for composing message ============== + // preload images + img1 = new Image(); + img1.src = "$iconpath/mailbkgrd.gif"; + img2 = new Image(); + img2.src = "$iconpath/mailto.gif"; + function msgCenter(msgform,usrctr,fullname) { var Nmsg = msgform.savemsgN.value; savedMsgHeader(Nmsg,usrctr,fullname); @@ -729,17 +736,26 @@ sub sub_page_kw_js { pDoc.write(" if (document.msgcenter.subchk.checked) {"); pDoc.write(" msgchk = \\"msgsub,\\";"); pDoc.write(" }"); - pDoc.write( "for (var i=1; i<=nmsg; i++) {"); + pDoc.write(" var includemsg = 0;"); + pDoc.write(" for (var i=1; i<=nmsg; i++) {"); pDoc.write(" var opnmsg = eval(\\"opener.document.SCORE.savemsg\\"+i);"); pDoc.write(" var frmmsg = eval(\\"document.msgcenter.msg\\"+i);"); pDoc.write(" opnmsg.value = frmmsg.value;"); pDoc.write(" var chkbox = eval(\\"document.msgcenter.msgn\\"+i);"); pDoc.write(" if (chkbox.checked) {"); pDoc.write(" msgchk += \\"savemsg\\"+i+\\",\\";"); + pDoc.write(" includemsg = 1;"); pDoc.write(" }"); pDoc.write(" }"); pDoc.write(" if (document.msgcenter.newmsgchk.checked) {"); pDoc.write(" msgchk += \\"newmsg\\"+usrctr;"); + pDoc.write(" includemsg = 1;"); + pDoc.write(" }"); + pDoc.write(" imgformname = eval(\\"opener.document.SCORE.mailicon\\"+usrctr);"); + pDoc.write(" if (includemsg) {"); + pDoc.write(" imgformname.src = \\"$iconpath/mailto.gif\\";"); + pDoc.write(" } else {"); + pDoc.write(" imgformname.src = \\"$iconpath/mailbkgrd.gif\\";"); pDoc.write(" }"); pDoc.write(" var includemsg = eval(\\"opener.document.SCORE.includemsg\\"+usrctr);"); pDoc.write(" includemsg.value = msgchk;"); @@ -1030,7 +1046,7 @@ sub submission { $request->print(''."\n". ''."\n". - ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". @@ -1054,7 +1070,9 @@ sub submission { my ($cts,$prnmsg) = (1,''); while ($cts <= $ENV{'form.savemsgN'}) { $prnmsg.=''."\n"; $cts++; } @@ -1095,7 +1113,7 @@ KEYWORDS my ($classlist,$fullname); if ($ENV{'form.handgrade'} eq 'yes') { my @col_list; - ($classlist,undef,$fullname) = &getclasslist('all',$ENV{'form.showgrading'} eq 'yes' ? '1' : '0'); + ($classlist,undef,$fullname) = &getclasslist('all','0'); for (keys (%$handgrade)) { my $ncol = &Apache::lonnet::EXT('resource.'.$_. '.maxcollaborators', @@ -1103,20 +1121,26 @@ KEYWORDS next if ($ncol <= 0); s/\_/\./g; next if ($record{'resource.'.$_.'.collaborators'} eq ''); - my (@collaborators) = split(/,?\s+/, + my (@colList) = split(/,?\s+/, $record{'resource.'.$_.'.collaborators'}); + my @collaborators = (); + foreach (@colList) { #pre-filter list - throw out submitter + my ($co_name,$co_dom) = split /\@|:/,$_; + $co_dom = $udom if (! defined($co_dom)); + next if ($co_name eq $uname && $co_dom eq $udom); + push @collaborators, $_; + } my (@badcollaborators); if (scalar(@collaborators) != 0) { $result.='Collaborators: '; foreach my $collaborator (@collaborators) { my ($co_name,$co_dom) = split /\@|:/,$collaborator; $co_dom = $udom if (! defined($co_dom)); - next if ($co_name eq $uname && $co_dom eq $udom); # Doing this grep allows 'fuzzy' specification - my @Matches = grep /^$co_name:$co_dom/i, + my @Matches = grep /^$co_name:$co_dom$/i, keys %$classlist; - if (! scalar(@Matches)) { - push @badcollaborators,$collaborator; + if (! scalar(@Matches)) { + push @badcollaborators,':'.$collaborator.':'; next; } push @col_list, @Matches; @@ -1229,7 +1253,9 @@ KEYWORDS $result.=''."\n". ' '. - 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').''. + 'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'  '. + ''."\n". '
 (Message will be sent when you click on Save & Next below.)'."\n" if ($ENV{'form.handgrade'} eq 'yes'); $request->print($result); @@ -1348,7 +1374,6 @@ sub processHandGrade { $ctr++; next; } - my $includemsg = $ENV{'form.includemsg'.$ctr}; my ($subject,$message,$msgstatus) = ('','',''); if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) { @@ -1357,9 +1382,11 @@ sub processHandGrade { foreach (@msgnum) { $message.=$ENV{'form.'.$_} if ($_ =~ /savemsg|newmsg/ && $_ ne ''); } - $message =~ s/<([^>]|\n)*>//g; # removes html codes Or should this be lonnet::escape ?? + $message =&Apache::lonfeedback::clear_out_html($message); $message.="\n\nPoint".($pts > 1 ? 's':'').' awarded = '.$pts.' out of '.$wgt; - $message.=" for $ENV{'form.probTitle'}"; + $message.=" for $ENV{'form.probTitle'}"; $msgstatus = &Apache::lonmsg::user_normal_msg ($uname,$udom, $ENV{'form.msgsub'},$message); } @@ -2343,7 +2370,7 @@ LISTJAVASCRIPT my $result='

 '. 'Manual Grading by Page or Sequence

'; - $result.=''."
\n"; + $result.=''."\n"; $result.=' Problems from: '."\n". ''."\n". ''."\n". - ''."

\n". - ''."\n"; + ''."\n". + ''."
\n"; - $result.='
 
'."\n"; $request->print($result); @@ -2418,8 +2445,7 @@ LISTJAVASCRIPT sub getSymbMap { my ($request) = @_; - my $navmap = Apache::lonnavmaps::navmap-> new($request, - $ENV{'request.course.fn'}.'.db', + my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db', $ENV{'request.course.fn'}.'_parms.db',1, 1); my $res = $navmap->firstResource(); # temp resource to access constants @@ -2494,8 +2520,7 @@ sub displayPage { &sub_page_js($request); $request->print($result); - my $navmap = Apache::lonnavmaps::navmap-> new($request, - $ENV{'request.course.fn'}.'.db', + my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db', $ENV{'request.course.fn'}.'_parms.db',1, 1); my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps @@ -2542,8 +2567,8 @@ sub displayPage { } else { my $companswer = &Apache::loncommon::get_student_answers( $symbx,$uname,$udom,$ENV{'request.course.id'}); - $companswer=~s|||g; - $companswer=~s|||g; + $companswer =~ s|||g; + $companswer =~ s|||g; # while ($companswer =~ /()/s) { #Trial '.$version.' Part '.$partid.'  ' - .$record{$version.':'.$matchKey[0]}.'
' : ''; + 'Part '.$partid.' '. + ($record{"$version:resource.$partid.tries"} eq '' ? 'Trial not counted' : + 'Trial '.$record{"$version:resource.$partid.tries"}).'  '. + $record{$version.':'.$matchKey[0]}.'
' : ''; $displaySub[1].=(exists $record{"$version:resource.$partid.award"}) ? 'Part '.$partid.'  '. $record{"$version:resource.$partid.award"}.'/'. @@ -2650,8 +2677,7 @@ sub updateGradeByPage { $request->print($result); - my $navmap = Apache::lonnavmaps::navmap-> new($request, - $ENV{'request.course.fn'}.'.db', + my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db', $ENV{'request.course.fn'}.'_parms.db',1, 1); my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'}); my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps @@ -2753,6 +2779,15 @@ sub updateGradeByPage { # #------ start of section for handling grading by page/sequence --------- +sub defaultFormData { + my ($symb,$url)=@_; + return ' + '."\n". + ''."\n". + ''."\n". + ''."\n"; +} + sub getSequenceDropDown { my ($request,$symb)=@_; my $result=''; + opendir(DIR,$Apache::lonnet::perlvar{'lonScansDir'}); + my @files=sort(readdir(DIR)); + foreach my $filename (@files) { + if ($filename eq '.' or $filename eq '..') { next; } + $result.="\n"; + } + closedir(DIR); + $result.=""; + return $result; +} + sub scantron_selectphase { my ($r) = @_; my ($symb,$url)=&get_symb_and_url($r); if (!$symb) {return '';} my $sequence_selector=&getSequenceDropDown($r,$symb); + my $default_form_data=&defaultFormData($symb,$url); + my $grading_menu_button=&show_grading_menu_form($symb,$url); + my $file_selector=&scantron_uploads(); my $result; $result.= < - - + $default_form_data
@@ -2797,12 +2848,7 @@ sub scantron_selectphase {
- - Filename of scoring office file: - + Filename of scoring office file: $file_selector
@@ -2811,6 +2857,7 @@ sub scantron_selectphase { +$grading_menu_button SCANTRONFORM return $result; @@ -2818,12 +2865,44 @@ SCANTRONFORM sub scantron_configphase { my ($r) = @_; - my $sequence=$ENV{'form.selectpage'}; + my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'}); my $result; - $result.="got page $sequence"; - $Apache::lonxml::debug=1; - &Apache::lonhomework::showhash(%ENV); - $Apache::lonxml::debug=0; + my ($symb,$url)=&get_symb_and_url($r); + if (!$symb) {return '';} + my $default_form_data=&defaultFormData($symb,$url); + my $grading_menu_button=&show_grading_menu_form($symb,$url); + my $file_selector; + $result.= < + + $default_form_data + + + + +
+ + + + + + + + + + +
+  Select a format for the data file. +
+ Format of data file: +
+ Filename of scoring office file: $file_selector +
+
+ + +$grading_menu_button +SCANTRONFORM #FIXME Needs to present some lines from the file and allow the instructor to specify which columns represent what data, possibly have some nice defaults setup, probably should do a pass through all problems for a student to get an idea of how many questions there are, and homw many lines we'll have, return $result; } @@ -3062,7 +3141,8 @@ GRADINGMENUJS 'Upload scores from file'."\n"; $result.=''. - ' '. + ' '. 'Grade scantron forms'."\n"; if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {