[LON-CAPA-cvs] cvs: loncom /homework grades.pm
ng
lon-capa-cvs@mail.lon-capa.org
Tue, 06 Aug 2002 20:46:30 -0000
This is a MIME encoded message
--ng1028666790
Content-Type: text/plain
ng Tue Aug 6 16:46:30 2002 EDT
Modified files:
/loncom/homework grades.pm
Log:
some minor error checking
Receipt form - if empty, prompts the user to put a number in
csv upload - if no file selected, then prompt the user to select one.
--ng1028666790
Content-Type: text/plain
Content-Disposition: attachment; filename="ng-20020806164630.txt"
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.45 loncom/homework/grades.pm:1.46
--- loncom/homework/grades.pm:1.45 Mon Aug 5 16:49:54 2002
+++ loncom/homework/grades.pm Tue Aug 6 16:46:30 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.45 2002/08/05 20:49:54 ng Exp $
+# $Id: grades.pm,v 1.46 2002/08/06 20:46:30 ng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,17 +45,6 @@
# ----- These first few routines are general use routines.-----
#
-
-sub print_hash {
- my ($request, $hash) = @_;
- $request->print('<table border=1><tr><td>Key</td><td>Value</td></tr>');
- for (sort keys (%$hash)) {
- $request->print('<tr><td>'.$_.'</td><td>'.$$hash{$_}.' </td></tr>');
- }
- $request->print('</table>');
- return '';
-}
-
# --- Retrieve the parts that matches stores_\d+ from the metadata file.---
sub getpartlist {
my ($url) = @_;
@@ -114,17 +103,6 @@
return \@partlist,\%handgrade;
}
-#--- Prints a message on screen if a user did something wrong
-#--- Operator error ---
-sub userError {
- my ($request, $reason, $step) = @_;
- $request->print('<h3><font color="red">LON-CAPA User Error</font></h3><br />'."\n");
- $request->print('<b>Reason: </b>'.$reason.'<br /><br />'."\n");
- $request->print('<b>Step: </b>'.($step ne '' ? $step : 'Use your browser back button to correct')
- .'<br /><br />'."\n");
- return '';
-}
-
#--- Dumps the class list with usernames,list of sections,
#--- section, ids and fullnames for each user.
sub getclasslist {
@@ -323,19 +301,22 @@
<script type="text/javascript" language="javascript">
function checkSelect(checkBox) {
var ctr=0;
+ var sense="";
if (checkBox.length > 1) {
for (var i=0; i<checkBox.length; i++) {
if (checkBox[i].checked) {
ctr++;
}
}
+ sense = "a student or group of students";
} else {
if (checkBox.checked) {
ctr = 1;
}
+ sense = "the student";
}
if (ctr == 0) {
- alert("You did not select any student.");
+ alert("Please select "+sense+" before clicking on the View/Grade button.");
return false;
}
document.gradesub.submit();
@@ -443,6 +424,8 @@
$gradeTable='<br /> <font color="red">'.
'No submission found for this resource.</font><br />';
$gradeTable.=&show_grading_menu_form ($ENV{'form.symb'},$ENV{'form.url'});
+ } elsif ($ctr == 1) {
+ $gradeTable =~ s/type=checkbox/type=checkbox checked/;
}
$request->print($gradeTable);
return '';
@@ -552,7 +535,7 @@
var points = eval("document.SCORE.GD_BOX"+i+"_"+partid+".value");
if (points == "") {
var name = eval("document.SCORE.name"+i+".value");
- alert("You did not assign any point for "+name+", part "+partid+".");
+ alert("Please assign a score for "+name+", part "+partid+".");
return false;
}
}
@@ -594,7 +577,7 @@
else return;
var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");
if (cleantxt=="") {
- alert("Select a word or group of words from document and then click this link.");
+ 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);
@@ -929,7 +912,6 @@
my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n".
'<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n";
-# $result.='<table border="0"><tr bgcolor="#ffffff"><td><b>Fullname: </b>'.$ENV{'form.fullname'}.
$result.='<b>Fullname: </b>'.$ENV{'form.fullname'}.
'<font color="#999999"> Username: '.$uname.'</font>'.
'<font color="#999999"> Domain: '.$udom.'</font><br />'."\n";
@@ -1002,7 +984,7 @@
$request->print($submitby);
} else {
my ($string,$timestamp)=
- &get_last_submission ($symb,$uname,$udom,$ENV{'request.course.id'});
+ &get_last_submission (%record);
my $lastsubonly.=''.
($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '.
$$timestamp).'';
@@ -1153,31 +1135,30 @@
#--- Retrieve the last submission for all the parts
sub get_last_submission {
- my ($symb,$username,$domain,$course)=@_;
- if ($symb) {
- my (@string,$timestamp);
- my (%returnhash)=&Apache::lonnet::restore($symb,$course,$domain,$username);
- if ($returnhash{'version'}) {
- my %lasthash=();
- my ($version);
- for ($version=1;$version<=$returnhash{'version'};$version++) {
- foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
- $lasthash{$_}=$returnhash{$version.':'.$_};
- }
- }
- foreach ((keys %lasthash)) {
- if ($_ =~ /\.submission$/) {
- my ($partid,$foo) = split(/submission$/,$_);
- my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
- '<font color="red">Draft Copy</font> ' : '';
- push @string, (join(':',$_,$draft.$lasthash{$_}));
- }
- if ($_ =~ /timestamp/) {$timestamp = scalar(localtime($lasthash{$_}))};
+ my (%returnhash)=@_;
+ my (@string,$timestamp);
+ if ($returnhash{'version'}) {
+ my %lasthash=();
+ my ($version);
+ for ($version=1;$version<=$returnhash{'version'};$version++) {
+ foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
+ $lasthash{$_}=$returnhash{$version.':'.$_};
+ if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {
+ $timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
+ }
+ }
+ }
+ foreach ((keys %lasthash)) {
+ if ($_ =~ /\.submission$/) {
+ my ($partid,$foo) = split(/submission$/,$_);
+ my $draft = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
+ '<font color="red">Draft Copy</font> ' : '';
+ push @string, (join(':',$_,$draft.$lasthash{$_}));
}
}
- @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
- return \@string,\$timestamp;
}
+ @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
+ return \@string,\$timestamp;
}
#--- High light keywords, with style choosen by user.
@@ -2029,8 +2010,6 @@
}
$request->print('<h3>Assigning Grades</h3>');
my $courseid=$ENV{'request.course.id'};
-# my $cdom=$ENV{"course.$courseid.domain"};
-# my $cnum=$ENV{"course.$courseid.num"};
my ($classlist) = &getclasslist('all','1');
my @skipped;
my $countdone=0;
@@ -2130,7 +2109,7 @@
$result.= '<option>'.$_.'</option>'."\n";
}
$result.='<option selected="on">all</select>'."<br />\n";
- $result.=' <input type="submit" name="submit" value="View/Grade" /></form>'."\n";
+ $result.=' <input type="button" onClick="submit();" value="View/Grade" /></form>'."\n";
$result.='</td></tr></table>'."\n";
$result.='</td></tr></table>'."\n";
return $result;
@@ -2140,7 +2119,17 @@
sub upcsvScores_form {
my ($symb,$url) = @_;
if (!$symb) {return '';}
- my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
+ my $result = '<script type="text/javascript" language="javascript">'."\n".
+ ' function checkUpload(formname) {'."\n".
+ ' if (formname.upfile.value == "") {'."\n".
+ ' alert("Please use the browse button to select a file from your local directory.");'."\n".
+ ' return false;'."\n".
+ ' }'."\n".
+ ' formname.submit();'."\n".
+ ' }'."\n".
+ '</script>'."\n";
+
+ $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
$result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
$result.=' <b>Specify a file containing the class scores for above resource</b></td></tr>'."\n";
$result.='<tr bgcolor=#ffffe6><td>'."\n";
@@ -2151,7 +2140,7 @@
<input type="hidden" name="url" value="$url" />
<input type="hidden" name="command" value="csvuploadmap" />
$upfile_select
-<br /> <input type="submit" name="submit" value="Upload Grades" />
+<br /> <input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Grades" />
</form>
ENDUPFORM
$result.='</td></tr></table>'."\n";
@@ -2185,8 +2174,8 @@
'<input type="radio" name="submitonly" value="all"> everybody <br />';
$result.=' (Section "no" implies the students were not assigned a section.)<br />'
if (grep /no/,@$sections);
-
- $result.='<br /> <input type="submit" name="submit" value="View/Grade" />'."\n".
+
+ $result.='<br /> <input type="button" onClick="submit();" value="View/Grade" />'."\n".
'</form>'."\n";
$result.='</td></tr></table>'."\n";
$result.='</td></tr></table>'."\n";
@@ -2196,17 +2185,27 @@
#--- Form to input a receipt number ---
sub verifyReceipt_form {
my ($symb,$url) = @_;
- my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};
- my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};
+ my $result = '<script type="text/javascript" language="javascript">'."\n".
+ ' function checkEntry(formname) {'."\n".
+ ' var receipt = formname.receipt.value;'."\n".
+ ' if (isNaN(receipt) || receipt == "") {'."\n".
+ ' alert("Please enter a receipt number given by a student in the box.");'."\n".
+ ' return false;'."\n".
+ ' }'."\n".
+ ' formname.submit();'."\n".
+ ' }'."\n".
+ '</script>'."\n";
+
my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
- my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
+ $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
$result.='<table width=100% border=0><tr><td bgcolor=#e6ffff>'."\n";
$result.=' <b>Verify a Submission Receipt Issued by this Server</td></tr>'."\n";
$result.='<tr bgcolor=#ffffe6><td>'."\n";
- $result.='<form action="/adm/grades" method="post">'."\n";
+ $result.='<form action="/adm/grades" method="post" name="verifyform">'."\n";
$result.=' <tt>'.$hostver.'-<input type="text" name="receipt" size="4"></tt><br />'."\n";
- $result.=' <input type="submit" name="submit" value="Verify Receipt">'."\n";
+ $result.=' <input type="button" onClick="javascript:checkEntry(this.form);"'.
+ ' value="Verify Receipt">'."\n";
$result.='<input type="hidden" name="command" value="verify">'."\n";
if ($ENV{'form.url'}) {
$result.='<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />';
@@ -2268,7 +2267,6 @@
}
}
} else {
- #&Apache::lonhomework::showhashsubset(\%ENV,'^form');
$Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
if ($command eq 'submission') {
&listStudents($request) if ($ENV{'form.student'} eq '');
--ng1028666790--