Option 1) To create a new quiz, copy a template folder from /Views/Quiz/Templates to the /Views/Quiz directory and rename it. The name of your new directory is the unique identifier of your quiz.
Option 2) Use the create a quiz feature by clicking on one of the templates on the home page, and then specifying the quiz name and number of questions. The website will copy perform all of the steps in Option 1 for you. You will however have to use the "show all files" feature in Visual Studio to include the new quiz folder in your Visual Studio project.
Take a moment to configure the quiz settings in the quiz.json file:
The welcome message and instructions can be placed in Index.cshtml.
Copy the Q.cshtml file from the Questions sub-directory of your new directory into the same directory, and rename it to Q1.cshtml.
Q1.cshtml contains the question and answers for question #1 of your quiz.
Edit the contents of the Q1.cshtml file.
Repeat steps 2 and 3 until you are done. Feel free to run the solution and view your quiz at any time during your development process.
Remember that you can edit your views, CSS files and JavaScript files while the solution is running. Simply refresh your browser when the you've saved your changes in Visual Studio. In fact, changes to the CSS files are reflected immediately in your browser while the solution is running (only tested in IE 11+).
Ensure that any custom files for your quiz are stored in the Content/Quiz/quiz-id for your quiz.
To reference these files, you can use the syntax ~/Content/Quiz/quiz-id/filename.ext for attributes such as href or src, or the helper method @Html.Content("filename.ext") (the second option is better in case you rename your quiz!)
Note that @Html.Content() is not the same as @Url.Content(), the later of which requires a full virtual URL (e.g.: ~/Content/Quiz/quiz-id/filename.ext).
The markup for the quizes are fully customizable, as long as you follow these guidelines:
The quiz attempt is currently saved in the session state. Everytime you run the solution, you will be starting over. If the solution is hosted on a web server, the session will expire every time that the solution is deployed or after a period of inactivity.
Once the data-access layer is implemented, the results will be saved in a database automatically. You will not be required to make any changes to your quiz in order to have save and restore functionality.
However, if changes are made to your quiz which would invalidate a previous incomplete attempt at the quiz, the user will have to restart. Changes that would prompt a restart consists of changing the number of questions, the number of answers for a question, or the position of the correct answer in a question.
You can also force the invalidation of incomplete attempts at your quiz by incrementing the value of ViewBag.QuizVersion in Questions/_Layout.cshtml before publishing to production.
Back to List of Quizes