Skip to content

Commit

Permalink
Merge branch 'MDL-41751-master' of git://github.com/jamiepratt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Oct 1, 2013
2 parents 9d4ff1e + d50b05e commit 6579a7b
Showing 9 changed files with 571 additions and 146 deletions.
62 changes: 22 additions & 40 deletions mod/quiz/report/statistics/report.php
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public function display($quiz, $cm, $course) {
$download = optional_param('download', '', PARAM_ALPHA);
$everything = optional_param('everything', 0, PARAM_BOOL);
$recalculate = optional_param('recalculate', 0, PARAM_BOOL);
// A qid paramter indicates we should display the detailed analysis of a question.
// A qid paramter indicates we should display the detailed analysis of a sub question.
$qid = optional_param('qid', 0, PARAM_INT);
$slot = optional_param('slot', 0, PARAM_INT);

@@ -135,7 +135,6 @@ public function display($quiz, $cm, $course) {
$questionstats = array();
$subquestionstats = array();
}
$quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);

// Set up the table, if there is data.
if ($quizstats->s()) {
@@ -166,6 +165,7 @@ public function display($quiz, $cm, $course) {

if ($everything) { // Implies is downloading.
// Overall report, then the analysis of each question.
$quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);
$this->download_quiz_info_table($quizinfo);

if ($quizstats->s()) {
@@ -209,7 +209,7 @@ public function display($quiz, $cm, $course) {

} else if ($qid) {
// Report on an individual sub-question indexed questionid.
if (!isset($subquestions[$qid])) {
if (!isset($subquestionstats[$qid])) {
print_error('questiondoesnotexist', 'question');
}

@@ -224,6 +224,7 @@ public function display($quiz, $cm, $course) {

} else if ($this->table->is_downloading()) {
// Downloading overview report.
$quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);
$this->download_quiz_info_table($quizinfo);
$this->output_quiz_structure_analysis_table($quizstats->s(), $questionstats, $subquestionstats);
$this->table->finish_output();
@@ -234,6 +235,7 @@ public function display($quiz, $cm, $course) {
echo $this->output_caching_info($quizstats, $quiz->id, $currentgroup,
$groupstudents, $useallattempts, $reporturl);
echo $this->everything_download_options();
$quizinfo = $quizstats->get_formatted_quiz_info_data($course, $cm, $quiz);
echo $this->output_quiz_info_table($quizinfo);
if ($quizstats->s()) {
echo $OUTPUT->heading(get_string('quizstructureanalysis', 'quiz_statistics'));
@@ -248,10 +250,8 @@ public function display($quiz, $cm, $course) {
/**
* Display the statistical and introductory information about a question.
* Only called when not downloading.
* @param object $quiz the quiz settings.
* @param object $quiz the quiz settings.
* @param \core_question\statistics\questions\calculated $questionstat the question to report on.
* @param moodle_url $reporturl the URL to resisplay this report.
* @param object $quizstats Holds the quiz statistics.
*/
protected function output_individual_question_data($quiz, $questionstat) {
global $OUTPUT;
@@ -329,8 +329,9 @@ protected function render_question_text($question) {

/**
* Display the response analysis for a question.
* @param object $question the question to report on.
* @param moodle_url $reporturl the URL to resisplay this report.
* @param object $question the question to report on.
* @param int $s
* @param moodle_url $reporturl the URL to redisplay this report.
* @param qubaid_condition $qubaids
*/
protected function output_individual_question_response_analysis($question, $s, $reporturl, $qubaids) {
@@ -354,8 +355,7 @@ protected function output_individual_question_response_analysis($question, $s, $
$questiontabletitle = '(' . $question->number . ') ' . $questiontabletitle;
}
if ($this->table->is_downloading() == 'xhtml') {
$questiontabletitle = get_string('analysisofresponsesfor',
'quiz_statistics', $questiontabletitle);
$questiontabletitle = get_string('analysisofresponsesfor', 'quiz_statistics', $questiontabletitle);
}

// Set up the table.
@@ -366,38 +366,20 @@ protected function output_individual_question_response_analysis($question, $s, $
}
}

$responesstats = new \core_question\statistics\responses\analyser($question);
$responesstats->load_cached($qubaids);
$responesanalyser = new \core_question\statistics\responses\analyser($question);
$responseanalysis = $responesanalyser->load_cached($qubaids);

$qtable->question_setup($reporturl, $question, $s, $responesstats);
$qtable->question_setup($reporturl, $question, $s, $responseanalysis);
if ($this->table->is_downloading()) {
$exportclass->output_headers($qtable->headers);
}

foreach ($responesstats->responseclasses as $partid => $partclasses) {
$rowdata = new stdClass();
$rowdata->part = $partid;
foreach ($partclasses as $responseclassid => $responseclass) {
$rowdata->responseclass = $responseclass->responseclass;

$responsesdata = $responesstats->responses[$partid][$responseclassid];
if (empty($responsesdata)) {
if (!array_key_exists('responseclass', $qtable->columns)) {
$rowdata->response = $responseclass->responseclass;
} else {
$rowdata->response = '';
}
$rowdata->fraction = $responseclass->fraction;
$rowdata->count = 0;
$qtable->add_data_keyed($qtable->format_row($rowdata));
continue;
}

foreach ($responsesdata as $response => $data) {
$rowdata->response = $response;
$rowdata->fraction = $data->fraction;
$rowdata->count = $data->count;
$qtable->add_data_keyed($qtable->format_row($rowdata));
foreach ($responseanalysis->get_subpart_ids() as $partid) {
$subpart = $responseanalysis->get_subpart($partid);
foreach ($subpart->get_response_class_ids() as $responseclassid) {
$responseclass = $subpart->get_response_class($responseclassid);
$tabledata = $responseclass->data_for_question_response_table($subpart->has_multiple_response_classes(), $partid);
foreach ($tabledata as $row) {
$qtable->add_data_keyed($qtable->format_row($row));
}
}
}
@@ -531,7 +513,7 @@ protected function get_quiz_and_questions_stats($quiz, $currentgroup, $useallatt
$groupstudents, count($questions), $qcalc->get_sum_of_mark_variance());

if ($quizstats->s()) {
$this->calculate_responses_for_all_questions_and_subquestions($qubaids, $questions, $subquestionstats);
$this->analyse_responses_for_all_questions_and_subquestions($qubaids, $questions, $subquestionstats);
}
} else {
$quizstats = $quizcalc->get_cached($qubaids);
@@ -541,7 +523,7 @@ protected function get_quiz_and_questions_stats($quiz, $currentgroup, $useallatt
return array($quizstats, $questionstats, $subquestionstats);
}

protected function calculate_responses_for_all_questions_and_subquestions($qubaids, $questions, $subquestionstats) {
protected function analyse_responses_for_all_questions_and_subquestions($qubaids, $questions, $subquestionstats) {

$done = array();
foreach ($questions as $question) {
23 changes: 13 additions & 10 deletions mod/quiz/report/statistics/statistics_question_table.php
Original file line number Diff line number Diff line change
@@ -38,9 +38,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quiz_statistics_question_table extends flexible_table {
/** @var object this question. */
/** @var object full question object for this question. */
protected $questiondata;

/** @var int no of attempts. */
protected $s;

/**
* Constructor.
* @param int $qid the id of the particular question whose statistics are being
@@ -51,12 +54,12 @@ public function __construct($qid) {
}

/**
* @param moodle_url $reporturl
* @param object $questiondata
* @param integer $s number of attempts on this question.
* @param \core_question\statistics\responses\analyser $responesstats
* @param moodle_url $reporturl
* @param object $questiondata
* @param integer $s number of attempts on this question.
* @param \core_question\statistics\responses\analysis_for_question $responseanalysis
*/
public function question_setup($reporturl, $questiondata, $s, \core_question\statistics\responses\analyser $responesstats) {
public function question_setup($reporturl, $questiondata, $s, $responseanalysis) {
$this->questiondata = $questiondata;
$this->s = $s;

@@ -68,16 +71,16 @@ public function question_setup($reporturl, $questiondata, $s, \core_question\sta
$columns = array();
$headers = array();

if ($responesstats->has_subparts()) {
if ($responseanalysis->has_subparts()) {
$columns[] = 'part';
$headers[] = get_string('partofquestion', 'quiz_statistics');
}

if ($responesstats->has_response_classes()) {
if ($responseanalysis->has_multiple_response_classes()) {
$columns[] = 'responseclass';
$headers[] = get_string('modelresponse', 'quiz_statistics');

if ($responesstats->has_actual_responses()) {
if ($responseanalysis->has_actual_responses()) {
$columns[] = 'response';
$headers[] = get_string('actualresponse', 'quiz_statistics');
}
@@ -129,7 +132,7 @@ protected function col_fraction($response) {

/**
* The frequency with which this response was given.
* @param object $response containst the data to display.
* @param object $response contains the data to display.
* @return string contents of this table cell.
*/
protected function col_frequency($response) {
7 changes: 1 addition & 6 deletions question/behaviour/behaviourbase.php
Original file line number Diff line number Diff line change
@@ -301,12 +301,7 @@ protected function get_our_resume_data() {
}

/**
* @return array subpartid => object with fields
* ->responseclassid matches one of the values returned from
* quetion_type::get_possible_responses.
* ->response the actual response the student gave to this part, as a string.
* ->fraction the credit awarded for this subpart, may be null.
* returns an empty array if no analysis is possible.
* @return question_possible_response[] where keys are subpartid or an empty array if no classification is possible.
*/
public function classify_response() {
return $this->question->classify_response($this->qa->get_last_qt_data());
Loading

0 comments on commit 6579a7b

Please sign in to comment.