<p>This is a very broad question, and I'm not sure you're going to get a very good answer without being more specific. Whether or not this is possible without the aid of a plugin would entirely depend on how you designed the system, and what the needs are. I can certainly imagine ways to accomplish this without the use of a plugin. With that said, I also think that you could probably make for a much more robust system with a better user experience with the aid of some simple plugins. But I also wouldn't let plugins scare you. Writing a plugin is surprisingly easy (depending on the complexity of course). As a front-end developer myself, I have written several with little difficulty, so I can attest to this. I would focus on designing a system that makes the most sense from a user perspective and then build it accordingly, even if that means learning to write some simple plugins.</p>

<p>As a starting point (without plugins) you might try and approach the problem this way.</p>

<ul>
<li>Create a channel (or structure if multiple tests are used; using a test/question hierarchy) to store question entries, which would include the question, possible answers, and the correct answer (i.e. <code>structure</code> with handle 'tests' or 'modules' or whatever you want to call it).</li>
<li>Create a channel for user submitted answers with the user's answer and related fields to store a reference to the original question, and the user that submitted the answer (i.e. <code>channel</code> with handle 'testResults' or whatever you want to call it).</li>
<li>Create a form that presents a question (from the 'tests' structure) and the possible answers (as a radio button for example if multiple choice) that gets submitted to the 'testResults' channel.</li>
<li>Include hidden fields on the form with the question id, and user id, to populate the corresponding related 'entries' and related 'users' fields in the 'testResults' entry.</li>
<li>In the form success redirect you can load the form submission as well as the original question/answer, compare them and display if they are correct or not.</li>
<li>In the user profile template, you can then load all test entries (questions) and testResult entries (answers) for that user and compare them to display both whether specific questions were answered correctly and their overall test score.</li>
</ul>

<p>Note that the data is not stored as part of the user profile per se; rather the user is only associated to the data via a related user field. And if you always look up the questions and answers and compare them to get the score then there would be no real need for a plugin. Where you might want a plugin is if you want to store the test results independently, or their overall progress, or other summary data, etc. But like I said above, writing a plugin to do this is not that complicated.</p>

<p>This assumes of course that the admin would view the user's profile and Q&amp;A via the front-end. This is also by no means the only way, just an example of how it might be done.</p>

CC BY-SA 3.0
2015-01-09T11:06:35.037Z
Thanks for the encouragement Douglas. I've done a few similar things before but plugin development does scare me! I'll have to embark on learning how to do it anyway independently of this project I think. That being said, your answer is how I'd intended to approach it but lays it out clearly, thank you!
darylknight
CC BY-SA 3.0
2015-01-09T01:24:08.963Z
2015-01-09T01:32:46.160Z
2015-01-09T01:32:46.160Z
Douglas McDonald
<p>The catch is, it sounds like you need to <strong>add an entry</strong> and <strong>modify user data</strong> all in a single shot. That's not really possible out-of-the-box... different forms will submit to different places.</p>

<ul>
<li><a href="http://buildwithcraft.com/docs/templating/entry-form" rel="nofollow">Edit an Entry</a></li>
<li><a href="http://buildwithcraft.com/docs/templating/user-profile-form" rel="nofollow">Edit a User Profile</a></li>
</ul>

<p>One possible solution is to create an intermediary page:</p>

<ol>
<li>First page is your test form,</li>
<li>Upon submission, creates a new entry. (Edit an Entry)</li>
<li><strong>Then redirects to a second page,</strong></li>
<li>Second page displays the results, and offers to "Save the results",</li>
<li>Upon submission, saves results to user profile. (Edit a User Profile)</li>
</ol>

<p>It's pretty rough, to be honest. If you know any PHP at all, I'd highly recommend using this project to teach yourself a little plugin development. If you build some customized Controllers and Services to handle this data, you'll end up with a far more robust solution.</p>

<p>Sounds like a fun project... Let us know what architecture you decide to go with!</p>

CC BY-SA 3.0
2015-01-09T01:30:17.697Z
Hey Lindsey. Didn't see your answer before I started mine. But I agree with you - a plugin of some kind would probably be helpful here.
Douglas McDonald
CC BY-SA 3.0
2015-01-09T11:07:49.400Z
Thanks for your answer Lindsey - I think some plugin learning might be in order regardless of this project! I've done some PHP in the past... might be time to dig it up again.
darylknight
CC BY-SA 3.0
2015-01-09T17:00:20.057Z
Glad to help. I think once you dive into plugin dev, you'll find it's actually not too scary (after you get past the initial learning curve). And like @Douglas said in his answer, it will greatly expand the amount of things you can do with your site. Good luck with your project!
Lindsey D
CC BY-SA 3.0
2015-01-09T00:17:37.377Z
2015-01-09T00:17:37.377Z
Lindsey D
<p>I've had a potential job come through that I want to run on Craft, but I'm a bit sketchy about one particularly bit. The site is going to include educational modules and tests for each. Test results will be stored in their profile which can be reviewed the admins. I know how to create a new entry for each test submission, but the thing I'm not sure about is this:</p>

