mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 16:10:15 +01:00
Merge branch 'MDL-63608_401' of https://github.com/AnupamaSarjoshi/moodle into MOODLE_401_STABLE
This commit is contained in:
commit
51254db574
@ -71,7 +71,7 @@ $string['questionsperpage'] = 'Questions per page';
|
||||
$string['questionsthatneedgrading'] = 'Questions that need grading';
|
||||
$string['questiontitle'] = 'Question {$a->number} : "{$a->name}" ({$a->openspan}{$a->gradedattempts}{$a->closespan} / {$a->totalattempts} attempts {$a->openspan}graded{$a->closespan}).';
|
||||
$string['random'] = 'Random';
|
||||
$string['saveandnext'] = 'Save and go to next page';
|
||||
$string['saveandnext'] = 'Save and show next';
|
||||
$string['showstudentnames'] = 'Show student names';
|
||||
$string['tograde'] = 'To grade';
|
||||
$string['total'] = 'Total';
|
||||
|
@ -22,8 +22,6 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The renderer for the quiz_grading module.
|
||||
*
|
||||
@ -148,9 +146,7 @@ class quiz_grading_renderer extends plugin_renderer_base {
|
||||
|
||||
$output .= $this->heading(get_string('gradingattemptsxtoyofz', 'quiz_grading', $paginginfo), 3);
|
||||
|
||||
if ($pagingbar->count > $pagingbar->pagesize && $pagingbar->order != 'random') {
|
||||
$output .= $this->paging_bar($pagingbar->count, $pagingbar->page, $pagingbar->pagesize, $pagingbar->pagingurl);
|
||||
}
|
||||
$output .= $this->render_paging_bar($pagingbar);
|
||||
|
||||
$output .= html_writer::start_tag('form', [
|
||||
'method' => 'post',
|
||||
@ -170,6 +166,8 @@ class quiz_grading_renderer extends plugin_renderer_base {
|
||||
]), ['class' => 'mdl-align']);
|
||||
$output .= html_writer::end_tag('div') . html_writer::end_tag('form');
|
||||
|
||||
$output .= $this->render_paging_bar($pagingbar);
|
||||
|
||||
// Add the form change checker.
|
||||
$this->page->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['manualgradingform']);
|
||||
|
||||
@ -197,4 +195,17 @@ class quiz_grading_renderer extends plugin_renderer_base {
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render paging bar.
|
||||
*
|
||||
* @param object $pagingbar Pagination bar information.
|
||||
* @return string The HTML for the question display.
|
||||
*/
|
||||
public function render_paging_bar(object $pagingbar): string {
|
||||
if ($pagingbar->count > $pagingbar->pagesize && $pagingbar->order != 'random') {
|
||||
return $this->paging_bar($pagingbar->count, $pagingbar->page, $pagingbar->pagesize, $pagingbar->pagingurl);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -148,9 +148,16 @@ class quiz_grading_report extends quiz_default_report {
|
||||
|
||||
// Process any submitted data.
|
||||
if ($data = data_submitted() && confirm_sesskey() && $this->validate_submitted_marks()) {
|
||||
$this->process_submitted_data();
|
||||
// Changes done to handle attempts being missed from grading due to redirecting to new page.
|
||||
$attemptsgraded = $this->process_submitted_data();
|
||||
|
||||
redirect($this->grade_question_url($slot, $questionid, $grade, $page + 1));
|
||||
$nextpagenumber = $page + 1;
|
||||
// If attempts need grading and one or more have now been graded, then page number should remain the same.
|
||||
if ($grade == 'needsgrading' && $attemptsgraded) {
|
||||
$nextpagenumber = $page;
|
||||
}
|
||||
|
||||
redirect($this->grade_question_url($slot, $questionid, $grade, $nextpagenumber));
|
||||
}
|
||||
|
||||
// Get the group, and the list of significant users.
|
||||
@ -552,15 +559,17 @@ class quiz_grading_report extends quiz_default_report {
|
||||
|
||||
/**
|
||||
* Save all submitted marks to the database.
|
||||
*
|
||||
* @return bool returns true if some attempts or all are graded. False, if none of the attempts are graded.
|
||||
*/
|
||||
protected function process_submitted_data() {
|
||||
protected function process_submitted_data(): bool {
|
||||
global $DB;
|
||||
|
||||
$qubaids = optional_param('qubaids', null, PARAM_SEQUENCE);
|
||||
$assumedslotforevents = optional_param('slot', null, PARAM_INT);
|
||||
|
||||
if (!$qubaids) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$qubaids = clean_param_array(explode(',', $qubaids), PARAM_INT);
|
||||
@ -568,11 +577,24 @@ class quiz_grading_report extends quiz_default_report {
|
||||
$events = [];
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$attemptsgraded = false;
|
||||
foreach ($qubaids as $qubaid) {
|
||||
$attempt = $attempts[$qubaid];
|
||||
$attemptobj = new quiz_attempt($attempt, $this->quiz, $this->cm, $this->course);
|
||||
|
||||
// State of the attempt before grades are changed.
|
||||
$attemptoldtstate = $attemptobj->get_question_state($assumedslotforevents);
|
||||
|
||||
$attemptobj->process_submitted_actions(time());
|
||||
|
||||
// Get attempt state after grades are changed.
|
||||
$attemptnewtstate = $attemptobj->get_question_state($assumedslotforevents);
|
||||
|
||||
// Check if any attempts are graded.
|
||||
if (!$attemptsgraded && $attemptoldtstate->is_graded() != $attemptnewtstate->is_graded()) {
|
||||
$attemptsgraded = true;
|
||||
}
|
||||
|
||||
// Add the event we will trigger later.
|
||||
$params = [
|
||||
'objectid' => $attemptobj->get_question_attempt($assumedslotforevents)->get_question_id(),
|
||||
@ -592,6 +614,8 @@ class quiz_grading_report extends quiz_default_report {
|
||||
foreach ($events as $event) {
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
return $attemptsgraded;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,8 +51,9 @@ Feature: Basic use of the Manual grading report
|
||||
| questioncategory | qtype | name | questiontext | answer 1 | grade |
|
||||
| Test questions | shortanswer | Short answer 001 | Where is the capital city of France? | Paris | 100% |
|
||||
And the following "activities" exist:
|
||||
| activity | name | course | idnumber | groupmode | grouping |
|
||||
| quiz | Quiz 1 | C1 | quiz1 | 1 | tging |
|
||||
| activity | name | course | idnumber | groupmode | grouping |
|
||||
| quiz | Quiz 1 | C1 | quiz1 | 1 | tging |
|
||||
| quiz | Quiz 2 | C1 | quiz2 | 1 | tging |
|
||||
And quiz "Quiz 1" contains the following questions:
|
||||
| question | page |
|
||||
| Short answer 001 | 1 |
|
||||
@ -95,7 +96,7 @@ Feature: Basic use of the Manual grading report
|
||||
# Adjust the mark for Student1
|
||||
And I set the field "Comment" to "I have adjusted your mark to 0.6"
|
||||
And I set the field "Mark" to "0.6"
|
||||
And I press "Save and go to next page"
|
||||
And I press "Save and show next"
|
||||
And I should see "All selected attempts have been graded. Returning to the list of questions."
|
||||
And "Short answer 001" row "To grade" column of "questionstograde" table should contain "0"
|
||||
And "Short answer 001" row "Already graded" column of "questionstograde" table should contain "1"
|
||||
@ -164,3 +165,53 @@ Feature: Basic use of the Manual grading report
|
||||
Then I should see "Quiz 1"
|
||||
And I should see "Separate groups: All participants"
|
||||
Then I should see "Sorry, but you need to be part of a group to see this page."
|
||||
|
||||
@javascript
|
||||
Scenario: Manual grading report with attempts to be graded
|
||||
Given the following "questions" exist:
|
||||
| questioncategory | qtype | name | user | questiontext |
|
||||
| Test questions | essay | Essay Q1 | admin | Question 1 text |
|
||||
And quiz "Quiz 2" contains the following questions:
|
||||
| question | page |
|
||||
| Essay Q1 | 1 |
|
||||
And I log out
|
||||
When I am on the "Quiz 2" "mod_quiz > View" page logged in as "student1"
|
||||
And I press "Attempt quiz"
|
||||
And I set the field with xpath "//*[contains(concat(' ', @class, ' '), ' editor_atto_content ')]" to "This is my attempt 1"
|
||||
And I follow "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue"
|
||||
And I click on "Finish review" "link"
|
||||
And I press "Re-attempt quiz"
|
||||
And I set the field with xpath "//*[contains(concat(' ', @class, ' '), ' editor_atto_content ')]" to "This is my attempt 2"
|
||||
And I follow "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue"
|
||||
And I click on "Finish review" "link"
|
||||
And I press "Re-attempt quiz"
|
||||
And I set the field with xpath "//*[contains(concat(' ', @class, ' '), ' editor_atto_content ')]" to "This is my attempt 3"
|
||||
And I follow "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue"
|
||||
And I log out
|
||||
|
||||
And I am on the "Quiz 2" "mod_quiz > Manual grading report" page logged in as "teacher1"
|
||||
And I follow "Also show questions that have been graded automatically"
|
||||
And I should see "Essay Q1"
|
||||
And "Essay Q1" row "To grade" column of "questionstograde" table should contain "3"
|
||||
And "Essay Q1" row "Already graded" column of "questionstograde" table should contain "0"
|
||||
# Go to the grading page.
|
||||
And I click on "grade" "link" in the "Essay Q1" "table_row"
|
||||
And I should see "Grading attempts 1 to 3 of 3"
|
||||
And I set the following fields to these values:
|
||||
| Questions per page | 1 |
|
||||
| Order attempts by | ID number |
|
||||
And I press "Change options"
|
||||
And I should see "Grading attempts 1 to 1 of 3"
|
||||
# Adjust the mark for Student1
|
||||
And I set the field "Comment" to "I have adjusted your mark to 0.6"
|
||||
And I set the field "Mark" to "0.6"
|
||||
And I press "Save and show next"
|
||||
Then I should see "Grading attempts 1 to 1 of 2"
|
||||
And I press "Save and show next"
|
||||
And I should see "Grading attempts 2 to 2 of 2"
|
||||
|
@ -177,7 +177,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
|
||||
When I click on "update grades" "link" in the "SA1" "table_row"
|
||||
Then I set the field "Comment" to "I have adjusted your mark to 1.0"
|
||||
And I set the field "Mark" to "1.0"
|
||||
And I press "Save and go to next page"
|
||||
And I press "Save and show next"
|
||||
And I follow "Results"
|
||||
And I follow "Review attempt"
|
||||
And I should see "Teacher One" in the "I have adjusted your mark to 1.0" "table_row"
|
||||
|
Loading…
x
Reference in New Issue
Block a user