Methods summary
public
|
#
__construct( $file = __FILE__ )
Constructor.
Parameters
Since
1.0.0
|
public
|
#
update_after_lesson_change( integer $post_id )
Update the quiz data when the lesson is changed
Update the quiz data when the lesson is changed
Parameters
|
public
integer
|
#
get_lesson_id( integer $quiz_id )
Get the lesson this quiz belongs to
Get the lesson this quiz belongs to
Parameters
Returns
integer @lesson_id
Since
1.7.2
|
public
boolean
|
#
user_save_quiz_answers_listener( )
user_save_quiz_answers_listener
user_save_quiz_answers_listener
This function hooks into the quiz page and accepts the answer form save post.
Returns
boolean $saved;
Since
1.7.3
|
public static
false
|
#
save_user_answers( array $quiz_answers, array $files, integer $lesson_id, integer $user_id = 0 )
Save the user answers for the given lesson's quiz
Save the user answers for the given lesson's quiz
For this function you must supply all three parameters. If will return false one is left out.
Parameters
- $quiz_answers
- $files
- from global $_FILES
- $lesson_id
- $user_id
Returns
false or int $answers_saved
Since
1.7.4
|
public
array
|
#
get_user_answers( integer $lesson_id, integer $user_id )
Get the user answers for the given lesson's quiz.
Get the user answers for the given lesson's quiz.
This function returns the data that is stored on the lesson as meta and is not compatible with
retrieving data for quiz answer before sensei 1.7.4
Parameters
Returns
array $answers or false
Since
1.7.4
|
public
void;
|
#
reset_button_click_listener( )
This function runs on the init hook and checks if the reset quiz button was clicked.
Returns
void;
Since
1.7.2
Hooked
init
|
public
|
#
user_quiz_submit_listener( )
Complete/ submit quiz hooked function
Complete/ submit quiz hooked function
This function listens to the complete button submit action and processes the users submitted answers
not that this function submits the given users quiz answers for grading.
Since
1.7.4
|
public
|
#
load_global_quiz_data( )
This function set's up the data need for the quiz page
This function set's up the data need for the quiz page
This function hooks into sensei_complete_quiz and load the global data for the
current quiz.
Since
1.7.4
|
public static
array
|
#
prepare_form_submitted_answers( array $unprepared_answers, $files )
This function converts the submitted array and makes it ready it for storage
This function converts the submitted array and makes it ready it for storage
Creating a single array of all question types including file id's to be stored
as comment meta by the calling function.
Parameters
- $unprepared_answers
- $files
Returns
array
Since
1.7.4
|
public
boolean
|
#
reset_user_lesson_data( integer $lesson_id, integer $user_id = 0 )
Reset user submitted questions
Reset user submitted questions
This function resets the quiz data for a user that has been submitted fro grading already. It is different to
the save_user_answers as currently the saved and submitted answers are stored differently.
Parameters
- $lesson_id
- $user_id
- $user_id
- $lesson_id
Returns
boolean $reset_success
Since
1.7.4
|
public static
boolean
|
#
submit_answers_for_grading( array $quiz_answers, array $files, integer $lesson_id, integer $user_id = 0 )
Submit the users quiz answers for grading
Submit the users quiz answers for grading
This function accepts users answers and stores it but also initiates the grading
if a quiz can be graded automatically it will, if not the answers can be graded by the teacher.
Parameters
- $quiz_answers
- $files
- from $_FILES
- $lesson_id
- $user_id
- $user_id
- $lesson_id
Returns
boolean $answers_submitted
Since
1.7.4
|
public
boolean|null
|
#
get_user_question_answer( integer $lesson_id, integer $question_id, integer $user_id = 0 )
Get the user question answer
Get the user question answer
This function gets the the users saved answer on given quiz for the given question parameter
this function allows for a fallback to users still using the question saved data from before 1.7.4
Parameters
- $lesson_id
- $question_id
- $user_id
- ( optional )
Returns
boolean|null $answers_submitted
Since
1.7.4
|
public
boolean
|
#
set_user_grades( array $quiz_grades, $lesson_id, $user_id = 0 )
Saving the users quiz question grades
Saving the users quiz question grades
This function save all the grades for all the question in a given quiz on the lesson
comment meta. It makes use of transients to save the grades for easier access at a later stage
Parameters
- $quiz_grades
- $quiz_grades{
- $lesson_id
- $user_id
- will use the current user if not supplied
Returns
boolean
Since
1.7.4
Type
int $question_id
int $question_grade
}
|
public
array
|
#
get_user_grades( $lesson_id, $user_id = 0 )
Retrieve the users quiz question grades
Retrieve the users quiz question grades
This function gets all the grades for all the questions in the given lesson quiz for a specific user.
Parameters
- $lesson_id
- $user_id
- will use the current user if not supplied
Returns
array $user_quiz_grades or false if none exists for this users
Since
1.7.4
|
public
boolean
|
#
get_user_question_grade( integer $lesson_id, integer $question_id, integer $user_id = 0 )
Get the user question grade
Get the user question grade
This function gets the grade on a quiz for the given question parameter
It does NOT do any grading. It simply retrieves the data that was stored during grading.
this function allows for a fallback to users still using the question saved data from before 1.7.4
Parameters
- $lesson_id
- $question_id
- $user_id
- ( optional )
Returns
boolean $question_grade
Since
1.7.4
|
public
false
|
#
save_user_answers_feedback( array $answers_feedback, integer $lesson_id, integer $user_id = 0 )
Save the user's answers feedback
Save the user's answers feedback
For this function you must supply all three parameters. If will return false one is left out.
The data will be saved on the lesson ID supplied.
Parameters
- $answers_feedback
$answers_feedback{
$type int $question_id
$type string $question_feedback
}
- $lesson_id
- $user_id
Returns
false or int $feedback_saved
Since
1.7.5
|
public
false
|
#
get_user_answers_feedback( integer $lesson_id, integer $user_id = 0 )
Get the user's answers feedback.
Get the user's answers feedback.
This function returns the feedback submitted by the teacher/admin
during grading. Grading occurs manually or automatically.
Parameters
Returns
false | array $answers_feedback{
$type int $question_id
$type string $question_feedback
}
Since
1.7.5
|
public
string
|
#
get_user_question_feedback( integer $lesson_id, integer $question_id, integer $user_id = 0 )
Get the user's answer feedback for a specific question.
Get the user's answer feedback for a specific question.
This function gives you a single answer note/feedback string
for the user on the given question.
Parameters
- $lesson_id
- $question_id
- $user_id
Returns
string $feedback or bool if false
Since
1.7.5
|
public
|
#
quiz_has_no_questions( )
Check if a quiz has no questions, and redirect back to lesson.
Check if a quiz has no questions, and redirect back to lesson.
Though a quiz is created for each lesson, it should not be visible
unless it has questions.
Since
1.9.0
|
public static
|
|
public static
|
|
public static
string
|
#
single_quiz_title( string $title, integer $post_id = 0 )
Filter the single title and add the Quiz to it.
Filter the single title and add the Quiz to it.
Parameters
- $title
- $post_id
- title post id
Returns
string $quiz_title
|
public static
|
#
start_quiz_questions_loop( )
Initialize the quiz question loop on the single quiz template
Initialize the quiz question loop on the single quiz template
The function will create a global quiz loop varialbe.
Since
1.9.0
|
public static
|
#
stop_quiz_questions_loop( )
Initialize the quiz question loop on the single quiz template
Initialize the quiz question loop on the single quiz template
The function will create a global quiz loop varialbe.
Since
1.9.0
|
public static
|
#
the_title( )
Output the title for the single quiz page
Output the title for the single quiz page
Since
1.9.0
|
public static
|
#
the_user_status_message( $quiz_id )
Output the sensei quiz status message.
Output the sensei quiz status message.
Parameters
|
public static
|
#
deprecate_sensei_quiz_action_buttons_hook( )
This functions runs the old sensei_quiz_action_buttons action
for backwards compatiblity sake.
This functions runs the old sensei_quiz_action_buttons action
for backwards compatiblity sake.
Deprecated
Since
1.9.0
|
public static
|
#
action_buttons( )
The quiz action buttons needed to ouput quiz
action such as reset complete and save.
The quiz action buttons needed to ouput quiz
action such as reset complete and save.
Since
1.3.0
|
public static
float
|
#
get_user_quiz_grade( integer $lesson_id, integer $user_id )
Fetch the quiz grade
Parameters
Returns
float $user_quiz_grade
Since
1.9.0
|
public static
boolean
|
#
is_reset_allowed( integer $lesson_id )
Check the quiz reset property for a given lesson's quiz.
Check the quiz reset property for a given lesson's quiz.
The data is stored on the quiz but going forward the quiz post
type will be retired, hence the lesson_id is a require parameter.
Parameters
Returns
boolean
Since
1.9.0
|
public static
boolean
|
|
public
|
#
maybe_delete_quiz( integer $post_id )
Parameters
- $post_id
- of the post being permanently deleted
Since
1.9.5
|