[LON-CAPA-cvs] cvs: loncom /homework grades.pm
www
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 16 Jun 2007 14:38:46 -0000
www Sat Jun 16 10:38:46 2007 EDT
Modified files:
/loncom/homework grades.pm
Log:
Remember clicker policy between sessions
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.412 loncom/homework/grades.pm:1.413
--- loncom/homework/grades.pm:1.412 Sat Jun 16 10:09:52 2007
+++ loncom/homework/grades.pm Sat Jun 16 10:38:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.412 2007/06/16 14:09:52 www Exp $
+# $Id: grades.pm,v 1.413 2007/06/16 14:38:45 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6178,6 +6178,14 @@
return %clicker_ids;
}
+sub clicker_grading_parameters {
+ return ('gradingmechanism' => 'scalar',
+ 'upfiletype' => 'scalar',
+ 'specificid' => 'scalar',
+ 'pcorrect' => 'scalar',
+ 'pincorrect' => 'scalar');
+}
+
sub process_clicker {
my ($r)=@_;
my ($symb)=&get_symb($r);
@@ -6191,6 +6199,22 @@
$result.=' <b>'.&mt('Specify a file containing the clicker information for this resource').
'.</b></td></tr>'."\n";
$result.='<tr bgcolor=#ffffe6><td>'."\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',
+ \%Saveable_Parameters);
+ if (!$env{'form.pcorrect'}) { $env{'form.pcorrect'}=100; }
+ if (!$env{'form.pincorrect'}) { $env{'form.pincorrect'}=100; }
+ if (!$env{'form.gradingmechanism'}) { $env{'form.gradingmechanism'}='attendance'; }
+ if (!$env{'form.upfiletype'}) { $env{'form.upfiletype'}='iclicker'; }
+
+ my %checked;
+ foreach my $gradingmechanism ('attendance','personnel','specific') {
+ if ($env{'form.gradingmechanism'} eq $gradingmechanism) {
+ $checked{$gradingmechanism}="checked='checked'";
+ }
+ }
+
my $upload=&mt("Upload File");
my $type=&mt("Type");
my $attendance=&mt("Award points just for participation");
@@ -6198,7 +6222,7 @@
my $specific=&mt("Correctness determined from response with clicker ID");
my $pcorrect=&mt("Percentage points for correct solution");
my $pincorrect=&mt("Percentage points for incorrect solution");
- my $selectform=&Apache::loncommon::select_form('iclicker','upfiletype',
+ my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype',
('iclicker' => 'i>clicker'));
$result.=<<ENDUPFORM;
@@ -6248,13 +6272,13 @@
<input type="hidden" name="saveState" value="$env{'form.saveState'}" />
<input type="file" name="upfile" size="50" />
<br /><label>$type: $selectform</label>
-<br /><label>$attendance: <input type="radio" name="gradingmechanism" value="attendance" checked="checked" onClick="sanitycheck()" /></label>
-<br /><label>$personnel: <input type="radio" name="gradingmechanism" value="personnel" onClick="sanitycheck()" /></label>
-<br /><label>$specific: <input type="radio" name="gradingmechanism" value="specific" onClick="sanitycheck()" /></label>
-<input type="text" name="specificid" size="15" />
-<input type="hidden" name="waschecked" value="attendance" />
-<br /><label>$pcorrect: <input type="text" name="pcorrect" size="4" value="100" onChange="sanitycheck()" /></label>
-<br /><label>$pincorrect: <input type="text" name="pincorrect" size="4" value="100" onChange="sanitycheck()" /></label>
+<br /><label>$attendance: <input type="radio" name="gradingmechanism" value="attendance" $checked{'attendance'} onClick="sanitycheck()" /></label>
+<br /><label>$personnel: <input type="radio" name="gradingmechanism" value="personnel" $checked{'personnel'} onClick="sanitycheck()" /></label>
+<br /><label>$specific: <input type="radio" name="gradingmechanism" value="specific" $checked{'specific'} onClick="sanitycheck()" /></label>
+<input type="text" name="specificid" value="$env{'form.specificid'}" size="15" />
+<input type="hidden" name="waschecked" value="$env{'form.gradingmechanism'}" />
+<br /><label>$pcorrect: <input type="text" name="pcorrect" size="4" value="$env{'form.pcorrect'}" onChange="sanitycheck()" /></label>
+<br /><label>$pincorrect: <input type="text" name="pincorrect" size="4" value="$env{'form.pincorrect'}" onChange="sanitycheck()" /></label>
<br /><input type="button" onClick="javascript:checkUpload(this.form);" value="$upload" />
</form>
ENDUPFORM
@@ -6268,6 +6292,11 @@
my ($r)=@_;
my ($symb)=&get_symb($r);
if (!$symb) {return '';}
+
+ my %Saveable_Parameters=&clicker_grading_parameters();
+ &Apache::loncommon::store_course_settings('grades_clicker',
+ \%Saveable_Parameters);
+
my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
if (($env{'form.gradingmechanism'} eq 'specific') && ($env{'form.specificid'}!~/\w/)) {
$result.='<span class="LC_error">'.&mt('You need to specify a clicker ID for the correct answer').'</span>';