[LON-CAPA-users] "slider" as a question type?

Rex Abert ABERTR at tcc.fl.edu
Mon Jul 1 08:50:30 EDT 2019


Sally-

I am replying off-list because I one time replied with a URL in the email, and the spam filter now blocks me. :-(

I've done some recent work using Javascript to do similar things.  Your slider is coded with javascript, so you can identify the script to the browswer with
<script language="javascript" type="text/javascript">

Now simply add a variable that you want to store the slider's value in:

var confidenceLevel = slider.value;


You can also set a response in the LC problem that will store the student's response, whose data you should be able to harvest later, though it might be tedious.

In the loncapa problem create a response of some type, probably custom response, so that it can take any value as "correct."

<part id="2">
<customresponse id="100">
    <hiddenline />
        <answer type="loncapa/perl">
           return 'EXACT_ANS';
        </answer>
</customresponse>


Using the <hiddenline />, this response will not show up within the problem.

Add a function similar to the following to your javascript:

  function setAnswer(answerIn)
  {
      try{
        document.lonhomework.elements["HWVAL_100"].value = answerIn;
      } catch(e) {}
  }

Call the function (I guess it doesn't have to be a separate function; it depends on how often you need to call it.

setAnswer(confidenceLevel);

This will pass the slider value to Lon-Capa as a response, and the student response will then be saved on the server.

I hope this helps!

Rex Abert
Associate Professor of Mathematics
Tallahassee Community College
________________________________________
From: LON-CAPA-users [lon-capa-users-bounces at mail.lon-capa.org] on behalf of Sally S Hunnicutt [sshunnic at vcu.edu]
Sent: Friday, June 28, 2019 12:06 PM
To: Discussion list for LON-CAPA users
Subject: Re: [LON-CAPA-users] "slider" as a question type?

Follow up to my previous question.

Using the coding below, I can get a slider to appear in my problem. However, the script is not type="loncapa". I would like to be able to get the slider bar response and save it in a variable that I can use elsewhere in the problem. Also, I would like to be able to store the students' confidence levels for research reasons.

Thanks,
Sally

Code:
<part id="p3">

<p>How confident are you that your answer is correct? Move the slider bar to the right to indicate high confidence (100) and to the left to indicate low confidence (1).</p>
<input type="range" min="1" max="100" value="50" id="myRange"></input>
<p>Your confidence is <span id="x"></span></p>


<script>
var slider = document.getElementById("myRange");
var output = document.getElementById("x");
output.innerHTML = slider.value;

slider.oninput = function() {
  output.innerHTML = this.value;
}
</script>

On Tue, Jun 18, 2019 at 2:32 PM Sally S Hunnicutt <sshunnic at vcu.edu<mailto:sshunnic at vcu.edu>> wrote:
Hello,

Has anyone developed a slider question as a type of question? For example, I would like to ask students to give their confidence, using a slider bar, that the question they have answered is the correct answer.

Thanks,
Sally Hunnicutt
VCU


***Due to Florida's very broad public records law, most written communications to or from Tallahassee Community College employees regarding College business are public records, available to the public and media upon request. Therefore, this email communication and your response may be subject to public disclosure.***


More information about the LON-CAPA-users mailing list