[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/quiz/classes/ -> structure.php (summary)

Defines the \mod_quiz\structure class.

Copyright: 2013 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 684 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

structure:: (34 methods):
  create()
  create_for_quiz()
  has_questions()
  get_question_count()
  get_question_by_id()
  get_question_in_slot()
  get_cmid()
  get_quizid()
  get_quiz()
  is_shuffled()
  can_be_repaginated()
  can_be_edited()
  check_can_be_edited()
  get_questions_per_page()
  get_slots()
  is_first_slot_on_page()
  is_last_slot_on_page()
  is_last_slot_in_quiz()
  get_last_slot()
  get_slot_by_id()
  get_questions_in_section()
  get_quiz_sections()
  get_edit_page_warnings()
  get_dates_summary()
  populate_structure()
  populate_missing_questions()
  populate_slots_with_sectionids()
  populate_question_numbers()
  move_slot()
  refresh_page_numbers()
  refresh_page_numbers_and_update_db()
  remove_slot()
  update_slot_maxmark()
  update_page_break()


Class: structure  - X-Ref

Quiz structure class.

The structure of the quiz. That is, which questions it is built up
from. This is used on the Edit quiz page (edit.php) and also when
starting an attempt at the quiz (startattempt.php). Once an attempt
has been started, then the attempt holds the specific set of questions
that that student should answer, and we no longer use this class.

create()   X-Ref
Create an instance of this class representing an empty quiz.

return: structure

create_for_quiz($quizobj)   X-Ref
Create an instance of this class representing the structure of a given quiz.

param: \quiz $quizobj the quiz.
return: structure

has_questions()   X-Ref
Whether there are any questions in the quiz.

return: bool true if there is at least one question in the quiz.

get_question_count()   X-Ref
Get the number of questions in the quiz.

return: int the number of questions in the quiz.

get_question_by_id($questionid)   X-Ref
Get the information about the question with this id.

param: int $questionid The question id.
return: \stdClass the data from the questions table, augmented with

get_question_in_slot($slotnumber)   X-Ref
Get the information about the question in a given slot.

param: int $slotnumber the index of the slot in question.
return: \stdClass the data from the questions table, augmented with

get_cmid()   X-Ref
Get the course module id of the quiz.

return: int the course_modules.id for the quiz.

get_quizid()   X-Ref
Get id of the quiz.

return: int the quiz.id for the quiz.

get_quiz()   X-Ref
Get the quiz object.

return: \stdClass the quiz settings row from the database.

is_shuffled()   X-Ref
Whether the question in the quiz are shuffled for each attempt.

return: bool true if the questions are shuffled.

can_be_repaginated()   X-Ref
Quizzes can only be repaginated if they have not been attempted, the
questions are not shuffled, and there are two or more questions.

return: bool whether this quiz can be repaginated.

can_be_edited()   X-Ref
Quizzes can only be edited if they have not been attempted.

return: bool whether the quiz can be edited.

check_can_be_edited()   X-Ref
This quiz can only be edited if they have not been attempted.
Throw an exception if this is not the case.


get_questions_per_page()   X-Ref
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.

return: int the number of questions that should be on each page of the

get_slots()   X-Ref
Get quiz slots.

return: \stdClass[] the slots in this quiz.

is_first_slot_on_page($slotnumber)   X-Ref
Is this slot the first one on its page?

param: int $slotnumber the index of the slot in question.
return: bool whether this slot the first one on its page.

is_last_slot_on_page($slotnumber)   X-Ref
Is this slot the last one on its page?

param: int $slotnumber the index of the slot in question.
return: bool whether this slot the last one on its page.

is_last_slot_in_quiz($slotnumber)   X-Ref
Is this slot the last one in the quiz?

param: int $slotnumber the index of the slot in question.
return: bool whether this slot the last one in the quiz.

get_last_slot()   X-Ref
Get the final slot in the quiz.

return: \stdClass the quiz_slots for for the final slot in the quiz.

get_slot_by_id($slotid)   X-Ref
Get a slot by it's id. Throws an exception if it is missing.

param: int $slotid the slot id.
return: \stdClass the requested quiz_slots row.

get_questions_in_section($sectionid)   X-Ref
Get all the questions in a section of the quiz.

param: int $sectionid the section id.
return: \stdClass[] of question/slot objects.

get_quiz_sections()   X-Ref
Get all the sections of the quiz.

return: \stdClass[] the sections in this quiz.

get_edit_page_warnings()   X-Ref
Get any warnings to show at the top of the edit page.

return: string[] array of strings.

get_dates_summary()   X-Ref
Get the date information about the current state of the quiz.

return: string[] array of two strings. First a short summary, then a longer

populate_structure($quiz)   X-Ref
Set up this class with the structure for a given quiz.

param: \stdClass $quiz the quiz settings.

populate_missing_questions($slots)   X-Ref
Used by populate. Make up fake data for any missing questions.

param: \stdClass[] $slots the data about the slots and questions in the quiz.
return: \stdClass[] updated $slots array.

populate_slots_with_sectionids()   X-Ref
Fill in the section ids for each slot.


populate_question_numbers()   X-Ref
Number the questions.


move_slot($idmove, $idbefore, $page)   X-Ref
Move a slot from its current location to a new location.

After callig this method, this class will be in an invalid state, and
should be discarded if you want to manipulate the structure further.

param: int $idmove id of slot to be moved
param: int $idbefore id of slot to come before slot being moved
param: int $page new page number of slot being moved
return: void

refresh_page_numbers($quiz, $slots=array()   X-Ref
Refresh page numbering of quiz slots.

param: \stdClass $quiz the quiz object.
param: \stdClass[] $slots (optional) array of slot objects.
return: \stdClass[] array of slot objects.

refresh_page_numbers_and_update_db($quiz)   X-Ref
Refresh page numbering of quiz slots and save to the database.

param: \stdClass $quiz the quiz object.
return: \stdClass[] array of slot objects.

remove_slot($quiz, $slotnumber)   X-Ref
Remove a slot from a quiz

param: \stdClass $quiz the quiz object.
param: int $slotnumber The number of the slot to be deleted.

update_slot_maxmark($slot, $maxmark)   X-Ref
Change the max mark for a slot.

Saves changes to the question grades in the quiz_slots table and any
corresponding question_attempts.
It does not update 'sumgrades' in the quiz table.

param: \stdClass $slot row from the quiz_slots table.
param: float $maxmark the new maxmark.
return: bool true if the new grade is different from the old one.

update_page_break($quiz, $slotid, $type)   X-Ref
Add/Remove a pagebreak.

Saves changes to the slot page relationship in the quiz_slots table and reorders the paging
for subsequent slots.

param: \stdClass $quiz the quiz object.
param: int $slotid id of slot.
param: int $type repaginate::LINK or repaginate::UNLINK.
return: \stdClass[] array of slot objects.



Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1