Hello,
I need to show immediate score for a technical test. using the check box as shown below.
This is a recruitment form for new candidates in an interview.
I need each checked question value to be added to the score.
Like the value is 7.14 for each questions, and if he answered three questions the score will be 21.42.
Whatever the numbers I need to make SUM for the value of the correct questions.
I tried the function but it show the ID like 1024,1025,1026 when count and show 1024 in SUM.
Each line (record) is a new comer test So I need the calculations be done for each line (record) and not for the table list.
Thank you
Show field type "check box" values sum
-
- Posts: 88
- Joined: 09 May 2017, 11:10
- Name: Ahmed Reda
- Location: Egypt
- Company Name: kalaweeza.com
- Contact:
Re: Show field type "check box" values sum
Hi,
Sure, you can make this with ajax field and put this code :
Also, do you need JS verification to block the submission if the total is not ok ?
Sure, you can make this with ajax field and put this code :
Code: Select all
$list = [123]; //id of the checkbox field
$total_query = db_query("select SUM(value) as total from app_fields_choices where id in ($list)",false); //use "app_fields_choices" if list of choices is directly in the checkbox field without a global list, and "app_global_lists_choices" if list of choices is a global list
$value = 0; //total value by default
if($total = db_fetch_array($total_query))
{
$value = $total['total'] ?? $value;
echo $value; //output value, or delete this line if you don't want to display it in the form
$form_field_value = $value; //value to save in database, or delete this line if you don't want to save it in the database
}
Also, do you need JS verification to block the submission if the total is not ok ?
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
-
- Posts: 88
- Joined: 09 May 2017, 11:10
- Name: Ahmed Reda
- Location: Egypt
- Company Name: kalaweeza.com
- Contact:
Re: Show field type "check box" values sum
Thank you for your help
I have made as shown in the images below. - I need in the Answered field number "4".
- Each Technical Question have a value and I checked "Display option values". It shows the fields ID as appear. The number of questions are 14 and each answer value is 7.14 so all count 100 of 100 so I need it to be viewed as like "21".
Do you see this is a good idea or you have better method for exam percentage.
I have made as shown in the images below. - I need in the Answered field number "4".
- Each Technical Question have a value and I checked "Display option values". It shows the fields ID as appear. The number of questions are 14 and each answer value is 7.14 so all count 100 of 100 so I need it to be viewed as like "21".
Do you see this is a good idea or you have better method for exam percentage.
Re: Show field type "check box" values sum
For score : you need an Ajax field not a JS formula. I gave you a php code not a JS.
https://docs.rukovoditel.net/index.php?p=99
For the other question. I will answer you later in the day .
https://docs.rukovoditel.net/index.php?p=99
For the other question. I will answer you later in the day .
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
Re: Show field type "check box" values sum
I didn't know but with JS formula is more simple (calculation is automatic) :
where 123 is the list of checkboxes field
For your total of checked (in a JS formula too) :
where 123 is the list of checkboxes field
You can also count the total of checked and in the other formula (score) do (and change the output number with 0 for decimals in options if you want) :
where 456 is the field for the count
Code: Select all
get_value([123])
For your total of checked (in a JS formula too) :
Code: Select all
countChecks(String([123]));
function countChecks(x)
{
if (x === '') {
return 0;
}
return x.split(',').length;
}
You can also count the total of checked and in the other formula (score) do (and change the output number with 0 for decimals in options if you want) :
Code: Select all
[456]*7.14
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
-
- Posts: 88
- Joined: 09 May 2017, 11:10
- Name: Ahmed Reda
- Location: Egypt
- Company Name: kalaweeza.com
- Contact:
Re: Show field type "check box" values sum
Thank you for the care
I'm happy to show you the result.
Form in list view And below each item field for reference for any friend need it later.
Answered:
get_value([1571])/7 Suffix of 14
Score:
$list = [1571]; //id of the checkbox field
$total_query = db_query("select SUM(value) as total from app_fields_choices where id in ($list)",false); //use "app_fields_choices" if list of choices is directly in the checkbox field without a global list, and "app_global_lists_choices" if list of choices is a global list
$value = 0; //total value by default
if($total = db_fetch_array($total_query))
{
$value = $total['total'] ?? $value;
echo $value; //output value, or delete this line if you don't want to display it in the form
$form_field_value = $value; //value to save in database, or delete this line if you don't want to save it in the database
}
Technical Suggestion (was Decision):
if([1573]>80,'Accepted','Rejected')
I'm happy to show you the result.
Form in list view And below each item field for reference for any friend need it later.
Answered:
get_value([1571])/7 Suffix of 14
Score:
$list = [1571]; //id of the checkbox field
$total_query = db_query("select SUM(value) as total from app_fields_choices where id in ($list)",false); //use "app_fields_choices" if list of choices is directly in the checkbox field without a global list, and "app_global_lists_choices" if list of choices is a global list
$value = 0; //total value by default
if($total = db_fetch_array($total_query))
{
$value = $total['total'] ?? $value;
echo $value; //output value, or delete this line if you don't want to display it in the form
$form_field_value = $value; //value to save in database, or delete this line if you don't want to save it in the database
}
Technical Suggestion (was Decision):
if([1573]>80,'Accepted','Rejected')
-
- Posts: 88
- Joined: 09 May 2017, 11:10
- Name: Ahmed Reda
- Location: Egypt
- Company Name: kalaweeza.com
- Contact:
Re: Show field type "check box" values sum
Good job !!! And good idea the « suffix »
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)