[LON-CAPA-cvs] cvs: loncom /homework grades.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Sat, 12 Feb 2005 15:18:42 -0000
albertel Sat Feb 12 10:18:42 2005 EDT
Modified files:
/loncom/homework grades.pm
Log:
- BUG#2432, add domain drop down field
- start work on adding more options (BUG#2198)
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.245 loncom/homework/grades.pm:1.246
--- loncom/homework/grades.pm:1.245 Fri Feb 11 22:43:06 2005
+++ loncom/homework/grades.pm Sat Feb 12 10:18:41 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.245 2005/02/12 03:43:06 albertel Exp $
+# $Id: grades.pm,v 1.246 2005/02/12 15:18:41 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2651,26 +2651,26 @@
#
#--- Javascript to handle csv upload
sub csvupload_javascript_reverse_associate {
+ my $error1=&mt('You need to specify the username or ID');
+ my $error2=&mt('You need to specify at least one grading field');
return(<<ENDPICK);
function verify(vf) {
var foundsomething=0;
var founduname=0;
var foundID=0;
- var founddomain=0;
for (i=0;i<=vf.nfields.value;i++) {
tw=eval('vf.f'+i+'.selectedIndex');
if (i==0 && tw!=0) { foundID=1; }
if (i==1 && tw!=0) { founduname=1; }
- if (i==2 && tw!=0) { founddomain=1; }
if (i!=0 && i!=1 && i!=2 && tw!=0) { foundsomething=1; }
}
- if ((founduname==0 && foundID==0) || founddomain==0) {
- alert('You need to specify the domain and either the username or ID');
- return;
+ if (founduname==0 && foundID==0) {
+ alert('$error1');
+ return;
}
if (foundsomething==0) {
- alert('You need to specify at least one grading field');
- return;
+ alert('$error2');
+ return;
}
vf.submit();
}
@@ -2691,26 +2691,26 @@
}
sub csvupload_javascript_forward_associate {
+ my $error1=&mt('You need to specify the username or ID');
+ my $error2=&mt('You need to specify at least one grading field');
return(<<ENDPICK);
function verify(vf) {
var foundsomething=0;
var founduname=0;
var foundID=0;
- var founddomain=0;
for (i=0;i<=vf.nfields.value;i++) {
tw=eval('vf.f'+i+'.selectedIndex');
if (tw==1) { foundID=1; }
if (tw==2) { founduname=1; }
- if (tw==3) { founddomain=1; }
if (tw>3) { foundsomething=1; }
}
- if ((founduname==0 && foundID==0) || founddomain==0) {
- alert('You need to specify the domain and either the username or ID');
- return;
+ if (founduname==0 && foundID==0) {
+ alert('$error1');
+ return;
}
if (foundsomething==0) {
- alert('You need to specify at least one grading field');
- return;
+ alert('$error2');
+ return;
}
vf.submit();
}
@@ -2761,7 +2761,7 @@
<input type="hidden" name="url" value="$url" />
<input type="hidden" name="saveState" value="$ENV{'form.saveState'}" />
<input type="hidden" name="probTitle" value="$ENV{'form.probTitle'}" />
-<input type="hidden" name="command" value="csvuploadassign" />
+<input type="hidden" name="command" value="csvuploadoptions" />
<hr />
<script type="text/javascript" language="Javascript">
$javascript
@@ -2885,15 +2885,51 @@
return '';
}
-sub csvuploadassign {
+sub csvuploadoptions {
my ($request)= @_;
my ($symb,$url)=&get_symb_and_url($request);
- if (!$symb) {return '';}
- &Apache::loncommon::load_tmp_file($request);
- my @gradedata = &Apache::loncommon::upfile_record_sep();
- if ($ENV{'form.noFirstLine'}) { shift(@gradedata); }
+ my $checked=(($ENV{'form.noFirstLine'})?'1':'0');
+ my $ignore=&mt('Ignore First Line');
+ $request->print(<<ENDPICK);
+<form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
+<h3><font color="#339933">Uploading Class Grade Options</font></h3>
+<input type="hidden" name="command" value="csvuploadassign" />
+<input type="submit" value="Assign Grades" /><br />
+<p>
+<label>
+ <input type="checkbox" name="show_full_results" />
+ Show a table of all changes
+</label>
+</p>
+<p>
+<label>
+ <input type="checkbox" name="overwite_scores" checked="checked" />
+ Overwrite any existing score
+</label>
+</p>
+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<p> Users are in domain: ".$domform."</p>\n");
+ }
+ foreach my $key (sort(keys(%ENV))) {
+ if ($key !~ /^form\.(.*)$/) { next; }
+ my $cleankey=$1;
+ if ($cleankey eq 'command') { next; }
+ $request->print('<input type="hidden" name="'.$cleankey.
+ '" value="'.$ENV{$key}.'" />'."\n");
+ }
+ # FIXME do a check for any duplicated user ids...
+ # FIXME do a check for any invalid user ids?...
+ $request->print("<hr /></form>\n");
+ $request->print(&show_grading_menu_form($symb,$url));
+ return '';
+}
+
+sub get_fields {
+ my %fields;
my @keyfields = split(/\,/,$ENV{'form.keyfields'});
- my %fields=();
for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
if ($ENV{'form.upfile_associate'} eq 'reverse') {
if ($ENV{'form.f'.$i} ne 'none') {
@@ -2905,6 +2941,17 @@
}
}
}
+ return %fields;
+}
+
+sub csvuploadassign {
+ my ($request)= @_;
+ my ($symb,$url)=&get_symb_and_url($request);
+ if (!$symb) {return '';}
+ &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('<h3>Assigning Grades</h3>');
my $courseid=$ENV{'request.course.id'};
my ($classlist) = &getclasslist('all',0);
@@ -2913,7 +2960,12 @@
my $countdone=0;
foreach my $grade (@gradedata) {
my %entries=&Apache::loncommon::record_sep($grade);
- my $domain=$entries{$fields{'domain'}};
+ my $domain;
+ if ($entries{$fields{'domain'}}) {
+ $domain=$entries{$fields{'domain'}};
+ } else {
+ $domain=$ENV{'form.default_domain'};
+ }
$domain=~s/\s//g;
my $username=$entries{$fields{'username'}};
$username=~s/\s//g;
@@ -5144,9 +5196,9 @@
$request->print(&csvupload($request));
} elsif ($command eq 'csvuploadmap' && $perm{'mgr'} ) {
$request->print(&csvuploadmap($request));
- } elsif ($command eq 'csvuploadassign' && $perm{'mgr'}) {
+ } elsif ($command eq 'csvuploadoptions' && $perm{'mgr'}) {
if ($ENV{'form.associate'} ne 'Reverse Association') {
- $request->print(&csvuploadassign($request));
+ $request->print(&csvuploadoptions($request));
} else {
if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
$ENV{'form.upfile_associate'} = 'reverse';
@@ -5155,6 +5207,8 @@
}
$request->print(&csvuploadmap($request));
}
+ } elsif ($command eq 'csvuploadassign' && $perm{'mgr'} ) {
+ $request->print(&csvuploadassign($request));
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) {
$request->print(&scantron_selectphase($request));
} elsif ($command eq 'scantron_warning' && $perm{'mgr'}) {