Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Public Member Functions | |
can_be_edited () | |
Quizzes can only be edited if they have not been attempted. | |
can_be_repaginated () | |
Quizzes can only be repaginated if they have not been attempted, the questions are not shuffled, and there are two or more questions. | |
can_display_number_be_customised (int $slotnumber) | |
Check the question has a number that could be customised. | |
can_finish_during_the_attempt ($slotnumber) | |
Whether it is possible for another question to depend on this one finishing. | |
can_question_depend_on_previous_slot ($slotnumber) | |
Whether it would be possible, given the question types, etc. | |
check_can_be_edited () | |
This quiz can only be edited if they have not been attempted. | |
get_cmid () | |
Get the course module id of the quiz. | |
get_context () | |
Get the quiz context. | |
get_courseid () | |
Get the course id that the quiz belongs to. | |
get_displayed_number_for_slot ($slotnumber) | |
Get the displayed question number (or 'i') for a given slot. | |
get_last_slot () | |
Get the final slot in the quiz. | |
get_page_number_for_slot ($slotnumber) | |
Get the page a given slot is on. | |
get_question_by_id ($questionid) | |
Get the information about the question with this id. | |
get_question_count () | |
Get the number of questions in the quiz. | |
get_question_in_slot ($slotnumber) | |
Get the information about the question in a given slot. | |
get_question_name_in_slot ($slotnumber) | |
Get the name of the question in a given slot. | |
get_question_type_for_slot ($slotnumber) | |
Get the question type in a given slot. | |
get_questions_per_page () | |
How many questions are allowed per page in the quiz. | |
get_quiz () | |
Get the quiz object. | |
get_quizid () | |
Get id of the quiz. | |
get_slot_by_id ($slotid) | |
Get a slot by its id. | |
get_slot_by_number ($slotnumber) | |
Get a slot by its slot number. | |
get_slot_id_for_slot ($slotnumber) | |
Get the slot id of a given slot slot. | |
get_slots () | |
Get quiz slots. | |
has_questions () | |
Whether there are any questions in the quiz. | |
has_use_capability (int $slotnumber) | |
Does the current user have '...use' capability over the question(s) in a given slot? | |
is_display_number_customised (int $slotid) | |
Check whether the question number is customised. | |
is_first_section ($section) | |
Is this the first section in the quiz? | |
is_first_slot_on_page ($slotnumber) | |
Is this slot the first one on its page? | |
is_last_section ($section) | |
Is this the last section in the quiz? | |
is_last_slot_in_quiz ($slotnumber) | |
Is this slot the last one in the quiz? | |
is_last_slot_in_section ($slotnumber) | |
Is this slot the last one in its section? | |
is_last_slot_on_page ($slotnumber) | |
Is this slot the last one on its page? | |
is_only_one_slot_in_section ($section) | |
Does this section only contain one slot? | |
is_only_slot_in_section ($slotnumber) | |
Is this slot the only one in its section? | |
is_question_dependent_on_previous_slot ($slotnumber) | |
Whether it would be possible, given the question types, etc. | |
is_real_question ($slotnumber) | |
Is a particular question in this attempt a real question, or something like a description. | |
make_slot_display_number_in_place_editable (int $slotid, context $context) | |
Make slot display number in place editable api call. | |
Static Public Member Functions | |
static | create () |
Create an instance of this class representing an empty quiz. | |
static | create_for_quiz ($quizobj) |
Create an instance of this class representing the structure of a given quiz. | |
Protected Attributes | |
bool | $canaddrandom = null |
caches the results of can_add_random_question. | |
bool | $canbeedited = null |
caches the results of can_be_edited. | |
stdClass[] | $questions = [] |
the questions in this quiz. | |
quiz_settings | $quizobj = null |
the quiz this is the structure of. | |
stdClass[] | $sections = [] |
currently a dummy. | |
stdClass[] | $slotsinorder = [] |
quiz_slots.slot => the quiz_slots rows for this quiz, augmented by sectionid. | |
mod_quiz\structure::can_be_edited | ( | ) |
Quizzes can only be edited if they have not been attempted.
bool | whether the quiz can be edited. |
mod_quiz\structure::can_be_repaginated | ( | ) |
Quizzes can only be repaginated if they have not been attempted, the questions are not shuffled, and there are two or more questions.
bool | whether this quiz can be repaginated. |
mod_quiz\structure::can_display_number_be_customised | ( | int | $slotnumber | ) |
Check the question has a number that could be customised.
int | $slotnumber |
bool |
mod_quiz\structure::can_finish_during_the_attempt | ( | $slotnumber | ) |
Whether it is possible for another question to depend on this one finishing.
Note that the answer is not exact, because of random questions, and sometimes questions cannot be depended upon because of quiz options.
int | $slotnumber | the index of the slot in question. |
bool | can this question finish naturally during the attempt? |
mod_quiz\structure::can_question_depend_on_previous_slot | ( | $slotnumber | ) |
Whether it would be possible, given the question types, etc.
for the question in the given slot to require that the previous question had been answered before this one is displayed.
int | $slotnumber | the index of the slot in question. |
bool | can this question require the previous one. |
mod_quiz\structure::check_can_be_edited | ( | ) |
This quiz can only be edited if they have not been attempted.
Throw an exception if this is not the case.
|
static |
Create an instance of this class representing an empty quiz.
structure |
|
static |
Create an instance of this class representing the structure of a given quiz.
quiz_settings | $quizobj | the quiz. |
structure |
mod_quiz\structure::get_cmid | ( | ) |
Get the course module id of the quiz.
int | the course_modules.id for the quiz. |
mod_quiz\structure::get_context | ( | ) |
Get the quiz context.
context_module | the context of the quiz that this is the structure of. |
mod_quiz\structure::get_courseid | ( | ) |
Get the course id that the quiz belongs to.
int | the course.id for the quiz. |
mod_quiz\structure::get_displayed_number_for_slot | ( | $slotnumber | ) |
Get the displayed question number (or 'i') for a given slot.
int | $slotnumber | the index of the slot in question. |
string | the question number ot display for this slot. |
mod_quiz\structure::get_last_slot | ( | ) |
Get the final slot in the quiz.
stdClass | the quiz_slots for the final slot in the quiz. |
mod_quiz\structure::get_page_number_for_slot | ( | $slotnumber | ) |
Get the page a given slot is on.
int | $slotnumber | the index of the slot in question. |
int | the page number of the page that slot is on. |
mod_quiz\structure::get_question_by_id | ( | $questionid | ) |
Get the information about the question with this id.
int | $questionid | The question id. |
stdClass | the data from the questions table, augmented with question_category.contextid, and the quiz_slots data for the question in this quiz. |
mod_quiz\structure::get_question_count | ( | ) |
Get the number of questions in the quiz.
int | the number of questions in the quiz. |
mod_quiz\structure::get_question_in_slot | ( | $slotnumber | ) |
Get the information about the question in a given slot.
int | $slotnumber | the index of the slot in question. |
stdClass | the data from the questions table, augmented with question_category.contextid, and the quiz_slots data for the question in this quiz. |
mod_quiz\structure::get_question_name_in_slot | ( | $slotnumber | ) |
Get the name of the question in a given slot.
int | $slotnumber | the index of the slot in question. |
stdClass | the data from the questions table, augmented with |
mod_quiz\structure::get_question_type_for_slot | ( | $slotnumber | ) |
Get the question type in a given slot.
int | $slotnumber | the index of the slot in question. |
string | the question type (e.g. multichoice). |
mod_quiz\structure::get_questions_per_page | ( | ) |
How many questions are allowed per page in the quiz.
This setting controls how frequently extra page-breaks should be inserted automatically when questions are added to the quiz.
int | the number of questions that should be on each page of the quiz by default. |
mod_quiz\structure::get_quiz | ( | ) |
Get the quiz object.
stdClass | the quiz settings row from the database. |
mod_quiz\structure::get_quizid | ( | ) |
Get id of the quiz.
int | the quiz.id for the quiz. |
mod_quiz\structure::get_slot_by_id | ( | $slotid | ) |
Get a slot by its id.
Throws an exception if it is missing.
int | $slotid | the slot id. |
stdClass | the requested quiz_slots row. |
mod_quiz\structure::get_slot_by_number | ( | $slotnumber | ) |
Get a slot by its slot number.
Throws an exception if it is missing.
int | $slotnumber | The slot number |
stdClass |
coding_exception |
mod_quiz\structure::get_slot_id_for_slot | ( | $slotnumber | ) |
Get the slot id of a given slot slot.
int | $slotnumber | the index of the slot in question. |
int | the page number of the page that slot is on. |
mod_quiz\structure::get_slots | ( | ) |
Get quiz slots.
stdClass[] | the slots in this quiz. |
mod_quiz\structure::has_questions | ( | ) |
Whether there are any questions in the quiz.
bool | true if there is at least one question in the quiz. |
mod_quiz\structure::has_use_capability | ( | int | $slotnumber | ) |
Does the current user have '...use' capability over the question(s) in a given slot?
int | $slotnumber | the index of the slot in question. |
bool | true if they have the required capability. |
mod_quiz\structure::is_display_number_customised | ( | int | $slotid | ) |
Check whether the question number is customised.
int | $slotid |
bool |
mod_quiz\structure::is_first_section | ( | $section | ) |
Is this the first section in the quiz?
stdClass | $section | the quiz_sections row. |
bool | whether this is first section in the quiz. |
mod_quiz\structure::is_first_slot_on_page | ( | $slotnumber | ) |
Is this slot the first one on its page?
int | $slotnumber | the index of the slot in question. |
bool | whether this slot the first one on its page. |
mod_quiz\structure::is_last_section | ( | $section | ) |
Is this the last section in the quiz?
stdClass | $section | the quiz_sections row. |
bool | whether this is first section in the quiz. |
mod_quiz\structure::is_last_slot_in_quiz | ( | $slotnumber | ) |
Is this slot the last one in the quiz?
int | $slotnumber | the index of the slot in question. |
bool | whether this slot the last one in the quiz. |
mod_quiz\structure::is_last_slot_in_section | ( | $slotnumber | ) |
Is this slot the last one in its section?
int | $slotnumber | the index of the slot in question. |
bool | whether this slot the last one on its section. |
mod_quiz\structure::is_last_slot_on_page | ( | $slotnumber | ) |
Is this slot the last one on its page?
int | $slotnumber | the index of the slot in question. |
bool | whether this slot the last one on its page. |
mod_quiz\structure::is_only_one_slot_in_section | ( | $section | ) |
Does this section only contain one slot?
stdClass | $section | the quiz_sections row. |
bool | whether this section contains only one slot. |
mod_quiz\structure::is_only_slot_in_section | ( | $slotnumber | ) |
Is this slot the only one in its section?
int | $slotnumber | the index of the slot in question. |
bool | whether this slot the only one on its section. |
mod_quiz\structure::is_question_dependent_on_previous_slot | ( | $slotnumber | ) |
Whether it would be possible, given the question types, etc.
for the question in the given slot to require that the previous question had been answered before this one is displayed.
int | $slotnumber | the index of the slot in question. |
bool | can this question require the previous one. |
mod_quiz\structure::is_real_question | ( | $slotnumber | ) |
Is a particular question in this attempt a real question, or something like a description.
int | $slotnumber | the index of the slot in question. |
bool | whether that question is a real question. |
mod_quiz\structure::make_slot_display_number_in_place_editable | ( | int | $slotid, |
context | $context ) |
Make slot display number in place editable api call.
int | $slotid | |
context | $context |
core\output\inplace_editable |
|
protected |
the questions in this quiz.
Contains the row from the questions table, with the data from the quiz_slots table added, and also question_categories.contextid.
|
protected |
currently a dummy.
Holds data that will match the quiz_sections, once it exists.