mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'master_MDL-71696-versioning-integration' of https://github.com/catalyst/moodle-MDL-70329
This commit is contained in:
commit
b841a811be
223 changed files with 7768 additions and 2899 deletions
|
@ -57,6 +57,7 @@ echo '<p><input type="submit" class="btn btn-secondary" id="settingssubmit" valu
|
|||
echo '</div></form>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$params[] = \core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN;
|
||||
// If we have a qtype to report on, generate the report.
|
||||
if ($requestedqtype) {
|
||||
|
||||
|
@ -74,14 +75,13 @@ if ($requestedqtype) {
|
|||
$title = get_string('reportforallqtypes', 'report_questioninstances');
|
||||
|
||||
$sqlqtypetest = '';
|
||||
$params = array();
|
||||
|
||||
} else {
|
||||
$title = get_string('reportforqtype', 'report_questioninstances',
|
||||
question_bank::get_qtype($requestedqtype)->local_name());
|
||||
|
||||
$sqlqtypetest = 'WHERE qtype = ?';
|
||||
$params = array($requestedqtype);
|
||||
$params [] = $requestedqtype;
|
||||
}
|
||||
|
||||
// Get the question counts, and all the context information, for each
|
||||
|
@ -89,14 +89,29 @@ if ($requestedqtype) {
|
|||
$ctxpreload = context_helper::get_preload_record_columns_sql('con');
|
||||
$ctxgroupby = implode(',', array_keys(context_helper::get_preload_record_columns('con')));
|
||||
$counts = $DB->get_records_sql("
|
||||
SELECT qc.contextid, count(1) as numquestions, sum(hidden) as numhidden, $ctxpreload
|
||||
FROM {question} q
|
||||
JOIN {question_categories} qc ON q.category = qc.id
|
||||
JOIN {context} con ON con.id = qc.contextid
|
||||
$sqlqtypetest
|
||||
AND (q.parent = 0 OR q.parent = q.id)
|
||||
GROUP BY qc.contextid, $ctxgroupby
|
||||
ORDER BY numquestions DESC, numhidden ASC, con.contextlevel ASC, con.id ASC", $params);
|
||||
SELECT result.contextid, SUM(numquestions) AS numquestions, SUM(numhidden) AS numhidden, $ctxpreload
|
||||
FROM (SELECT data.contextid, COUNT(data.numquestions) AS numquestions,
|
||||
(SELECT COUNT(qv.id)
|
||||
FROM {question_versions} qv
|
||||
WHERE qv.id = data.versionid
|
||||
AND qv.status = ?) AS numhidden
|
||||
FROM (SELECT qv.id as versionid, qc.contextid, 1 AS numquestions
|
||||
FROM {question} q
|
||||
JOIN {question_versions} qv ON qv.questionid = q.id
|
||||
JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid
|
||||
JOIN {question_categories} qc ON qc.id = qbe.questioncategoryid
|
||||
JOIN {context} con ON con.id = qc.contextid
|
||||
$sqlqtypetest
|
||||
AND qv.version = (SELECT MAX(v.version)
|
||||
FROM {question_versions} v
|
||||
JOIN {question_bank_entries} be
|
||||
ON be.id = v.questionbankentryid
|
||||
WHERE be.id = qbe.id)
|
||||
AND (q.parent = 0 OR q.parent = q.id)) data
|
||||
GROUP BY data.contextid, data.versionid) result
|
||||
JOIN {context} con ON con.id = result.contextid
|
||||
GROUP BY result.contextid, $ctxgroupby
|
||||
ORDER BY numquestions DESC, numhidden ASC, con.contextlevel ASC, con.id ASC", $params);
|
||||
|
||||
// Print the report heading.
|
||||
echo $OUTPUT->heading($title);
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
@core @core_question @javascript @report @report_questioninstance
|
||||
Feature: A Teacher can generate question instance reports
|
||||
In order to see question instance reports
|
||||
As a Teacher
|
||||
I need to generate them
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | weeks |
|
||||
And the following "question categories" exist:
|
||||
| contextlevel | reference | name |
|
||||
| Course | C1 | Test questions |
|
||||
And the following "activities" exist:
|
||||
| activity | course | name |
|
||||
| quiz | C1 | Test quiz Q001 |
|
||||
And the following "questions" exist:
|
||||
| questioncategory | qtype | name |
|
||||
| Test questions | truefalse | TF |
|
||||
| Test questions | shortanswer | SA |
|
||||
And quiz "Test quiz Q001" contains the following questions:
|
||||
| question | page | maxmark |
|
||||
| TF | 1 | 5.0 |
|
||||
| SA | 1 | 5.0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And the following "question categories" exist:
|
||||
| contextlevel | reference | name |
|
||||
| Activity module | Test quiz Q001 | Quiz category |
|
||||
|
||||
@javascript
|
||||
Scenario: Generate general and specific report
|
||||
Given I am on the "C1" "Course" page logged in as "admin"
|
||||
And I navigate to "Reports > Question instances" in site administration
|
||||
When I press "Get the report"
|
||||
Then "Course: Course 1" row "Total" column of "generaltable" table should contain "2"
|
||||
And "Course: Course 1" row "Visible" column of "generaltable" table should contain "2"
|
||||
And "Course: Course 1" row "Hidden" column of "generaltable" table should contain "0"
|
||||
|
||||
@javascript
|
||||
Scenario: Generate report displaying hidden questions
|
||||
Given I am on the "Test quiz Q001" "quiz activity" page logged in as "admin"
|
||||
And I navigate to "Question bank > Questions" in current page administration
|
||||
And I click on "Edit" "link" in the "TF" "table_row"
|
||||
And I choose "Delete" in the open action menu
|
||||
And I press "Delete"
|
||||
And I navigate to "Reports > Question instances" in site administration
|
||||
When I press "Get the report"
|
||||
Then "Course: Course 1" row "Total" column of "generaltable" table should contain "2"
|
||||
And "Course: Course 1" row "Visible" column of "generaltable" table should contain "1"
|
||||
And "Course: Course 1" row "Hidden" column of "generaltable" table should contain "1"
|
||||
And I click on "menuqtype" "select"
|
||||
And I click on "True/False" "option"
|
||||
And I press "Get the report"
|
||||
And "Course: Course 1" row "Total" column of "generaltable" table should contain "1"
|
||||
And "Course: Course 1" row "Visible" column of "generaltable" table should contain "0"
|
||||
And "Course: Course 1" row "Hidden" column of "generaltable" table should contain "1"
|
Loading…
Add table
Add a link
Reference in a new issue