Feb 28, 2013 at 3:59 PM
Edited Feb 28, 2013 at 4:25 PM
I'm a .NET developer who has just started getting into MVC and am working on my first Orchard project. I have already viewed the basic and advanced Orchard training videos on PluralSight and have been following tutorials on how to create a custom Orchard
My client's existing WebForms site uses Ektron for its CMS; my task is to rebuild the site in MVC and to use Orchard to recreate some of the central CMS features that the client is used to. One of those features is the ability for the client to create content
for multiple-choice exams or surveys which can then be displayed as a form to the end user, with the users' responses written to the database. We are currently using Ektron's SmartForm feature to create the exam/survey structure. An exam consists of a few
fields that apply to the entire exam (the name of the exam, passing score, etc.) and then any number of repeating blocks of form data representing the questions and their multiple-choice answers. So the Ektron SmartForm would look something like this:
Exam Name: [________________]
Passing Score: [________________]
[remove question -]
Question Text: [________________]
Answer Choice 1: [________________]
Answer Choice 2: [________________]
Answer Choice 3: [________________]
Answer Choice 4: [________________]
Correct Answer: [________________]
[add question +]
The client can add any number of question blocks, remove existing question blocks, etc. My first thought was to create a custom content type in Orchard with fields to match the existing SmartForm, but there doesn't seem to be any way to address the repeating
blocks of question form data. Is there a technique for this that could be implemented in the standard Orchard setup, or is this the kind of feature that would have to be generated by a custom module? Assuming that it's possible to create a new content type
that represents the exam structure above, I still need to a) render the data as a form to the user and b) record the user's responses to the exam form.
If anyone has any ideas about how to approach this type of customization I would very much appreciate the advice. I'm not necessarily looking for detailed instructions for how to implement this, just a broad overview of the best way to approach and design the
feature at this point. Thanks in advance to anyone responding.
Mar 4, 2013 at 9:20 AM
Edited Mar 4, 2013 at 9:20 AM
I guess the simplest way to do it is by attaching the Containable part to Answer and Question and the Container part to Exam and Question.
If the admin experience is not the way you would like it to be, I think you will have to create a custom module.
What you could do is setup the custom content type "Exam", which has a custom content part called ExamPart.
Create content types for Question and Answer. A QuestionPart could have an ExamId and an Answer could have a QuestionId.
Using a custom admin controller, you can create a listings page that lists all Exams. Each Exam row would have a Questions link, which takes the admin to a listings page of Questions for that exam. Each Question row in turn would have an Answers link, taking
the admin to a list view of Answers for that question.
All this is done with custom admin controllers where you have complete freedom in implementing your system.
Since all types are content types, you can reuse the Content Item Editor so that you don't have to redo that when editing a content item.
Alternatively, instead of creating custom controllers, you could have the ExamPartDriver render a list of Questions, from where the user can be taken to the Question content editor. The QuestionPartDriver would in turn render a list of answers, from which the
admin can be taken to an individual answer.
In the end, I think you will need a custom module anyway, so you can render your exams and questions and answers using custom controllers and process the submitted forms.