How to simulate user do quiz multi choice use Jmeter !

Re: How to simulate user do quiz multi choice use Jmeter !

by Jan Derriks -
Number of replies: 0

It took me hours to find out why my JMeter (recorded+edited) script did not seem to push the right values for questions.
The scripts ran fine but all the questions remained unanswered.

It turned out that Jim Hunt's Regex Extractor example from the stack101.jmx file cannot be used for quizzes with more than 1 question. In the stack101.jmx example it says:

...

<stringProp name="RegexExtractor.regex">name=&quot;(q\d+:1_):sequencecheck&quot;</stringProp>

..

And this will only work with one question, numbered :1. So I changed it into:

name=&quot;(q\d+):1_:sequencecheck&quot;

And if you add the three regex JMeter post-processor parts on the right place in your recorded JMX file it will work after some more text-editing to:

  • replace every session key occurrence with ${sesskey} (session keys look like JN9Xa5r5bd)
  • replace every literal attempt number with ${attemptid}
  • replace every question prefix with ${varprefix} like in: ${varprefix}:2_:flagged

You can use any text editor to do the find+replace. You can also use the JMeter gui and change all the arguments one by one but that is a lot more work.

If the script works, use JMeter gui to remove requests for things like themes and javascript that are not needed to clean up.

So the basic steps to record+play a JMeter script for a quiz:

  1. Start the jmeter recorder and do the quiz: log in, navigate to the quiz, answer the questions, finish, logout, stop recorder. Note: dont use random generated questions if you want stable results.
  2. Add jmeter regex rules for extraction of SESSKEY, VARPREFIX and ATTEMPTID. Put the sesskey regex in the login/index.php request and the other two in the startattempt.php request. You can choose if you do it with JMeter gui or by editing the jmx file.
  3. Replace the occurrences of the real sesskey string, attempt numbers and question prefixes like q1728 with their variables.
  4. Save script.
  5. Keep "view result tree" JMeter window visible and click start/replay. Start with 1 thread and a loop count of 1 because you probably forgot to edit one or two attempt numbers or session key's.


I added an example to copy parts from. This example uses localhost as it is tested with moodle 2.9 on XAMPP.
It uses a quiz with thee questions: numerical, multiple choice and a simple text.





Attachment jmeterquiz.PNG
Average of ratings: Useful (5)