--- loncom/homework/grades.pm 2003/03/23 08:10:30 1.75 +++ loncom/homework/grades.pm 2003/03/24 21:03:54 1.76 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.75 2003/03/23 08:10:30 albertel Exp $ +# $Id: grades.pm,v 1.76 2003/03/24 21:03:54 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -113,7 +113,7 @@ sub response_type { #--- Dumps the class list with usernames,list of sections, #--- section, ids and fullnames for each user. sub getclasslist { - my ($getsec,$hideexpired) = @_; + my ($getsec,$filterlist) = @_; my $classlist=&Apache::loncoursedata::get_classlist(); # Bail out if we were unable to get the classlist return if (! defined($classlist)); @@ -124,11 +124,13 @@ sub getclasslist { # the following undefs are for 'domain', and 'username' respectively. my (undef,undef,$end,$start,$id,$section,$fullname,$status)= @{$classlist->{$_}}; - # still a student? - if (($hideexpired) && ($status ne 'Active')) { - delete ($classlist->{$_}); - next; - } + # filter students according to status selected + if ($filterlist && $ENV{'form.saveStatus'} ne 'Any') { + if ($ENV{'form.saveStatus'} ne $status) { + delete ($classlist->{$_}); + next; + } + } $section = ($section ne '' ? $section : 'no'); if ($getsec eq 'all' || $getsec eq $section) { $sections{$section}++; @@ -209,8 +211,10 @@ sub jscriptNform { $jscript.= '
'."\n". ''."\n". ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". @@ -300,6 +304,8 @@ sub listStudents { $result.=''; my $viewgrade = $ENV{'form.handgrade'} eq 'yes' ? 'View/Grade' : 'View'; + $ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ? + &Apache::lonnet::gettitle($symb) : $ENV{'form.probTitle'}; $result='

 '. $viewgrade. @@ -355,8 +361,10 @@ LISTJAVASCRIPT ''."\n". '
'."\n". '
'."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". @@ -368,7 +376,7 @@ LISTJAVASCRIPT 'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n". 'value="'.$viewgrade.'" />'."\n"; - my (undef,undef,$fullname) = &getclasslist($getsec,'0'); + my (undef,undef,$fullname) = &getclasslist($getsec,$ENV{'form.showgrading'} eq 'yes' ? '1' : '0'); $gradeTable.='
'. ''. @@ -631,8 +639,7 @@ sub sub_page_kw_js { //===================== Show list of keywords ==================== function keywords(keyform) { - var keywds = keyform.value; - var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keywds); + var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value); if (nret==null) return; keyform.value = nret; @@ -701,91 +708,97 @@ sub sub_page_kw_js { return; } +// var pWin = null; function savedMsgHeader(Nmsg,usrctr,fullname) { - var height = 50*Nmsg+250; + var height = 70*Nmsg+250; var scrollbar = "no"; if (height > 600) { height = 600; scrollbar = "yes"; } -/* if (window.pWin) - window.pWin.close(); */ +// if (window.pWin) window.pWin.close(); pWin = window.open('', 'MessageCenter', 'toolbar=no,location=no,scrollbars='+scrollbar+',screenx=70,screeny=75,width=600,height='+height); - pWin.document.write(""); - pWin.document.write("Message Central"); - - pWin.document.write(" @@ -985,6 +1003,9 @@ sub submission { if ($counter == 0) { &sub_page_js($request); &sub_page_kw_js($request); + $ENV{'form.probTitle'} = $ENV{'form.probTitle'} eq '' ? + &Apache::lonnet::gettitle($symb) : $ENV{'form.probTitle'}; + $request->print('

 Submission Record

'."\n". ' Problem: '.$ENV{'form.probTitle'}.''."\n"); @@ -1015,8 +1036,10 @@ sub submission { $request->print(''."\n". ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n". @@ -1081,7 +1104,7 @@ KEYWORDS my ($classlist,$fullname); if ($ENV{'form.handgrade'} eq 'yes') { my @col_list; - ($classlist,undef,$fullname) = &getclasslist('all','0'); + ($classlist,undef,$fullname) = &getclasslist('all',$ENV{'form.showgrading'} eq 'yes' ? '1' : '0'); for (keys (%$handgrade)) { my $ncol = &Apache::lonnet::EXT('resource.'.$_. '.maxcollaborators', @@ -1126,7 +1149,7 @@ KEYWORDS } if (scalar(@collaborators > $ncol)) { $result .= '
'; - $result .= 'This student has sumbitted too many '. + $result .= 'This student has submitted too many '. 'collaborators. Maximum is '.$ncol; $result .= '
'; } @@ -1715,8 +1738,10 @@ sub viewgrades { ''."\n". ''."\n". ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". ''."\n"; $result.='

