[LON-CAPA-cvs] cvs: loncom /homework grades.pm

www lon-capa-cvs-allow@mail.lon-capa.org
Wed, 13 Jun 2007 15:22:39 -0000


www		Wed Jun 13 11:22:39 2007 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  Saving my work on clickers (still commented out)
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.401 loncom/homework/grades.pm:1.402
--- loncom/homework/grades.pm:1.401	Mon Jun 11 17:36:18 2007
+++ loncom/homework/grades.pm	Wed Jun 13 11:22:38 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.401 2007/06/11 21:36:18 albertel Exp $
+# $Id: grades.pm,v 1.402 2007/06/13 15:22:38 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6082,7 +6082,6 @@
 #        '<input type="button" onClick="javascript:checkChoice(this.form,\'6\',\'processclicker\');" value="'.&mt('Process').'" />'.
 #        ' '.&mt('clicker file').' </td></tr>'."\n";
 
-
     $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
 	'<input type="button" onClick="javascript:checkChoice(this.form,\'4\',\'scantron_selectphase\');'.
 	'" value="'.&mt('Grade').'" /> scantron forms</td></tr>'."\n";
@@ -6156,6 +6155,28 @@
     return %clickerids;
 }
 
+sub gather_adv_clicker_ids {
+    my %clickerids=();
+    my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
+    my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+    my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
+    foreach my $element (sort keys %coursepersonnel) {
+        foreach my $person (split(/\,/,$coursepersonnel{$element})) {
+            my ($puname,$pudom)=split(/\:/,$person);
+            my $clickers =
+               (&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1];
+               foreach my $id (split(/\,/,$clickers)) {
+               if (exists($clickerids{$id})) {
+                  $clickerids{$id}.=','.$puname.':'.$pudom;
+               } else {
+                  $clickerids{$id}=$puname.':'.$pudom;
+               }
+           }
+        }
+    }
+    return %clickerids;
+}
+
 sub process_clicker {
     my ($r)=@_;
     my ($symb)=&get_symb($r);
@@ -6171,10 +6192,54 @@
     $result.='<tr bgcolor=#ffffe6><td>'."\n";
     my $upload=&mt("Upload File");
     my $type=&mt("Type");
+    my $attendance=&mt("Award points just for participation");
+    my $personnel=&mt("Correctness determined from response by course personnel");
+    my $specific=&mt("Correctness determind 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',
                                   ('iclicker' => 'iClicker'));
 
     $result.=<<ENDUPFORM;
+<script type="text/javascript">
+function sanitycheck() {
+// Accept only integer percentages
+   document.forms.gradesupload.pcorrect.value=Math.round(document.forms.gradesupload.pcorrect.value);
+   document.forms.gradesupload.pincorrect.value=Math.round(document.forms.gradesupload.pincorrect.value);
+// Find out grading choice
+   for (i=0; i<document.forms.gradesupload.gradingmechanism.length; i++) {
+      if (document.forms.gradesupload.gradingmechanism[i].checked) {
+         gradingchoice=document.forms.gradesupload.gradingmechanism[i].value;
+      }
+   }
+// By default, new choice equals user selection
+   newgradingchoice=gradingchoice;
+// Not good to give more points for false answers than correct ones
+   if (Math.round(document.forms.gradesupload.pcorrect.value)<Math.round(document.forms.gradesupload.pincorrect.value)) {
+      document.forms.gradesupload.pcorrect.value=document.forms.gradesupload.pincorrect.value;
+   }
+// If new choice is attendance only, and old choice was correctness-based, restore defaults
+   if ((gradingchoice=='attendance') && (document.forms.gradesupload.waschecked.value!='attendance')) {
+      document.forms.gradesupload.pcorrect.value=100;
+      document.forms.gradesupload.pincorrect.value=100;
+   }
+// If the values are different, cannot be attendance only
+   if ((Math.round(document.forms.gradesupload.pcorrect.value)!=Math.round(document.forms.gradesupload.pincorrect.value)) &&
+       (gradingchoice=='attendance')) {
+       newgradingchoice='personnel';
+   }
+// Change grading choice to new one
+   for (i=0; i<document.forms.gradesupload.gradingmechanism.length; i++) {
+      if (document.forms.gradesupload.gradingmechanism[i].value==newgradingchoice) {
+         document.forms.gradesupload.gradingmechanism[i].checked=true;
+      } else {
+         document.forms.gradesupload.gradingmechanism[i].checked=false;
+      }
+   }
+// Remember the old state
+   document.forms.gradesupload.waschecked.value=newgradingchoice;
+}
+</script>
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
 <input type="hidden" name="symb" value="$symb" />
 <input type="hidden" name="command" value="processclickerfile" />
@@ -6182,6 +6247,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 /><input type="button" onClick="javascript:checkUpload(this.form);" value="$upload" />
 </form>
 ENDUPFORM