/**
* Get icon mapping for font-awesome.
+ *
+ * @return array
*/
-function forum_get_fontawesome_icon_map() {
+function mod_glossary_get_fontawesome_icon_map() {
return [
'mod_glossary:export' => 'fa-download'
];
}
/**
- * Handles creating actions for events.
+ * This function receives a calendar event and returns the action associated with it, or null if there is none.
+ *
+ * This is used by block_myoverview in order to display the event appropriately. If null is returned then the event
+ * is not displayed on the block.
*
* @param calendar_event $event
* @param \core_calendar\action_factory $factory
- * @return \core_calendar\local\event\value_objects\action|\core_calendar\local\interfaces\action_interface|null
+ * @return \core_calendar\local\event\entities\action_interface|null
*/
function mod_glossary_core_calendar_provide_event_action(calendar_event $event,
\core_calendar\action_factory $factory) {
true
);
}
+
+/**
+ * Add a get_coursemodule_info function in case any glossary type wants to add 'extra' information
+ * for the course (see resource).
+ *
+ * Given a course_module object, this function returns any "extra" information that may be needed
+ * when printing this activity in a course listing. See get_array_of_activities() in course/lib.php.
+ *
+ * @param stdClass $coursemodule The coursemodule object (record).
+ * @return cached_cm_info An object on information that the courses
+ * will know about (most noticeably, an icon).
+ */
+function glossary_get_coursemodule_info($coursemodule) {
+ global $DB;
+
+ $dbparams = ['id' => $coursemodule->instance];
+ $fields = 'id, completionentries';
+ if (!$choice = $DB->get_record('glossary', $dbparams, $fields)) {
+ return false;
+ }
+
+ $result = new cached_cm_info();
+
+ // Populate the custom completion rules as key => value pairs, but only if the completion mode is 'automatic'.
+ if ($coursemodule->completion == COMPLETION_TRACKING_AUTOMATIC) {
+ $result->customdata['customcompletionrules']['completionentries'] = $choice->completionentries;
+ }
+
+ return $result;
+}
+
+/**
+ * Callback which returns human-readable strings describing the active completion custom rules for the module instance.
+ *
+ * @param cm_info|stdClass $cm object with fields ->completion and ->customdata['customcompletionrules']
+ * @return array $descriptions the array of descriptions for the custom rules.
+ */
+function mod_glossary_get_completion_active_rule_descriptions($cm) {
+ // Values will be present in cm_info, and we assume these are up to date.
+ if (empty($cm->customdata['customcompletionrules'])
+ || $cm->completion != COMPLETION_TRACKING_AUTOMATIC) {
+ return [];
+ }
+
+ $descriptions = [];
+ foreach ($cm->customdata['customcompletionrules'] as $key => $val) {
+ switch ($key) {
+ case 'completionentries':
+ if (empty($val)) {
+ continue;
+ }
+ $descriptions[] = get_string('completionentriesdesc', 'glossary', $val);
+ break;
+ default:
+ break;
+ }
+ }
+ return $descriptions;
+}