Correct answer of second question depends on students answer to first

Correct answer of second question depends on students answer to first

Wolfgang Rolke -
回帖数:28

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.

回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Shirley Gregorczyk -
Particularly helpful Moodlers的头像
回复Shirley Gregorczyk

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
Shirley, this would work if the goal was to make sure the student gets all the answers right, or gets nothing. I want them to get the points they deserve based on their own answers. So in my example though Washington was the wrong answer in question 1, it was the right answer for question 2 (Washington is not the largest city in the US), so they should get credit for that.
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像
You can do this with the Formulas question. You need to set up some grading variables and criterion, as well as a bit of JavaScript to make it look good.

Formulas_20210810_1845.png




A simpler, but perhaps not as elegant, way would be to ask two separate questions, the second of which does not depend on the first. For example, 1) What is the capital of France? (Paris, Washington) 2) Which city is the largest in its country? (Paris, Washington).


回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Mohd Zahid -

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

回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
It is a fundamental part of the design on the Moodle quiz that each question is independent.

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.)
回复Tim Hunt

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

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.

回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
I am assuming Dominique's reply was aimed at Tim...

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?
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
What you want (in a single question with mulitple sub-parts) to do is possible with the STACK question type https://moodle.org/plugins/qtype_stack - but that is not the easiest plugin to install because in addition to the Moodle plugin, you also need to install the maths processing software (Maxima) which it uses.

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.)
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

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&section=5 ↗

回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

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&section=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.

回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像
Unfortunately, the functions mean, standard deviation, etc. are not yet available. Fortunately, they are not very complicated and in the meantime you can easily program them with the tools available in the Formulas question, including loop and ternary operator.
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像
Besides, I am the maintainer of the Formulas question (not very efficient, but still), I created and am the almost sole contributor to the Formulas questions documentation site, and I am almost the only person who answers on this forum regarding the Formulas question. Oh, I'm also a full-time professor at an engineering school, so everything I do doesn't count because only software developers have the truth and can say something.

I have discovered several ways to use the possibilities of the question, among others this way of using the grading criteria of the parts so that their sub-questions depend on each other, and many other aspects that no one has thought of. Regarding the Formulas question, I have nothing to learn from anyone at this time. A little help and solidarity would rather be appreciated, not denigration. 
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
Actually, Tim's suggestion is what I have been doing for some time now. I use the statistics program R to generate an xml file with 50 (or as many as I want) different versions of the same basic set of questions but with different data sets from different distributions with different sample sizes, parameters etc..

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.
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
Dominique, I have tried to adept your answer to my actual problem, unfortunately without success. Here is the quiz I want: In the first question ("The p value of the hypothesis test is ..") the students have to enter a number. Then the second question is a multiple choice with options "reject" and "fail to reject", and the text "Therefore we ... the null hypothesis". Now if the student entered a number <0.05 in the first question, the correct answer in the second question is "reject", otherwise the correct answer is "fail to reject".
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

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.

  1. Is the correct answer any number p <0.05 or a specific number such as p = 0.04?
  2. 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 ...
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
The idea is that in addition each student gets a different data set, which I can create outside of moodle and "add" to the xml file(s). Then the student needs to run a statistics program, which gives him a number called the p-value. If they get the wrong number they should 0 points for that part.

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.
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

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  ?
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
Sorry, I was not clear enough. For the second part it is irrelevant what the correct p value is. If a student finds a p<0.05, they should always select "reject". After all, they don't know that they calculated the wrong number in part 1. So in your table it would always be

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.
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
Dominique, I just realized that your question is about total points for the two problems, not points for each. So here is what you asked:

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)
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
Yes, that's exactly it! I just checked the "code" and what I didn't get right before was the part with the multiple choice. I suppose the formula question type is mainly for questions that need a numerical calculation, but it might be useful to add a little bit to the explanations for multiple choice section on the moodleformulas.org page. Maybe one or two simple examples?

Anyway, many thanks for your help!
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

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.

回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -

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

回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

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.

2. Perhaps, write the p-value function. It shouldn't be too difficult. I will see if it is possible to obtain sufficient precision with simple calculations. This would allow you to directly generate billions of different data sets with a single Formulas question. (It would probalby be better to link to a function library, but I'll get to that later.)
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
Dominique,

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
回复Wolfgang Rolke

Re: Correct answer of second question depends on students answer to first

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像
Wolfgang,

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.
回复Dominique Bauer

Re: Correct answer of second question depends on students answer to first

Wolfgang Rolke -
No, I did get that. And yes, the fact that I need 20 or so questions vs. just one is a very minor inconvenience.