• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Quiz score 0

Quiz score 0 1 month 3 weeks ago #44155

  • liz9
  • liz9's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
I built a quiz (radio button options). There are 18 questions, and each question has 4 radio values. 1, 2, 3, 4
I followed instructions in documentation but at the end of my quiz, instead of getting a score / result % I get a 0.00

I need it to calculate a % score out of 100

My hidden field is called: score

My calculation is as follows:
(({Q1:value} + {Q2:value} + {Q3:value} + {Q4:value} + {Q5:value} + {Q6:value} + {Q7:value} + {Q8:value} + {Q9:value} + {Q10:value} + {Q11:value} + {Q12:value} + {Q13:value} + {Q14:value} + {Q15:value} + {Q16:value} + {Q17:value} + {Q18:value}) / 72) * 100

I've asked Chat GPT for help, but I am getting nowhere.
PLEASE HELP!!!!!
I don't know where to even start looking....
The administrator has disabled public write access.

Quiz score 0 1 month 3 weeks ago #44156

  • dragos
  • dragos's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 667
  • Thank you received: 122
Hello,

You can try crafting all your radio items like this:
1[p1]
2[p2]
3[p3]
4[p4]

Further info on the RSForm!Pro Calculations functionality can be found here.

Or, instead of 18 Radio Group fields, you can add one Survey Table field, with 18 questions and 4 answers, crafted just like above. Then, in the calculation you can use this equation instead:
({survey_table_name:value} / 72) * 100
The administrator has disabled public write access.

Quiz score 0 1 month 2 weeks ago #44170

  • liz9
  • liz9's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Thank you that worked like a charm.
Now based on the score percentage I would like a message displayed below the score.
I've tried using conditional fields but I cannot see my hidden score field in the dropdown, so I've opted for a script:
$score = $form->GetFieldValue('score'); // Get the calculated score

$message = '';

if ($score >= 85) {
$message = 'Excellent! You scored 85–100%!';
} elseif ($score >= 65) {
$message = 'Good! You scored 65–84%!';
} elseif ($score >= 40) {
$message = 'Fair! You scored 40–64%.';
} else {
$message = 'Below expectation — you scored below 40%.';
}

// Set the hidden field value
$form->SetFieldValue('scoreMessage', $message);

I placed this in Script called on form process, but it does not work.

May I ask for help again?
The administrator has disabled public write access.

Quiz score 0 1 month 2 weeks ago #44171

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 273
  • Thank you received: 71
Nearly there but you haven't assigned the value of the fied score to the variable$score so try this
// Get the score from the hidden field
$score = isset($_POST['form']['score']) ? (float)$_POST['form']['score'] : 0;
 
// Determine the message
$message = '';
if ($score >= 85) {
    $message = 'Excellent! You scored 85–100%!';
} elseif ($score >= 65) {
    $message = 'Good! You scored 65–84%!';
} elseif ($score >= 40) {
    $message = 'Fair! You scored 40–64%.';
} else {
    $message = 'Below expectation — you scored below 40%.';
}
 
// Set the message in the hidden field or another field
$_POST['form']['scoreMessage'] = $message;
If you can keep your head when all about you are losing theirs, you obviously don't understand the situation!
The administrator has disabled public write access.

Quiz score 0 1 month 2 weeks ago #44172

  • liz9
  • liz9's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
BLESS YOU!!!!!!!!
Thank you, thank you, thank you so much!!!!!!!!
The administrator has disabled public write access.

Quiz score 0 1 month 2 weeks ago #44173

  • dragos
  • dragos's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 667
  • Thank you received: 122
Hello,

If you want to display different text based on the score result within the Thank You Message / User / Admin emails, you can try the {if} syntax, instead of a custom scripting approach. Details here.

For example:
{if {score:value}>=85}Excellent! You scored 85100%!{/if}
 
{if {score:value}<=84}
	{if {score:value}>=65}
		Good! You scored 6584%
	{/if}
{/if}
 
{if {score:value}<=64}
	{if {score:value}>=40}
		Fair! You scored 4064%
	{/if}
{/if}
 
{if {score:value}<=39}Below expectation — you scored below 40%{/if}
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!