Assign Common Grade To '; @@ -1807,7 +1832,7 @@ sub viewgrades { #get info for each student #list all the students - with points and grade status - my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0'); + my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1'); my $ctr = 0; foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) { my ($uname,$udom) = split(/:/); @@ -2018,48 +2043,6 @@ sub split_part_type { # #-------------------------- Next few routines handles grading by csv upload # -#--- Menu to upload a csv scores --- -sub upcsvScores_form { - my ($request) = shift; - my ($symb,$url)=&get_symb_and_url($request); - if (!$symb) {return '';} - my $result =< - function checkUpload(formname) { - if (formname.upfile.value == "") { - alert("Please use the browse button to select a file from your local directory."); - return false; - } - formname.submit(); - if (navigator.appName !="Netscape") {self.close()}; //if netscape if appears to close before submit!!! - // any suggestion how to get around this?? - } - -CSVFORMJS - $ENV{'form.probTitle'} = &Apache::lonnet::gettitle($symb); - $result.='
'."\n"; - $result.=''."\n"; - $result.='
'."\n"; - $result.=' Specify a file containing the class scores for problem - '.$ENV{'form.probTitle'}. - '.
'."\n"; - my $upfile_select=&Apache::loncommon::upfile_select_html(); - $result.=< - - - - -$upfile_select -
  - - - -ENDUPFORM - $result.='
'."\n"; - $result.='
'."\n"; - return $result; -} - #--- Javascript to handle csv upload sub csvupload_javascript_reverse_associate { return(< - - + + + +
@@ -2323,8 +2308,7 @@ sub pickStudentPage { @@ -2398,15 +2390,17 @@ LISTJAVASCRIPT ''."\n". ''."\n". ''."

\n". - ''."\n". - ''."\n"; + ''."\n". + ''."\n". + ''."\n". + ''."\n"; $result.='
 
'."\n"; $request->print($result); - my $studentTable.=' Select a Student you wish to grade
'. + my $studentTable.=' Select a student you wish to grade
'. '
'. ''. ''. @@ -2414,7 +2408,7 @@ LISTJAVASCRIPT ''. ''; - my (undef,undef,$fullname) = &getclasslist($getsec,'0'); + my (undef,undef,$fullname) = &getclasslist($getsec,'1'); my $ptr = 1; foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) { my ($uname,$udom) = split(/:/,$student); @@ -2505,7 +2499,7 @@ sub displayPage { my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"}; my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'}; my $pageTitle = $ENV{'form.page'}; - my (undef,undef,$fullname) = &getclasslist($getsec,'0'); + my (undef,undef,$fullname) = &getclasslist($getsec,'1'); my ($uname,$udom) = split(/:/,$ENV{'form.student'}); my $result='

 '.$ENV{'form.title'}.'

'; @@ -2531,8 +2525,10 @@ sub displayPage { ''."\n". ''."\n". ''."\n". - ''."\n". - ''."\n"; + ''."\n". + ''."\n". + ''."\n". + ''."\n"; my $checkIcon = ''; @@ -2594,6 +2590,8 @@ sub displayPage { my @displaySub = (); foreach my $partid (@{$parts}) { my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys; + next if ($record{"$version:resource.$partid.award"} eq 'APPROX_ANS' && + $record{"$version:resource.$partid.solved"} eq ''); $displaySub[0].=(exists $record{$version.':'.$matchKey[0]}) ? 'Part: '.$partid.' Submission: ' .$record{$version.':'.$matchKey[0]}.'
' : ''; @@ -2660,7 +2658,7 @@ sub updateGradeByPage { my $cnum = $ENV{"course.$ENV{'request.course.id'}.num"}; my $getsec = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'}; my $pageTitle = $ENV{'form.page'}; - my (undef,undef,$fullname) = &getclasslist($getsec,'0'); + my (undef,undef,$fullname) = &getclasslist($getsec,'1'); my ($uname,$udom) = split(/:/,$ENV{'form.student'}); my $result='

 '.$ENV{'form.title'}.'

'; @@ -2755,11 +2753,11 @@ sub updateGradeByPage { } $studentTable.='
 Fullname (username) Fullname (username) Fullname (username)
