I have the following issue: my quiz has two questions, and whether or not the students second answer is correct depends on what they chose in the first. As an example, say question one is "what is the capital of France", with the options Paris and Washington. The second question is "is this city the largest in its country?" Now if a student wrongly chose Washington in question 1 but correctly (for Washington) answered No in question 2 they would still get 0 points because the correct answers are Paris and Yes.
Re: Correct answer of second question depends on students answer to first
Re: Correct answer of second question depends on students answer to first
Re: Correct answer of second question depends on students answer to first


Re: Correct answer of second question depends on students answer to first
Dear Professor Dominique
I am still new with Formula type question and also weak in programming. I'm having trouble aligning the answer box. My question preview look like below:
I would like to have the answer box in line with the "Answer = " and also the unit sign
example:
Answer = [answer box] ° , and also
Answer = [answer box] s
This is what is in the Part's text
I have also attached the question in xml moodle format. I will really appreciate if you could kindly show me the way how solve it
Re: Correct answer of second question depends on students answer to first
Some questoin types (e.g. Forumuas, STACK) support a single question with multiple sub-parts, which can then depend on each other. That is the only way to achieve what you want. (I would not recomment hacking this with JavaScript.)
Re: Correct answer of second question depends on students answer to first
The Formulas question has multiple parts and multiple sub-questions in each part. The grading criteria allow the sub-questions to depend on each other. This is a nice feature of the Formulas question. In comparison, the Cloze question also has multiple sub-questions but these cannot depend on each other.
However, the grading criteria of the Formulas question are local to each part. Contrary to what you say, in the Formulas question, the parts cannot depend on each other or, more precisely, the parts cannot depend on the value of the students' answers in the previous parts. This would be another nice feature that I will try to implement someday.
I wish I could hack "this", but only somewhat laborious workarounds are possible at this time. So no one is hacking "this" here. You know that very well. With that being said, as it is very often the only practical solution for making slight adjustments to Moodle, I highly recommend a bit of hacking with JavaScript and jQuery where a new plugin is not called for.
Re: Correct answer of second question depends on students answer to first
Anyway do I undertstand correctly that what I am trying to do is not currently possible without some additional "hacking"?
The example I gave above was just a toy example. I am a Professor of Statistics and in my classes each student gets a quiz with different numbers. Here is a more realistic (toy) example: each student has a data set with different numbers. In questions one and two they have to find the mean and the median. In the third question they are asked whether the mean is greater than the median. Now say the correct answer is no. But if they made a mistake in calculating the mean, then from their numbers they should answer yes, but they will still get 0 points.
By the way, are calculations like the mean, standard deviation etc. possible with the formula question type?
Re: Correct answer of second question depends on students answer to first
The other way to achieve what you want with standard question types is to create each separate variant you want as a separate question in the question bank (since they are multip-part qusetions, they would need to be Cloze), and then use the Moodle feature to add one picked at random to the quiz: https://docs.moodle.org/310/en/Effective_quiz_practices#Robust_testing_with_random_variants. (The down-side of this method is that you have to create and maintain multiple questions.)
Re: Correct answer of second question depends on students answer to first
Wolfgang,
The question can be rephrased as follows. While this has nothing to do with Tim's irrelevant comment on JavaScript, this new wording removes the need for JavaScript.
https://moodleformulas.org/course/view.php?id=113§ion=5 ↗
Re: Correct answer of second question depends on students answer to first
Anyway do I undertstand correctly that what I am trying to do is not currently possible without some additional "hacking"?
No. You can make your statistics question without JavaScript. Just use the Formulas question's standard grading variables and criterion.
I use JavaScript in workarounds to improve some aspects of Moodle when a more permanent solution is not available. A lot of people use the little scripts I wrote and it makes their life easier. The only person who uses the term "hacking" in a disparaging way is Tim. It's his personal problem. He thinks we're just a bunch of useless geeks (his words).
Take a look at this statistics question that you might be interested in: https://moodleformulas.org/course/view.php?id=78§ion=38. There is a small script just for formatting the answer boxes. The only reason for such a script is the stupid (Tim's preferred expression) editor removes the css <style> code.
Re: Correct answer of second question depends on students answer to first
Re: Correct answer of second question depends on students answer to first
Re: Correct answer of second question depends on students answer to first
This way I can also use much more advanced functions (such as find a confidence interval) that would likely be hard to implement in moodle but that my students need to use.
Then I import the xml file to moodle and assign one question randomly to each student. In this way I get a much higher randomization than is possible with moodle itself.
However, this does not allow for the issue under discussion. I need to decide "outside" of moodle what answers are correct. I have been using the CLOZE format, but I might be able to do the same thing using the formula format now that I know about it. STACK is not a possibility because I don't maintain our institutions moodle.
Re: Correct answer of second question depends on students answer to first
Re: Correct answer of second question depends on students answer to first
Hello Wolfgang,
This problem can easily be done with the Formulas question. In fact, it's a snap.
But before going any further, could you clarify your grading scale.
- Is the correct answer any number p <0.05 or a specific number such as p = 0.04?
- Assuming the correct answer is any number p <0.05,
-
- if the student answers: p = 0.02 and "reject", the score is ...
- if the student answers: p = 0.02 and "fail to reject", the score is ...
- if the student answers: p = 0.08 and "reject", the score is ...
- if the student answers: p = 0.08 and "fail to reject", the score is ...
Re: Correct answer of second question depends on students answer to first
Because the data sets are different, some get a p-value less than 0.05, others one grater than 0.05. But independent of the data set, a p-value less than 0.05 always should lead the student to reject the null hypothesis, and one greater then 0.05 to fail to reject the null hypothesis. If their p value is less than 0.05 but they wrongly choose "fail to reject" they should get 0 points for that part, and vice versa.
Ultimately these questions need to be created outside of moodle because the randomization options in moodle are insufficient for the purposes of a statistics course and the calculation of the p-value requires a complicated routine.
Re: Correct answer of second question depends on students answer to first
Hello Wolfgang,
Your answer is very nice but incomplete. At any rate, please do give the score for each of the following 12 cases:
Assuming the correct answer is say p = 0.03:
Case | Student's answer | Score | |
1 | 0.03 | reject | 100% |
2 | 0.03 | fail to reject | 50% |
3 | 0.02 | reject | ? |
4 | 0.02 | fail to reject | ? |
5 | 0.07 | reject | ? |
6 | 0.07 | fail to reject | ? |
Assuming now that the correct answer is say p = 0.09:
Case | Student's answer | Score | |
7 | 0.09 | reject | 50% |
8 | 0.09 | fail to reject | 100% |
9 | 0.02 | reject | ? |
10 | 0.02 | fail to reject | ? |
11 | 0.07 | reject | ? |
12 | 0.07 | fail to reject | ? |
Re: Correct answer of second question depends on students answer to first
0.02 reject 100
0.02 fail to reject 0
0.07 reject 0
0.07 fail to reject 100
and the same for any other p entered by the student.
Re: Correct answer of second question depends on students answer to first
Say correct p=0.02
student p=0.02 reject 100 (Both answers correct)
student p=0.02 fail to reject 50 (Answer 1 correct, answer 2 wrong)
student p=0.03 reject 50 (Answer 1 wrong, answer 2 correct)
student p=0.03 fail to reject 0 (Both wrong)
student p=0.07 reject 0 (Both wrong)
student p=0.07 fail to reject 50 (Answer 1 wrong, answer 2 correct)
Re: Correct answer of second question depends on students answer to first
Re: Correct answer of second question depends on students answer to first
Anyway, many thanks for your help!
Re: Correct answer of second question depends on students answer to first
Wolfgang,
You will find some explanations and examples on the multiple choices of the Formulas question at Formulas mulitple choice ↗.
Note that the URL of this page will eventually change as I am reorganizing the moodleformulas.org site a bit.
Re: Correct answer of second question depends on students answer to first
Dominique,
I am attaching an expanded version of the quiz, so you can see what I had in mind originally. In this version there is a story and a data set, randomly chose from a normal distribution. Also some students need to pick < from a drop down box, others >, depending on whether it says less or more in the text. This in turn depends on what makes sense given the data. Finally there are two p values, one completely correct and one only partially correct.
Now that I have written the corresponding routine (in a language called R used by Statisticians) I could generate 1000 of these with the click of a button.
One (very minor issue): In the answer it always says One possible answer is .. However, here there is just one correct answer, so I would like to get rid of the word possible.
Wolfgang
Re: Correct answer of second question depends on students answer to first
Hello Wolfgang,
In the answer it always says One possible answer is .. However, here there is just one correct answer, so I would like to get rid of the word possible.
There are other ways to do this, but the easiest is probably to uncheck the "Right answer" option under "Review options" in the quiz settings, and provide your own feedback.
I looked at your quiz. May I suggest some improvements.
1. Put the sample data as variables. This can easily be done and it would allow you to:
a. Use random data sets. You can probably put one hundred or more different data sets in the same question, thus replacing one hundred or more different questions. By the way, isn't the quiz as good if you use fewer sample data points. You have more than 60 in a given set. Maybe 10 or 20 would be enough.
b. Shuffle the sample data points in a given set, so that the set looks different even though some students may get the same one.
c. Have the student calculate the mean of the sample data, the standard deviation, and the t-score as intermediate checks.
Re: Correct answer of second question depends on students answer to first
thanks for the hint to remove the word "possible".
Some comments on you other suggestions:
The data is already randomized. Each problem in the xml file has a different one. And I could create 1000 more with the click of a button. Moreover, it is randomized in the right way, that is in this case it is drawn from a normal distribution with a mean and standard deviation known to me as the creator of the problems, but not the students. I could even randomize those, thereby giving different students different "size" numbers.
The students are not doing any calculations by hand. They will copy-paste the data into the R program and then use the appropriate routine to get the numbers they need. It does therefore not matter how many data points I give them. And 50 or so is more realistic than 10.
Shuffling the data points is easy but not necessary as they are different numbers anyway. In fact they came in random order, but often I prefer to present them to the students ordered.
Of course in different quizzes the students will have to answer different questions, from easy ones (what is the mean) to much harder ones (such as finding the p value). My course currently has about 40 quizzes!
The function that calculates the p-value is not a simple one, among other things it requires numerical integration. One advantage of creating the problems outside of moodle is that the routine that calculates the correct answer and the one the students have to use is the same, thereby making sure the answers actually match. Moreover, p-value is just one of about 20 routines that would need to be implemented to cover a basic introductory statistics course.
Wolfgang
Re: Correct answer of second question depends on students answer to first
Point 1. I think you missed the point. Just putting the sample data as variables instead of plain text in the question would allow you to have a single question instead of a thousand. This is one of the advantages of the Formulas question. You don't need to create a thousand questions, just one. Above all, when it comes to make a change to the question, you only have to do it for one question, not a thousand. But if you are happy with the way you do things, good for you.
Point 2. In its simplest form, numerical integration is just a simple loop through the function. No big deal, and it may be fun. But again, if you're happy with the way you do things, good for you.