Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Public Member Functions | |
can_add_section_heading ($pagenumber) | |
Check whether adding a section heading is possible. | |
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. | |
formatted_question_grade ($slotnumber) | |
Get the maximum mark for a question, formatted for display. | |
formatted_quiz_grade () | |
Get the overall quiz grade formatted for display. | |
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_dates_summary () | |
Get the date information about the current state of the quiz. | |
get_decimal_places_for_grades () | |
Get the number of decimal places for displaying overall quiz grades or marks. | |
get_decimal_places_for_question_marks () | |
Get the number of decimal places for displaying question marks. | |
get_displayed_number_for_slot ($slotnumber) | |
Get the displayed question number (or 'i') for a given slot. | |
get_edit_page_warnings () | |
Get any warnings to show at the top of the edit page. | |
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_section_by_id ($sectionid) | |
Get a particular section by id. | |
get_section_count () | |
Get the number of questions in the quiz. | |
get_sections () | |
Get all the sections 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. | |
get_slots_in_section ($sectionid) | |
Get all the slots in a section of the quiz. | |
get_version_choices_for_slot (int $slotnumber) | |
Get the version options to show on the 'Questions' page for a particular question. | |
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. | |
move_slot ($idmove, $idmoveafter, $page) | |
Move a slot from its current location to a new location. | |
populate_slots_with_sections () | |
Fill in the section ids for each slot. | |
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[] array | $gradeitems = [] |
quiz_grade_items for this quiz indexed by id. | |
stdClass[] | $questions = [] |
the questions in this quiz. | |
quiz_settings | $quizobj = null |
the quiz this is the structure of. | |
stdClass[] | $sections = [] |
this quiz's data from the quiz_sections table. | |
stdClass[] | $slotsinorder = [] |
quiz_slots.slot => the quiz_slots rows for this quiz, augmented by sectionid. | |
mod_quiz\structure::can_add_section_heading | ( | $pagenumber | ) |
Check whether adding a section heading is possible.
int | $pagenumber | the number of the page. |
boolean |
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::formatted_question_grade | ( | $slotnumber | ) |
Get the maximum mark for a question, formatted for display.
int | $slotnumber | the index of the slot in question. |
string | the maximum mark for the question in this slot. |
mod_quiz\structure::formatted_quiz_grade | ( | ) |
Get the overall quiz grade formatted for display.
string | the maximum grade for this quiz. |
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_dates_summary | ( | ) |
Get the date information about the current state of the quiz.
string[] | array of two strings. First a short summary, then a longer explanation of the current state, e.g. for a tool-tip. |
mod_quiz\structure::get_decimal_places_for_grades | ( | ) |
Get the number of decimal places for displaying overall quiz grades or marks.
int | the number of decimal places. |
mod_quiz\structure::get_decimal_places_for_question_marks | ( | ) |
Get the number of decimal places for displaying question marks.
int | the number of decimal places. |
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_edit_page_warnings | ( | ) |
Get any warnings to show at the top of the edit page.
string[] | array of strings. |
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_section_by_id | ( | $sectionid | ) |
Get a particular section by id.
stdClass | the section. |
mod_quiz\structure::get_section_count | ( | ) |
Get the number of questions in the quiz.
int | the number of questions in the quiz. |
mod_quiz\structure::get_sections | ( | ) |
Get all the sections of the quiz.
stdClass[] | the sections in this 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::get_slots_in_section | ( | $sectionid | ) |
Get all the slots in a section of the quiz.
int | $sectionid | the section id. |
int[] | slot numbers. |
mod_quiz\structure::get_version_choices_for_slot | ( | int | $slotnumber | ) |
Get the version options to show on the 'Questions' page for a particular question.
int | $slotnumber | which slot to get the choices for. |
stdClass[] | other versions of this question. Each object has fields versionid, version and selected. Array is returned most recent version first. |
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 |
mod_quiz\structure::move_slot | ( | $idmove, | |
$idmoveafter, | |||
$page ) |
Move a slot from its current location to a new location.
After calling this method, this class will be in an invalid state, and should be discarded if you want to manipulate the structure further.
int | $idmove | id of slot to be moved |
int | $idmoveafter | id of slot to come before slot being moved |
int | $page | new page number of slot being moved |
|
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 |
this quiz's data from the quiz_sections table.
Each item has a ->lastslot field too.