This commit is contained in:
Huong Nguyen 2024-07-24 12:06:54 +07:00
commit 86968a64a5
No known key found for this signature in database
GPG key ID: 40D88AB693A3E72A
4 changed files with 20 additions and 46 deletions

View file

@ -0,0 +1,7 @@
issueNumber: MDL-72424
notes:
mod_feedback:
- message: >-
The `feedback_check_is_switchrole` method has been deprecated as it
didn't work
type: deprecated

View file

@ -14,16 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains class mod_feedback_completion
*
* @package mod_feedback
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Collects information and methods about feedback completion (either complete.php or show_entries.php)
*
@ -557,12 +547,6 @@ class mod_feedback_completion extends mod_feedback_structure {
$feedbackcompleted = !$feedbackcompleted ? null : $feedbackcompleted;
$feedbackcompletedtmp = $this->get_current_completed_tmp();
if (feedback_check_is_switchrole()) {
// We do not actually save anything if the role is switched, just delete temporary values.
$this->delete_completedtmp();
return;
}
// Save values.
$completedid = feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted);
$this->completed = $DB->get_record('feedback_completed', array('id' => $completedid));
@ -584,19 +568,6 @@ class mod_feedback_completion extends mod_feedback_structure {
}
}
/**
* Deletes the temporary completed and all related temporary values
*/
protected function delete_completedtmp() {
global $DB;
if ($completedtmp = $this->get_current_completed_tmp()) {
$DB->delete_records('feedback_valuetmp', ['completed' => $completedtmp->id]);
$DB->delete_records('feedback_completedtmp', ['id' => $completedtmp->id]);
$this->completedtmp = null;
}
}
/**
* Retrieves the last completion record for the current user
*

View file

@ -29,3 +29,16 @@ function feedback_get_completion_state() {
$completionclass = \mod_feedback\completion\custom_completion::class;
throw new coding_exception(__FUNCTION__ . "() has been removed, please use the '{$completionclass}' class instead");
}
/**
* Returns true if the current role is faked by switching role feature
*
* @return bool
* @deprecated since Moodle 4.5 - please do not use this function any more, {@see is_role_switched}
*/
#[\core\attribute\deprecated('is_role_switched', since: '4.5', mdl: 'MDL-72424')]
function feedback_check_is_switchrole(): bool {
global $USER;
\core\deprecation::emit_deprecation_if_present(__FUNCTION__);
return isset($USER->switchrole) && is_array($USER->switchrole) && count($USER->switchrole) > 0;
}

View file

@ -926,23 +926,6 @@ function feedback_get_context() {
throw new coding_exception('feedback_get_context() can not be used anymore.');
}
/**
* returns true if the current role is faked by switching role feature
*
* @global object
* @return boolean
*/
function feedback_check_is_switchrole() {
global $USER;
if (isset($USER->switchrole) AND
is_array($USER->switchrole) AND
count($USER->switchrole) > 0) {
return true;
}
return false;
}
/**
* count users which have not completed the feedback
*