mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-68652 mod_forum: Only include gradable users in grading
This commit is contained in:
parent
bfb8ad5735
commit
faae0874ce
2
course/amd/build/repository.min.js
vendored
2
course/amd/build/repository.min.js
vendored
@ -5,6 +5,6 @@ define("core_course/repository",["exports","core/ajax"],(function(_exports,_ajax
|
||||
* @module core_course/repository
|
||||
* @copyright 2018 Ryan Wyllie <ryan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_ajax=(obj=_ajax)&&obj.__esModule?obj:{default:obj};var _default={getEnrolledCoursesByTimelineClassification:(classification,limit,offset,sort)=>{const args={classification:classification};void 0!==limit&&(args.limit=limit),void 0!==offset&&(args.offset=offset),void 0!==sort&&(args.sort=sort);const request={methodname:"core_course_get_enrolled_courses_by_timeline_classification",args:args};return _ajax.default.call([request])[0]},getLastAccessedCourses:(userid,limit,offset,sort)=>{const args={};void 0!==userid&&(args.userid=userid),void 0!==limit&&(args.limit=limit),void 0!==offset&&(args.offset=offset),void 0!==sort&&(args.sort=sort);const request={methodname:"core_course_get_recent_courses",args:args};return _ajax.default.call([request])[0]},getUsersFromCourseModuleID:function(cmid,groupID){let onlyActive=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var request={methodname:"core_course_get_enrolled_users_by_cmid",args:{cmid:cmid,groupid:groupID,onlyactive:onlyActive}};return _ajax.default.call([request])[0]},toggleManualCompletion:(cmid,completed)=>{const request={methodname:"core_completion_update_activity_completion_status_manually",args:{cmid:cmid,completed:completed}};return _ajax.default.call([request])[0]},getEnrolledCoursesWithEventsByTimelineClassification:function(classification){let limit=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,offset=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,sort=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,searchValue=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,eventsFrom=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,eventsTo=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;const args={classification:classification,limit:limit,offset:offset,sort:sort,eventsfrom:eventsFrom,eventsto:eventsTo,searchvalue:searchValue},request={methodname:"core_course_get_enrolled_courses_with_action_events_by_timeline_classification",args:args};return _ajax.default.call([request])[0]}};return _exports.default=_default,_exports.default}));
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_ajax=(obj=_ajax)&&obj.__esModule?obj:{default:obj};var _default={getEnrolledCoursesByTimelineClassification:(classification,limit,offset,sort)=>{const args={classification:classification};void 0!==limit&&(args.limit=limit),void 0!==offset&&(args.offset=offset),void 0!==sort&&(args.sort=sort);const request={methodname:"core_course_get_enrolled_courses_by_timeline_classification",args:args};return _ajax.default.call([request])[0]},getLastAccessedCourses:(userid,limit,offset,sort)=>{const args={};void 0!==userid&&(args.userid=userid),void 0!==limit&&(args.limit=limit),void 0!==offset&&(args.offset=offset),void 0!==sort&&(args.sort=sort);const request={methodname:"core_course_get_recent_courses",args:args};return _ajax.default.call([request])[0]},getUsersFromCourseModuleID:function(cmid,groupID){let onlyActive=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var request={methodname:"core_course_get_enrolled_users_by_cmid",args:{cmid:cmid,groupid:groupID,onlyactive:onlyActive}};return _ajax.default.call([request])[0]},getGradableUsersFromCourseID:function(courseid,groupID){let onlyActive=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const request={methodname:"core_grades_get_gradable_users",args:{courseid:courseid,groupid:groupID,onlyactive:onlyActive}};return _ajax.default.call([request])[0]},toggleManualCompletion:(cmid,completed)=>{const request={methodname:"core_completion_update_activity_completion_status_manually",args:{cmid:cmid,completed:completed}};return _ajax.default.call([request])[0]},getEnrolledCoursesWithEventsByTimelineClassification:function(classification){let limit=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,offset=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,sort=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,searchValue=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,eventsFrom=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,eventsTo=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;const args={classification:classification,limit:limit,offset:offset,sort:sort,eventsfrom:eventsFrom,eventsto:eventsTo,searchvalue:searchValue},request={methodname:"core_course_get_enrolled_courses_with_action_events_by_timeline_classification",args:args};return _ajax.default.call([request])[0]}};return _exports.default=_default,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=repository.min.js.map
|
File diff suppressed because one or more lines are too long
@ -150,6 +150,27 @@ const getEnrolledUsersFromCourseModuleID = (cmid, groupID, onlyActive = false) =
|
||||
return Ajax.call([request])[0];
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the list of gradable users enrolled in this course.
|
||||
*
|
||||
* @param {Number} courseid Course ID from which the users will be obtained
|
||||
* @param {Number} groupID Group ID from which the users will be obtained
|
||||
* @param {Boolean} onlyActive Whether to fetch only the active enrolled users or all enrolled users in the course.
|
||||
* @returns {Promise} Promise containing a list of users
|
||||
*/
|
||||
const getGradabaleUsersFromCourseID = (courseid, groupID, onlyActive = false) => {
|
||||
const request = {
|
||||
methodname: 'core_grades_get_gradable_users',
|
||||
args: {
|
||||
courseid: courseid,
|
||||
groupid: groupID,
|
||||
onlyactive: onlyActive,
|
||||
},
|
||||
};
|
||||
|
||||
return Ajax.call([request])[0];
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the completion state of an activity with manual completion.
|
||||
*
|
||||
@ -172,6 +193,7 @@ export default {
|
||||
getEnrolledCoursesByTimelineClassification,
|
||||
getLastAccessedCourses,
|
||||
getUsersFromCourseModuleID: getEnrolledUsersFromCourseModuleID,
|
||||
getGradableUsersFromCourseID: getGradabaleUsersFromCourseID,
|
||||
toggleManualCompletion,
|
||||
getEnrolledCoursesWithEventsByTimelineClassification,
|
||||
};
|
||||
|
55
grade/classes/external/get_gradable_users.php
vendored
55
grade/classes/external/get_gradable_users.php
vendored
@ -17,8 +17,6 @@
|
||||
namespace core_grades\external;
|
||||
|
||||
use coding_exception;
|
||||
use core_external\external_description;
|
||||
use core_user;
|
||||
use core_external\external_api;
|
||||
use core_external\external_function_parameters;
|
||||
use core_external\external_multiple_structure;
|
||||
@ -26,6 +24,7 @@ use core_external\external_single_structure;
|
||||
use core_external\external_value;
|
||||
use core_external\external_warnings;
|
||||
use core_external\restricted_context_exception;
|
||||
use core_user_external;
|
||||
use invalid_parameter_exception;
|
||||
use moodle_exception;
|
||||
use user_picture;
|
||||
@ -41,7 +40,6 @@ require_once($CFG->dirroot . '/user/externallib.php');
|
||||
* @package core_grades
|
||||
* @copyright 2023 Ilya Tregubov <ilya.a.tregubov@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 4.1
|
||||
*/
|
||||
class get_gradable_users extends external_api {
|
||||
|
||||
@ -63,9 +61,9 @@ class get_gradable_users extends external_api {
|
||||
/**
|
||||
* Given a course ID find the gradable users within a group.
|
||||
*
|
||||
* @param int $courseid
|
||||
* @param int|null $groupid
|
||||
* @param bool $onlyactive
|
||||
* @param int $courseid Course ID
|
||||
* @param int|null $groupid Group ID
|
||||
* @param bool $onlyactive Whether we should only return active enrolments.
|
||||
* @return array Users and warnings.
|
||||
* @throws coding_exception
|
||||
* @throws invalid_parameter_exception
|
||||
@ -91,25 +89,15 @@ class get_gradable_users extends external_api {
|
||||
require_capability('moodle/course:viewparticipants', $coursecontext);
|
||||
|
||||
$course = $DB->get_record('course', ['id' => $params['courseid']]);
|
||||
// Create a graded_users_iterator because it will properly check the groups etc.
|
||||
$onlyactive = $onlyactive || !has_capability('moodle/course:viewsuspendedusers', $coursecontext);
|
||||
|
||||
$gui = new \graded_users_iterator($course, null, $params['groupid']);
|
||||
$gui->require_active_enrolment($onlyactive);
|
||||
$gui->init();
|
||||
|
||||
// Flatten the users.
|
||||
$users = [];
|
||||
while ($user = $gui->next_user()) {
|
||||
$users[$user->user->id] = $user->user;
|
||||
}
|
||||
$gui->close();
|
||||
|
||||
$users = get_gradable_users($course->id, $params['groupid'], $onlyactive);
|
||||
$users = array_map(function ($user) use ($PAGE) {
|
||||
$user->fullname = fullname($user);
|
||||
$userpicture = new user_picture($user);
|
||||
$userpicture->size = 1;
|
||||
$user->profileimage = $userpicture->get_url($PAGE)->out(false);
|
||||
$user->profileimageurlsmall = $userpicture->get_url($PAGE)->out(false);
|
||||
$user->profileimageurl = $userpicture->get_url($PAGE)->out(false);
|
||||
return $user;
|
||||
}, $users);
|
||||
sort($users);
|
||||
@ -127,35 +115,8 @@ class get_gradable_users extends external_api {
|
||||
*/
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'users' => new external_multiple_structure(self::user_description()),
|
||||
'users' => new external_multiple_structure(core_user_external::user_description()),
|
||||
'warnings' => new external_warnings(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user return value description.
|
||||
*
|
||||
* @return external_description
|
||||
*/
|
||||
public static function user_description(): external_description {
|
||||
$userfields = [
|
||||
'id' => new external_value(core_user::get_property_type('id'), 'ID of the user'),
|
||||
'profileimage' => new external_value(
|
||||
PARAM_URL,
|
||||
'The location of the users larger image',
|
||||
VALUE_OPTIONAL
|
||||
),
|
||||
'fullname' => new external_value(PARAM_TEXT, 'The full name of the user', VALUE_OPTIONAL),
|
||||
'firstname' => new external_value(
|
||||
core_user::get_property_type('firstname'),
|
||||
'The first name(s) of the user',
|
||||
VALUE_OPTIONAL),
|
||||
'lastname' => new external_value(
|
||||
core_user::get_property_type('lastname'),
|
||||
'The family name of the user',
|
||||
VALUE_OPTIONAL),
|
||||
];
|
||||
return new external_single_structure($userfields);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -791,6 +791,7 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
|
||||
*/
|
||||
function get_gradable_users(int $courseid, ?int $groupid = null, bool $onlyactiveenrol = false): array {
|
||||
$course = get_course($courseid);
|
||||
// Create a graded_users_iterator because it will properly check the groups etc.
|
||||
$gui = new graded_users_iterator($course, null, $groupid);
|
||||
$gui->require_active_enrolment($onlyactiveenrol);
|
||||
$gui->init();
|
||||
|
@ -960,14 +960,13 @@ abstract class grade_report {
|
||||
*
|
||||
* @param int $courseid The course ID.
|
||||
* @param int|null $groupid The group ID (optional).
|
||||
* @return array $users A list of enrolled gradable users.
|
||||
* @return array A list of enrolled gradable users.
|
||||
*/
|
||||
public static function get_gradable_users(int $courseid, ?int $groupid = null): array {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/grade/lib.php');
|
||||
|
||||
$context = context_course::instance($courseid);
|
||||
// Create a graded_users_iterator because it will properly check the groups etc.
|
||||
$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
|
||||
$onlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol) ||
|
||||
!has_capability('moodle/course:viewsuspendedusers', $context);
|
||||
|
26
grade/tests/external/get_gradable_users_test.php
vendored
26
grade/tests/external/get_gradable_users_test.php
vendored
@ -89,7 +89,7 @@ class get_gradable_users_test extends \externallib_advanced_testcase {
|
||||
'fullname' => $user['fullname'],
|
||||
'firstname' => $user['firstname'],
|
||||
'lastname' => $user['lastname'],
|
||||
'profileimage' => $user['profileimage'],
|
||||
'profileimageurl' => $user['profileimageurl'],
|
||||
];
|
||||
}, array_values($result['users']));
|
||||
$this->assertEquals($expected, $mapped);
|
||||
@ -107,31 +107,31 @@ class get_gradable_users_test extends \externallib_advanced_testcase {
|
||||
false,
|
||||
[
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Apple',
|
||||
'lastname' => 'Apricot',
|
||||
'fullname' => 'Apple Apricot',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Banana',
|
||||
'lastname' => 'Blueberry',
|
||||
'fullname' => 'Banana Blueberry',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Cherry',
|
||||
'lastname' => 'Cranberry',
|
||||
'fullname' => 'Cherry Cranberry',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Durian',
|
||||
'lastname' => 'Dracontomelon',
|
||||
'fullname' => 'Durian Dracontomelon',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Eggplant',
|
||||
'lastname' => 'Ensete',
|
||||
'fullname' => 'Eggplant Ensete',
|
||||
@ -143,25 +143,25 @@ class get_gradable_users_test extends \externallib_advanced_testcase {
|
||||
false,
|
||||
[
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Apple',
|
||||
'lastname' => 'Apricot',
|
||||
'fullname' => 'Apple Apricot',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Banana',
|
||||
'lastname' => 'Blueberry',
|
||||
'fullname' => 'Banana Blueberry',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Cherry',
|
||||
'lastname' => 'Cranberry',
|
||||
'fullname' => 'Cherry Cranberry',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Durian',
|
||||
'lastname' => 'Dracontomelon',
|
||||
'fullname' => 'Durian Dracontomelon',
|
||||
@ -173,19 +173,19 @@ class get_gradable_users_test extends \externallib_advanced_testcase {
|
||||
true,
|
||||
[
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Apple',
|
||||
'lastname' => 'Apricot',
|
||||
'fullname' => 'Apple Apricot',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Banana',
|
||||
'lastname' => 'Blueberry',
|
||||
'fullname' => 'Banana Blueberry',
|
||||
],
|
||||
[
|
||||
'profileimage' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'profileimageurl' => 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f1',
|
||||
'firstname' => 'Cherry',
|
||||
'lastname' => 'Cranberry',
|
||||
'fullname' => 'Cherry Cranberry',
|
||||
|
@ -7,6 +7,7 @@ Information provided here is intended especially for developers.
|
||||
* The grade_structure::get_element_header() function has been deprecated. Please use grade_helper::get_element_header() instead.
|
||||
* The grade_structure::get_activity_link() functions has been deprecated. Please use grade_helper::get_activity_link() instead.
|
||||
* The function get_gradable_users() in grade/lib.php has extra param now to retrieve only active enrolments.
|
||||
* A new webservice core_grades_get_gradable_users has been added to retrieve gradable users for a course.
|
||||
|
||||
=== 4.3 ===
|
||||
* The $showtitle parameter in the print_grade_page_head function located inside grade/lib.php has been deprecated and is not used anymore.
|
||||
|
2
mod/forum/amd/build/grades/grader.min.js
vendored
2
mod/forum/amd/build/grades/grader.min.js
vendored
@ -5,6 +5,6 @@ define("mod_forum/grades/grader",["exports","./grader/selectors","mod_forum/repo
|
||||
* @module mod_forum/grades/grader
|
||||
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.registerLaunchListeners=void 0,Selectors=_interopRequireWildcard(Selectors),_repository=_interopRequireDefault(_repository),_templates=_interopRequireDefault(_templates),Grader=_interopRequireWildcard(Grader),_notification=_interopRequireDefault(_notification),_repository2=_interopRequireDefault(_repository2);const templateNames_contentRegion="mod_forum/grades/grader/discussion/posts",getContentForUserIdFunction=(cmid,experimentalDisplayMode)=>userid=>_repository.default.getDiscussionByUserID(userid,cmid).then((context=>(context.discussions=context.discussions.map(discussionPostMapper),context.experimentaldisplaymode=!!experimentalDisplayMode,_templates.default.render(templateNames_contentRegion,context)))).catch(_notification.default.exception),getUsersForCmidFunction=(cmid,groupID,onlyActive)=>async()=>(await _repository2.default.getUsersFromCourseModuleID(cmid,groupID,onlyActive)).users,findGradableNode=node=>node.closest(Selectors.gradableItem),discussionPostMapper=discussion=>{const parentMap=new Map;discussion.posts.parentposts.forEach((post=>parentMap.set(post.id,post)));const userPosts=discussion.posts.userposts.map((post=>{post.readonly=!0,post.hasreplies=!1,post.replies=[];const parent=post.parentid?parentMap.get(post.parentid):null;return parent&&(parent.hasreplies=!1,parent.replies=[],parent.readonly=!0,post.parentauthorname=parent.author.fullname),{parent:parent,post:post}}));return{...discussion,posts:userPosts}};_exports.registerLaunchListeners=()=>{document.addEventListener("click",(async e=>{if(e.target.matches(Selectors.launch)){const rootNode=findGradableNode(e.target);if(!rootNode)throw Error("Unable to find a gradable item");if(!rootNode.matches(Selectors.gradableItems.wholeForum))throw Error("Unable to find a valid gradable item");e.preventDefault();try{await async function(rootNode){let{focusOnClose:focusOnClose=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const data=rootNode.dataset,gradingPanelFunctions=await Grader.getGradingPanelFunctions("mod_forum",data.contextid,data.gradingComponent,data.gradingComponentSubtype,data.gradableItemtype),groupID=data.group?data.group:0,onlyActive=data.gradeOnlyActiveUsers;await Grader.launch(getUsersForCmidFunction(data.cmid,groupID,onlyActive),getContentForUserIdFunction(data.cmid,"1"==data.experimentalDisplayMode),gradingPanelFunctions.getter,gradingPanelFunctions.setter,{groupid:data.groupid,initialUserId:data.initialuserid,moduleName:data.name,courseName:data.courseName,courseUrl:(0,_url.relativeUrl)("/course/view.php",{id:data.courseId}),sendStudentNotifications:data.sendStudentNotifications,focusOnClose:focusOnClose})}(rootNode,{focusOnClose:e.target})}catch(error){_notification.default.exception(error)}}if(e.target.matches(Selectors.viewGrade)){e.preventDefault();const rootNode=findGradableNode(e.target);if(!rootNode)throw Error("Unable to find a gradable item");if(!rootNode.matches(Selectors.gradableItems.wholeForum))throw Error("Unable to find a valid gradable item");e.preventDefault();try{await async function(rootNode){let{focusOnClose:focusOnClose=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const data=rootNode.dataset,gradingPanelFunctions=await Grader.getGradingPanelFunctions("mod_forum",data.contextid,data.gradingComponent,data.gradingComponentSubtype,data.gradableItemtype);await Grader.view(gradingPanelFunctions.getter,data.userid,data.name,{focusOnClose:focusOnClose})}(rootNode,{focusOnClose:e.target})}catch(error){_notification.default.exception(error)}}}))}}));
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.registerLaunchListeners=void 0,Selectors=_interopRequireWildcard(Selectors),_repository=_interopRequireDefault(_repository),_templates=_interopRequireDefault(_templates),Grader=_interopRequireWildcard(Grader),_notification=_interopRequireDefault(_notification),_repository2=_interopRequireDefault(_repository2);const templateNames_contentRegion="mod_forum/grades/grader/discussion/posts",getContentForUserIdFunction=(cmid,experimentalDisplayMode)=>userid=>_repository.default.getDiscussionByUserID(userid,cmid).then((context=>(context.discussions=context.discussions.map(discussionPostMapper),context.experimentaldisplaymode=!!experimentalDisplayMode,_templates.default.render(templateNames_contentRegion,context)))).catch(_notification.default.exception),getGradableUsersForCourseidFunction=(courseID,groupID,onlyActive)=>async()=>(await _repository2.default.getGradableUsersFromCourseID(courseID,groupID,onlyActive)).users,findGradableNode=node=>node.closest(Selectors.gradableItem),discussionPostMapper=discussion=>{const parentMap=new Map;discussion.posts.parentposts.forEach((post=>parentMap.set(post.id,post)));const userPosts=discussion.posts.userposts.map((post=>{post.readonly=!0,post.hasreplies=!1,post.replies=[];const parent=post.parentid?parentMap.get(post.parentid):null;return parent&&(parent.hasreplies=!1,parent.replies=[],parent.readonly=!0,post.parentauthorname=parent.author.fullname),{parent:parent,post:post}}));return{...discussion,posts:userPosts}};_exports.registerLaunchListeners=()=>{document.addEventListener("click",(async e=>{if(e.target.matches(Selectors.launch)){const rootNode=findGradableNode(e.target);if(!rootNode)throw Error("Unable to find a gradable item");if(!rootNode.matches(Selectors.gradableItems.wholeForum))throw Error("Unable to find a valid gradable item");e.preventDefault();try{await async function(rootNode){let{focusOnClose:focusOnClose=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const data=rootNode.dataset,gradingPanelFunctions=await Grader.getGradingPanelFunctions("mod_forum",data.contextid,data.gradingComponent,data.gradingComponentSubtype,data.gradableItemtype),groupID=data.group?data.group:0,onlyActive=data.gradeOnlyActiveUsers;await Grader.launch(getGradableUsersForCourseidFunction(data.courseId,groupID,onlyActive),getContentForUserIdFunction(data.cmid,"1"==data.experimentalDisplayMode),gradingPanelFunctions.getter,gradingPanelFunctions.setter,{groupid:data.groupid,initialUserId:data.initialuserid,moduleName:data.name,courseName:data.courseName,courseUrl:(0,_url.relativeUrl)("/course/view.php",{id:data.courseId}),sendStudentNotifications:data.sendStudentNotifications,focusOnClose:focusOnClose})}(rootNode,{focusOnClose:e.target})}catch(error){_notification.default.exception(error)}}if(e.target.matches(Selectors.viewGrade)){e.preventDefault();const rootNode=findGradableNode(e.target);if(!rootNode)throw Error("Unable to find a gradable item");if(!rootNode.matches(Selectors.gradableItems.wholeForum))throw Error("Unable to find a valid gradable item");e.preventDefault();try{await async function(rootNode){let{focusOnClose:focusOnClose=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const data=rootNode.dataset,gradingPanelFunctions=await Grader.getGradingPanelFunctions("mod_forum",data.contextid,data.gradingComponent,data.gradingComponentSubtype,data.gradableItemtype);await Grader.view(gradingPanelFunctions.getter,data.userid,data.name,{focusOnClose:focusOnClose})}(rootNode,{focusOnClose:e.target})}catch(error){_notification.default.exception(error)}}}))}}));
|
||||
|
||||
//# sourceMappingURL=grader.min.js.map
|
File diff suppressed because one or more lines are too long
@ -60,13 +60,13 @@ const getContentForUserIdFunction = (cmid, experimentalDisplayMode) => (userid)
|
||||
* Curried function with CMID set, this is then used in unified grader as a fetch users call.
|
||||
* The function curried fetches all users in a course for a given CMID.
|
||||
*
|
||||
* @param {Number} cmid
|
||||
* @param {Number} courseID
|
||||
* @param {Number} groupID
|
||||
* @param {Boolean} onlyActive Whether to fetch only the active enrolled users or all enrolled users in the course.
|
||||
* @return {Array} Array of users for a given context.
|
||||
*/
|
||||
const getUsersForCmidFunction = (cmid, groupID, onlyActive) => async() => {
|
||||
const context = await CourseRepository.getUsersFromCourseModuleID(cmid, groupID, onlyActive);
|
||||
const getGradableUsersForCourseidFunction = (courseID, groupID, onlyActive) => async() => {
|
||||
const context = await CourseRepository.getGradableUsersFromCourseID(courseID, groupID, onlyActive);
|
||||
|
||||
return context.users;
|
||||
};
|
||||
@ -132,7 +132,7 @@ const launchWholeForumGrading = async(rootNode, {
|
||||
const onlyActive = data.gradeOnlyActiveUsers;
|
||||
|
||||
await Grader.launch(
|
||||
getUsersForCmidFunction(data.cmid, groupID, onlyActive),
|
||||
getGradableUsersForCourseidFunction(data.courseId, groupID, onlyActive),
|
||||
getContentForUserIdFunction(data.cmid, data.experimentalDisplayMode == "1"),
|
||||
gradingPanelFunctions.getter,
|
||||
gradingPanelFunctions.setter,
|
||||
|
@ -52,4 +52,4 @@
|
||||
require(['mod_forum/grades/grader'], function(Grader) {
|
||||
Grader.registerLaunchListeners();
|
||||
});
|
||||
{{/js}}
|
||||
{{/js}}
|
||||
|
@ -38,13 +38,13 @@
|
||||
"total": 7
|
||||
}
|
||||
}}
|
||||
{{#profileimage}}
|
||||
{{#profileimageurl}}
|
||||
<img
|
||||
class="rounded-circle userpicture mr-2"
|
||||
src="{{.}}"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{{/profileimage}}
|
||||
{{/profileimageurl}}
|
||||
<div class="overflow-hidden">
|
||||
<h5
|
||||
class="mb-0 font-weight-bold user-full-name text-truncate"
|
||||
|
@ -161,3 +161,18 @@ Feature: I can grade a students interaction across a forum
|
||||
Then the field "Maximum grade" matches value "10"
|
||||
Then the field "Grade to pass" matches value "4"
|
||||
And I should see "Tutor" in the "Parent category" "fieldset"
|
||||
|
||||
Scenario: Ensure that only gradable users are available in forum grading interface
|
||||
Given I am on the "Test Forum 1" "forum activity editing" page logged in as "admin"
|
||||
And I expand all fieldsets
|
||||
When I set the field "Whole forum grading > Type" to "Point"
|
||||
And I set the field "Whole forum grading > Maximum grade" to "10"
|
||||
And I set the field "Whole forum grading > Grade to pass" to "4"
|
||||
And I press "Save and display"
|
||||
And I press "Grade users"
|
||||
Then I should see "1 out of 1"
|
||||
And I should see "Student 1"
|
||||
And I should not see "Teacher 1"
|
||||
And I press "Save changes and proceed to the next user"
|
||||
And I should see "Student 1"
|
||||
And I should not see "Teacher 1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user