mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-66958 core_grade: Add hasgrade to all external fetch webservices
This commit is contained in:
parent
63cd8d45db
commit
8827e573db
@ -129,20 +129,23 @@ class fetch extends external_api {
|
||||
|
||||
// Fetch the actual data.
|
||||
$gradeduser = \core_user::get_user($gradeduserid);
|
||||
$hasgrade = $gradeitem->user_has_grade($gradeduser);
|
||||
$grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
|
||||
|
||||
return self::get_fetch_data($grade);
|
||||
return self::get_fetch_data($grade, $hasgrade);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data to be fetched.
|
||||
*
|
||||
* @param stdClass $grade
|
||||
* @param bool $hasgrade
|
||||
* @return array
|
||||
*/
|
||||
public static function get_fetch_data(stdClass $grade): array {
|
||||
public static function get_fetch_data(stdClass $grade, bool $hasgrade): array {
|
||||
return [
|
||||
'templatename' => 'core_grades/grades/grader/gradingpanel/point',
|
||||
'hasgrade' => $hasgrade,
|
||||
'grade' => [
|
||||
'grade' => $grade->grade,
|
||||
'timecreated' => $grade->timecreated,
|
||||
@ -161,6 +164,7 @@ class fetch extends external_api {
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'templatename' => new external_value(PARAM_SAFEPATH, 'The template to use when rendering this data'),
|
||||
'hasgrade' => new external_value(PARAM_BOOL, 'Does the user have a grade?'),
|
||||
'grade' => new external_single_structure([
|
||||
'grade' => new external_value(PARAM_FLOAT, 'The numeric grade'),
|
||||
'timecreated' => new external_value(PARAM_INT, 'The time that the grade was created'),
|
||||
|
@ -152,7 +152,7 @@ class store extends external_api {
|
||||
// Grade.
|
||||
$gradeitem->store_grade_from_formdata($gradeduser, $USER, (object) $data);
|
||||
|
||||
$hasgrade = $gradeitem->get_grade_status_for_user($gradeduser);
|
||||
$hasgrade = $gradeitem->user_has_grade($gradeduser);
|
||||
// Fetch the updated grade back out.
|
||||
$grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
|
||||
|
||||
|
@ -142,6 +142,7 @@ class fetch extends external_api {
|
||||
public static function get_fetch_data(gradeitem $gradeitem, stdClass $gradeduser): array {
|
||||
global $USER;
|
||||
|
||||
$hasgrade = $gradeitem->user_has_grade($gradeduser);
|
||||
$grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
|
||||
$currentgrade = (int) unformat_float($grade->grade);
|
||||
|
||||
@ -156,6 +157,7 @@ class fetch extends external_api {
|
||||
|
||||
return [
|
||||
'templatename' => 'core_grades/grades/grader/gradingpanel/scale',
|
||||
'hasgrade' => $hasgrade,
|
||||
'grade' => [
|
||||
'options' => $values,
|
||||
'timecreated' => $grade->timecreated,
|
||||
@ -174,6 +176,7 @@ class fetch extends external_api {
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'templatename' => new external_value(PARAM_SAFEPATH, 'The template to use when rendering this data'),
|
||||
'hasgrade' => new external_value(PARAM_BOOL, 'Does the user have a grade?'),
|
||||
'grade' => new external_single_structure([
|
||||
'options' => new external_multiple_structure(
|
||||
new external_single_structure([
|
||||
|
@ -148,6 +148,7 @@ class fetch extends external_api {
|
||||
public static function get_fetch_data(gradeitem $gradeitem, stdClass $gradeduser): array {
|
||||
global $USER;
|
||||
|
||||
$hasgrade = $gradeitem->user_has_grade($gradeduser);
|
||||
$grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
|
||||
$instance = $gradeitem->get_advanced_grading_instance($USER, $grade);
|
||||
$controller = $instance->get_controller();
|
||||
@ -217,6 +218,7 @@ class fetch extends external_api {
|
||||
|
||||
return [
|
||||
'templatename' => 'gradingform_guide/grades/grader/gradingpanel',
|
||||
'hasgrade' => $hasgrade,
|
||||
'grade' => [
|
||||
'instanceid' => $instance->get_id(),
|
||||
'criterion' => $criterion,
|
||||
@ -238,6 +240,7 @@ class fetch extends external_api {
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'templatename' => new external_value(PARAM_SAFEPATH, 'The template to use when rendering this data'),
|
||||
'hasgrade' => new external_value(PARAM_BOOL, 'Does the user have a grade?'),
|
||||
'grade' => new external_single_structure([
|
||||
'instanceid' => new external_value(PARAM_INT, 'The id of the current grading instance'),
|
||||
'criterion' => new external_multiple_structure(
|
||||
|
@ -140,6 +140,7 @@ class fetch extends external_api {
|
||||
global $USER;
|
||||
|
||||
// Set up all the controllers etc that we'll be needing.
|
||||
$hasgrade = $gradeitem->user_has_grade($gradeduser);
|
||||
$grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
|
||||
$instance = $gradeitem->get_advanced_grading_instance($USER, $grade);
|
||||
$controller = $instance->get_controller();
|
||||
@ -229,6 +230,7 @@ class fetch extends external_api {
|
||||
|
||||
return [
|
||||
'templatename' => 'gradingform_rubric/grades/grader/gradingpanel',
|
||||
'hasgrade' => $hasgrade,
|
||||
'grade' => [
|
||||
'instanceid' => $instance->get_id(),
|
||||
'criteria' => $criterion,
|
||||
@ -251,6 +253,7 @@ class fetch extends external_api {
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'templatename' => new external_value(PARAM_SAFEPATH, 'The template to use when rendering this data'),
|
||||
'hasgrade' => new external_value(PARAM_BOOL, 'Does the user have a grade?'),
|
||||
'grade' => new external_single_structure([
|
||||
'instanceid' => new external_value(PARAM_INT, 'The id of the current grading instance'),
|
||||
'rubricmode' => new external_value(PARAM_RAW, 'The mode i.e. evaluate editable'),
|
||||
|
@ -25,6 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['addcriterion'] = 'Add criterion';
|
||||
$string['additionalfeedback'] = 'Additional feedback';
|
||||
$string['alwaysshowdefinition'] = 'Allow users to preview rubric (otherwise it will only be displayed after grading)';
|
||||
$string['backtoediting'] = 'Back to editing';
|
||||
$string['confirmdeletecriterion'] = 'Are you sure you want to delete this criterion?';
|
||||
|
Loading…
x
Reference in New Issue
Block a user