mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-58453-master' of git://github.com/jleyva/moodle
This commit is contained in:
commit
ad02561c15
2 changed files with 19 additions and 0 deletions
|
@ -1002,6 +1002,10 @@ class mod_feedback_external extends external_api {
|
|||
|
||||
list($feedback, $course, $cm, $context) = self::validate_feedback($params['feedbackid']);
|
||||
|
||||
if ($feedback->anonymous != FEEDBACK_ANONYMOUS_NO || $feedback->course == SITEID) {
|
||||
throw new moodle_exception('anonymous', 'feedback');
|
||||
}
|
||||
|
||||
// Check permissions.
|
||||
require_capability('mod/feedback:viewreports', $context);
|
||||
|
||||
|
|
|
@ -674,10 +674,25 @@ class mod_feedback_external_testcase extends externallib_advanced_testcase {
|
|||
mod_feedback_external::get_non_respondents($this->feedback->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_non_respondents from an anonymous feedback.
|
||||
*/
|
||||
public function test_get_non_respondents_from_anonymous_feedback() {
|
||||
$this->setUser($this->student);
|
||||
$this->expectException('moodle_exception');
|
||||
$this->expectExceptionMessage(get_string('anonymous', 'feedback'));
|
||||
mod_feedback_external::get_non_respondents($this->feedback->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_non_respondents.
|
||||
*/
|
||||
public function test_get_non_respondents() {
|
||||
global $DB;
|
||||
|
||||
// Force non anonymous.
|
||||
$DB->set_field('feedback', 'anonymous', FEEDBACK_ANONYMOUS_NO, array('id' => $this->feedback->id));
|
||||
|
||||
// Create another student.
|
||||
$anotherstudent = self::getDataGenerator()->create_user();
|
||||
$this->getDataGenerator()->enrol_user($anotherstudent->id, $this->course->id, $this->studentrole->id, 'manual');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue