-
Notifications
You must be signed in to change notification settings - Fork 13
Pages in the project
We could spend a bunch of time explaining what each file in the folder structure does. Instead we will illustrate how a user travels through the plugin, and what files he meets at what stages in his interaction. Most of the .php files makes use of the repository to query quiz related data, hence the big circle around all the files. When we have queried the database, we instantiate model classes defined in the classes/models folder.
The first file the user meets. This file is mandatory in a Moodle Activity module and serves as the "entrypoint" for our user interaction. It ensures the user is logged in and has the necessary permissions to access the module. Depending on the user's capabilities, it renders either the teacher's or the student's view of the live quiz. It sets up the page context, includes necessary styles, queries the DB and creates an instance of a LiveQuiz that can be used in the backend, and outputs the appropriate content using Moodle's rendering system. All .php files which format and pass data to mustache templates are situated in the output folder and contain the substring _page
A student is shown two things when he has entered the LiveQuiz plugin:
- The index page, where other templates are rendered (index_page.mustache)
- A button to take the livequiz (take_quiz_button.mustache)
- A list of his previous participations (participations_section.mustache)
(YES... This page did not receive any styling :( )
This file is reponsible for preparing a data object to pass to the templates in order to render them. This data object is based on the LiveQuiz instance queried from the database. All .php files in the output folder have the same responsibillity: Prepare data for a template.
A teacher can see / trigger the following UI elements from the index page:
- The main quiz editing page where you can trigger, adding questions and importing questions. Contains all other templates (defined in quiz_editor_page.mustache)
- A list of questions which are already contained in the quiz, together with editing and deletion of question buttons (saved_questions_list.mustache)
- A menu for adding questions to a quiz (question_menu_popup.mustache)
- A menu for editing questions in a quiz (question_menu_popup.mustache)
- A menu for importing questions from other quizzes (import_questions_list.mustache)
Before a teacher or student is able to take the quiz, they are routed through attempt.php. This file is responsible for creating two session variables:
-
$_SESSION['completed']
- Set to 1 when the student completes the quiz. Used to block the student from going back to answering the quiz after he has submitted it. -
$_SESSION['quiz_answers']
- Stores the answers while answering the quiz. After the student submits the quiz,$_SESSION['quiz_answers']
is read and stored in the database for future use when showing results
This file provides the following UI elements with data:
- A main page containing all other templates (take_livequiz_page.mustache)
- A section displaying the current question and the answer options you can select (question_section.mustache)
- A section where you can go to the next or previous question (side_bar_section.mustache)
- A button allowing you to submit the quiz (nav_bar_section.mustache)
Fetches the relevant quiz and participation data, either the latest participation or a specific one based on the provided index. It then sets up the page URL, title, and heading, and renders the results_page.php wich displays:
- All the questions in the LiveQuiz with the answers the students has provided (results_page.mustache and question_section.mustache)
- Correct answers are marked with green, incorrect with red, and unanswered correct answers with yellow
- A way to return to the LiveQuiz index page