PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Use GF for Self-Assessment type quiz?

  1. I'd like to create a quiz where each 'answer' is worth a certain amount of points. So, basically something like:

    Q1
    Answer 'A' = 3 points
    Answer 'B' = 2 points

    etc..

    Then, on submission, the forms notification screen shows that they got 'x' points (add up each question's value) and show something like, "if you got 0-5 points, you're this, 6-9 you're that, etc.."

    Is there any way to make GF do this? :)

    Thanks!

    David

    Posted 13 years ago on Friday March 4, 2011 | Permalink
  2. Not without custom code. Scoring/Grading isn't currently a built in feature. You would have to write custom code to handle this and then store the score/etc. in a hidden field after doing the calculation.

    Posted 13 years ago on Friday March 4, 2011 | Permalink
  3. One other question; is there any way to use to pass, using the querystring, the 'value' (as opposed to the choice) in a multiple-choice field? i.e. {Q1:1} returns the choice, not the value. I'd like it to return the value, if possible?

    David

    Posted 13 years ago on Friday March 4, 2011 | Permalink
  4. Yes, you append :value to the end of the form field variable.

    So instead of:

    {Q1:1}

    You would use:

    {Q1:1:value}

    Posted 13 years ago on Friday March 4, 2011 | Permalink
  5. I ended up doing this in functions.php

    add_action("gform_pre_submission", "pre_submission_handler");
    function pre_submission_handler($form_meta){
    	if($form_meta["id"] == '1'){
    		$total_value = 0;
    		foreach($form_meta["fields"] as $field){
    			$value = $_POST["input_" . $field["id"]];
    			$total_value = $total_value + $value;
    		}
    		$_POST["input_8"] = $total_value;
    	}
    	return $form;
    }

    I'm sure there's a more elegant way, but, this worked.

    input_8 is a hidden field to store the cumulative value.

    I turned on 'values' and each multiple choice answer got assigned the point value I wanted.

    I'm posting this here in the hopes that it can 1) help someone else, and 2) others can help me improve on this :)

    What I'm still not sure on is how I can retrieve the hidden field value easily? Or, if there's any easy way to use a querystring to selectively hide/show the "results" on the confirmation page.

    I guess what would be nice would be to have some sort of scripting ability on the notification page so that I can do something like [if input_8 >= 2 || input_8 <= 4 then....]

    Anyways, just a thought.

    David

    Posted 13 years ago on Sunday March 6, 2011 | Permalink