MDL-27747 quiz summary, add a CSS class to the table rows based on question state.
The standard themes do not use this for anything, but it makes it easier for themers to do cool stuff. Also improve the API for getting the question state class.
This commit is contained in:
+15
-1
@@ -756,6 +756,20 @@ class quiz_attempt {
|
||||
return $this->quba->get_question_state_string($slot, $showcorrectness);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the grade obtained on a particular question, if the user is permitted
|
||||
* to see it. You must previously have called load_question_states to load the
|
||||
* state data about this question.
|
||||
*
|
||||
* @param int $slot the number used to identify this question within this attempt.
|
||||
* @param bool $showcorrectness Whether right/partial/wrong states should
|
||||
* be distinguised.
|
||||
* @return string class name for this state.
|
||||
*/
|
||||
public function get_question_state_class($slot, $showcorrectness) {
|
||||
return $this->quba->get_question_state_class($slot, $showcorrectness);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the grade obtained on a particular question.
|
||||
* You must previously have called load_question_states to load the state
|
||||
@@ -1167,7 +1181,7 @@ abstract class quiz_nav_panel_base {
|
||||
$button = new quiz_nav_question_button();
|
||||
$button->id = 'quiznavbutton' . $slot;
|
||||
$button->number = $qa->get_question()->_number;
|
||||
$button->stateclass = $qa->get_state()->get_state_class($showcorrectness);
|
||||
$button->stateclass = $qa->get_state_class($showcorrectness);
|
||||
if (!$showcorrectness && $button->stateclass == 'notanswered') {
|
||||
$button->stateclass = 'complete';
|
||||
}
|
||||
|
||||
@@ -484,6 +484,8 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
$row[] = $attemptobj->get_question_mark($slot);
|
||||
}
|
||||
$table->data[] = $row;
|
||||
$table->rowclasses[] = $attemptobj->get_question_state_class(
|
||||
$slot, $displayoptions->correctness);
|
||||
}
|
||||
|
||||
// Print the summary table.
|
||||
|
||||
@@ -517,6 +517,15 @@ class question_attempt {
|
||||
return $this->behaviour->get_state_string($showcorrectness);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $showcorrectness Whether right/partial/wrong states should
|
||||
* be distinguised.
|
||||
* @return string a CSS class name for the current state.
|
||||
*/
|
||||
public function get_state_class($showcorrectness) {
|
||||
return $this->get_state()->get_state_class($showcorrectness);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int the timestamp of the most recent step in this question attempt.
|
||||
*/
|
||||
|
||||
@@ -246,6 +246,16 @@ class question_usage_by_activity {
|
||||
return $this->get_question_attempt($slot)->get_state_string($showcorrectness);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $slot the number used to identify this question within this usage.
|
||||
* @param bool $showcorrectness Whether right/partial/wrong states should
|
||||
* be distinguised.
|
||||
* @return string a CSS class name for the current state.
|
||||
*/
|
||||
public function get_question_state_class($slot, $showcorrectness) {
|
||||
return $this->get_question_attempt($slot)->get_state_class($showcorrectness);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time of the most recent action performed on a question.
|
||||
* @param int $slot the number used to identify this question within this usage.
|
||||
|
||||
Reference in New Issue
Block a user