<p>How can I store whether a question was answered correctly or not?
Is there a way to display a score based on the test result?</p>

<p>As always, I'm not a plugin developer... if this can be done with template logic that would be perfect.</p>

<entries>
Education test website Q&A - how?
# Education test website Q&A - how?

(Asked by: username_0 on 2015-01-08)

I've had a potential job come through that I want to run on Craft, but I'm a bit sketchy about one particularly bit. The site is going to include educational modules and tests for each. Test results will be stored in their profile which can be reviewed the admins. I know how to create a new entry for each test submission, but the thing I'm not sure about is this:

How can I store whether a question was answered correctly or not?
Is there a way to display a score based on the test result?

As always, I'm not a plugin developer... if this can be done with template logic that would be perfect.

**Tags:** entries

---

## 2 answers

### Answer by username_1 on 2015-01-09. Score: 2 | Accepted answer

This is a very broad question, and I'm not sure you're going to get a very good answer without being more specific. Whether or not this is possible without the aid of a plugin would entirely depend on how you designed the system, and what the needs are. I can certainly imagine ways to accomplish this without the use of a plugin. With that said, I also think that you could probably make for a much more robust system with a better user experience with the aid of some simple plugins. But I also wouldn't let plugins scare you. Writing a plugin is surprisingly easy (depending on the complexity of course). As a front-end developer myself, I have written several with little difficulty, so I can attest to this. I would focus on designing a system that makes the most sense from a user perspective and then build it accordingly, even if that means learning to write some simple plugins.

As a starting point (without plugins) you might try and approach the problem this way.

* Create a channel (or structure if multiple tests are used; using a test/question hierarchy) to store question entries, which would include the question, possible answers, and the correct answer (i.e. `structure` with handle 'tests' or 'modules' or whatever you want to call it).
* Create a channel for user submitted answers with the user's answer and related fields to store a reference to the original question, and the user that submitted the answer (i.e. `channel` with handle 'testResults' or whatever you want to call it).
* Create a form that presents a question (from the 'tests' structure) and the possible answers (as a radio button for example if multiple choice) that gets submitted to the 'testResults' channel.
* Include hidden fields on the form with the question id, and user id, to populate the corresponding related 'entries' and related 'users' fields in the 'testResults' entry.
* In the form success redirect you can load the form submission as well as the original question/answer, compare them and display if they are correct or not.
* In the user profile template, you can then load all test entries (questions) and testResult entries (answers) for that user and compare them to display both whether specific questions were answered correctly and their overall test score.

Note that the data is not stored as part of the user profile per se; rather the user is only associated to the data via a related user field. And if you always look up the questions and answers and compare them to get the score then there would be no real need for a plugin. Where you might want a plugin is if you want to store the test results independently, or their overall progress, or other summary data, etc. But like I said above, writing a plugin to do this is not that complicated.

This assumes of course that the admin would view the user's profile and Q&A via the front-end. This is also by no means the only way, just an example of how it might be done.

> **Comments:**
> **username_0**: Thanks for the encouragement Douglas. I've done a few similar things before but plugin development does scare me! I'll have to embark on learning how to do it anyway independently of this project I think. That being said, your answer is how I'd intended to approach it but lays it out clearly, thank you!  

---

### Answer by username_2 on 2015-01-09. Score: 3

The catch is, it sounds like you need to **add an entry** and **modify user data** all in a single shot. That's not really possible out-of-the-box... different forms will submit to different places.

* [Edit an Entry](http://buildwithcraft.com/docs/templating/entry-form)
* [Edit a User Profile](http://buildwithcraft.com/docs/templating/user-profile-form)

One possible solution is to create an intermediary page:

1. First page is your test form,
2. Upon submission, creates a new entry. (Edit an Entry)
3. **Then redirects to a second page,**
4. Second page displays the results, and offers to "Save the results",
5. Upon submission, saves results to user profile. (Edit a User Profile)

It's pretty rough, to be honest. If you know any PHP at all, I'd highly recommend using this project to teach yourself a little plugin development. If you build some customized Controllers and Services to handle this data, you'll end up with a far more robust solution.

Sounds like a fun project... Let us know what architecture you decide to go with!

> **Comments:**
> **username_1**: Hey Lindsey. Didn't see your answer before I started mine. But I agree with you - a plugin of some kind would probably be helpful here.  
> **username_0**: Thanks for your answer Lindsey - I think some plugin learning might be in order regardless of this project! I've done some PHP in the past... might be time to dig it up again.  
> **username_2**: Glad to help. I think once you dive into plugin dev, you'll find it's actually not too scary (after you get past the initial learning curve). And like @Douglas said in his answer, it will greatly expand the amount of things you can do with your site. Good luck with your project!  

---

