[LON-CAPA-cvs] cvs: rat /client parameter.html

raeburn raeburn at source.lon-capa.org
Sun May 15 13:40:35 EDT 2016


raeburn		Sun May 15 17:40:35 2016 EDT

  Modified files:              
    /rat/client	parameter.html 
  Log:
  - Bug 2802
   - Lenient (partial credit) parameter for optionresponse supports relative
     weights when checkboxes are in use.
  
  
Index: rat/client/parameter.html
diff -u rat/client/parameter.html:1.71 rat/client/parameter.html:1.72
--- rat/client/parameter.html:1.71	Fri May 13 22:48:14 2016
+++ rat/client/parameter.html	Sun May 15 17:40:34 2016
@@ -5,7 +5,7 @@
 The LearningOnline Network with CAPA
 Parameter Input Window
 //
-// $Id: parameter.html,v 1.71 2016/05/13 22:48:14 raeburn Exp $
+// $Id: parameter.html,v 1.72 2016/05/15 17:40:34 raeburn Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -449,6 +449,45 @@
     return 'onclick="parent.radiostringeval(\''+newval+'\')"';
 }
 
+function lenienteval(newval) {
+    if (newval == 'weighted') {
+        if (document.getElementById('lenientweighteddiv')) {
+            document.getElementById('lenientweighteddiv').style.display='block';
+        }
+        var patternRelWeight = /^\-?[\d.]+$/;
+        var sform=choices.document.forms.sch; 
+        if ((sform.lenientrelwt.length != 'undefined')  && (sform.lenientrelwt.length) != 'null') {
+            for (var i=0; i<sform.lenientrelwt.length; i++) {
+                var relweight = sform.lenientrelwt[i].value;
+                relweight = relweight.replace(/^\s+|\s+$/g,'');
+                if (!patternRelWeight.test(relweight)) {
+                    if (i<2) {
+                        relweight = '1.0';
+                    } else {
+                        relweight = '0.0';
+                    }
+                }
+                sform.lenientrelwt[i].value = relweight;
+                if (i==0) {
+                    svalue = relweight;
+                } else {
+                    svalue += ','+relweight;
+                }
+            }
+        }
+    } else {
+        if (document.getElementById('lenientweighteddiv')) {
+            document.getElementById('lenientweighteddiv').style.display='none';
+        }
+        svalue=newval;
+    } 
+    draw();
+}
+
+function calllenientradioeval(newval) {
+    return 'onclick="parent.lenienteval(\''+newval+'\')"';
+}
+
 function callintervalpmodval() {
     return 'onclick="parent.intcalc();parent.toggleSecret()"';
 } 
@@ -809,20 +848,50 @@
            choicewrite(' /> Library</label><br />');
         }
         if (pscat=='lenient') {
+           var patternLenientStd = /^(yes|no|default)$/;
+           var patternLenientRel = /^([\-\d\.]+)\,([\-\d\.]+)\,([\-\d\.]+)\,([\-\d\.]+)$/;
+           var lenientweighted = 'none';
+           var relatives = new Array;
            tablestart('Lenient Grading (Partial Credit)');
            choicewrite('<tr><td>Value:</td><td colspan="2">');
            choicewrite('<label><input name="stringval" value="yes"'+
-                  ' type="radio" '+callradiostringeval('yes'));
+                  ' type="radio" '+calllenientradioeval('yes'));
            if (svalue=='yes') { choicewrite(' checked="checked"'); }
            choicewrite(' /> Yes</label><br />');
            choicewrite('<label><input name="stringval" value="no"'+
-                  ' type="radio" '+callradiostringeval('no'));
+                  ' type="radio" '+calllenientradioeval('no'));
            if (svalue=='no') { choicewrite(' checked="checked"'); }
            choicewrite(' /> No</label><br />');
            choicewrite('<label><input name="stringval" value="default"'+
-               ' type="radio" '+callradiostringeval('default'));
+               ' type="radio" '+calllenientradioeval('default'));
            if (svalue=='default') { choicewrite(' checked="checked"'); }
            choicewrite(' /> Default (only bubblesheet grading is lenient)</label><br />');
+           choicewrite('<label><input name="stringval" value="weighted"'+
+               ' type="radio" '+calllenientradioeval('weighted'));
+           if (!patternLenientStd.test(svalue) && svalue != '') {
+              choicewrite(' checked="checked"');
+              lenientweighted='block';
+              var relatives = svalue.match(patternLenientRel);
+           }
+           choicewrite(' />Yes, weighted (optionresponse in checkbox mode)</label><br /><br />'+
+                       '<div id="lenientweighteddiv" style="display:'+lenientweighted+'">'+
+                       '<table class="LC_parmsel_table"><tr bgcolor="#C5DB99">'+
+                       '<th colspan="2">Foil submission status</th><th>Points</th></tr>');
+           var lenienttypes = ['Correct (checked)','Correct (unchecked)','Incorrect (checked)','Incorrect (unchecked)'];
+           for (var i=0; i<lenienttypes.length; i++) {
+               var j = i+1;
+               if (relatives[j] == '') {
+                   if (i < 2) {
+                       relatives[j] = '1.0';
+                   } else {
+                       relatives[j] = '0.0';
+                   }
+               }
+               choicewrite('<tr><td colspan="2">'+lenienttypes[i]+'</td>'+
+                           '<td><input type="text" name="lenientrelwt" value="'+relatives[j]+'"'+
+                           ' size="3" onblur="parent.lenienteval(\'weighted\')" /></td></tr>');
+           }
+           choicewrite('</table></div>');
         }
         if (pscat=='discussvote') {
            tablestart('Discussion Voting');




More information about the LON-CAPA-cvs mailing list