'; - $studentTable.=($changeflag == 0 ? 'No score was changed or updated.' : - 'The scores were changed for '. - $changeflag.' problem'.($changeflag == 1 ? '.' : 's.')); $studentTable.=&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'}); - $request->print($studentTable); + my $grademsg=($changeflag == 0 ? 'No score was changed or updated.' : + 'The scores were changed for '. + $changeflag.' problem'.($changeflag == 1 ? '.' : 's.')); + $request->print($grademsg.$studentTable); return ''; } @@ -2880,38 +2878,39 @@ sub show_grading_menu_form { my $result.='
'."\n". ''."\n". ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". ''."\n". ''."\n". '
'."\n"; return $result; } + #--- Displays the main menu page ------- sub gradingmenu { my ($request) = @_; my ($symb,$url)=&get_symb_and_url($request); if (!$symb) {return '';} + my $probTitle = &Apache::lonnet::gettitle($symb); + my $saveCmd = ($ENV{'form.saveCmd'} eq '' ? 'pickStudentPage' : $ENV{'form.saveCmd'}); + my $saveSec = ($ENV{'form.saveSec'} eq '' ? 'all' : $ENV{'form.saveSec'}); + my $saveSub = ($ENV{'form.saveSub'} eq '' ? 'yes' : $ENV{'form.saveSub'}); + my $saveStatus = ($ENV{'form.saveStatus'} eq '' ? 'Active' : $ENV{'form.saveStatus'}); $request->print(< function checkChoice(formname) { var cmd = formname.command; - formname.lastCmd.value = radioSelection(formname.command); - formname.lastSec.value = pullDownSelection(formname.section); - if (cmd[0].checked || cmd[1].checked || cmd[2].checked || cmd[4].checked) { - formname.submit(); - } + formname.saveCmd.value = radioSelection(cmd); + formname.saveSec.value = pullDownSelection(formname.section); + formname.saveSub.value = radioSelection(formname.submitonly); + formname.saveStatus.value = pullDownSelection(formname.status); + if (cmd[0].checked || cmd[1].checked || cmd[2].checked || cmd[4].checked) formname.submit(); - if (cmd[3].checked) { - var url = "/adm/grades?command=csvform&symb="+formname.symb.value+"&url="+formname.url.value; - var options = "width=620,height=340,screenx=70,screeny=75,"; - options += "resizable=no,scrollbars=no,status=no,"; - options += "menubar=no,toolbar=no,location=no,directories=no"; - var newWin = window.open(url, "CSVFile", options); - newWin.focus(); - } + if (cmd[3].checked) browseAndUpload(); if (cmd[5].checked) { if (!checkReceiptNo(formname,'notOK')) { return false;} @@ -2930,35 +2929,94 @@ sub gradingmenu { formname.receipt.focus(); return false; } - formname.command[4].checked = true; + formname.command[5].checked = true; return true; } function radioSelection(radioButton) { var selection=null; - for (var i=0; i 1) { + for (var i=0; i 1) { + for (var i=0; i"); + lDoc.write("Browse And Upload"); + + lDoc.write(" GRADINGMENUJS - my $probTitle = &Apache::lonnet::gettitle($ENV{'form.url'}); my $result='

 Manual Grading/View Submission

'. ''. - ''; + ''."\n"; my ($partlist,$handgrade) = &response_type($url); my ($resptype,$hdgrade)=('','no'); for (sort keys(%$handgrade)) { @@ -2969,11 +3027,9 @@ GRADINGMENUJS ''. ''; } - $result.='
Problem: '.$probTitle.'
Problem: '.$probTitle.'
Type: '.$responsetype.'Handgrade: '.$handgrade.'
'; + $result.='

'."\n"; - my ($classlist,$sections) = &getclasslist('all','0'); - my $lastCmd = ($ENV{'form.lastCmd'} eq '' ? 'pickStudentPage' : $ENV{'form.lastCmd'}); - my $lastSec = ($ENV{'form.lastSec'} eq '' ? 'all' : $ENV{'form.lastSec'}); + my (undef,$sections) = &getclasslist('all','0'); $result.='
'."\n". ''."\n". @@ -2981,8 +3037,10 @@ GRADINGMENUJS ''."\n". ''."\n". ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n". ''."\n"; $result.='
'."\n". @@ -2993,25 +3051,27 @@ GRADINGMENUJS $result.=''. ''."\n". ''."\n". ''."\n". ''."\n". + ' submitted'. + ' everybody'."\n". ''."\n"; $result.=''. '
'. ' '. + ($saveCmd eq 'pickStudentPage' ? 'checked' : '').'> '. 'Handgrade/View Submission for a student by page/sequence
'. ' '. + ($saveCmd eq 'viewgrades' ? 'checked' : '').'> '. 'Grade by section or class
'. + ($saveCmd eq 'submission' ? 'checked' : '').'> '. ($hdgrade eq 'yes' ? 'View/Grade essay response of' : 'View'). ' an individual student --> For students who has: '. - ' submitted'. - ' everybody
'. ' '. + ($saveCmd eq 'csvupload' ? 'checked' : '').'> '. 'Upload scores from file
'. @@ -3020,8 +3080,8 @@ GRADINGMENUJS if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) { $result.='
'. - ' '. + ' '. 'Verify a submission receipt issued by this server--> Receipt no: '.unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}). '-'. @@ -3029,13 +3089,21 @@ GRADINGMENUJS } $result.='

'."\n". - ' Select section: '."\n"; if (ref($sections)) { foreach (sort (@$sections)) {$result.=''."\n";} + ($saveSec eq $_ ? 'selected="on"' : '').'>'.$_.''."\n";} } - $result.= '