Skip to content

Commit

Permalink
Merge branch 'MDL-71457-master-3' of https://github.com/bmbrands/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Dec 20, 2021
2 parents 06e5340 + 47e63b5 commit 625a22a
Show file tree
Hide file tree
Showing 90 changed files with 643 additions and 227 deletions.
1 change: 1 addition & 0 deletions blocks/site_main_menu/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/* Made specific to win over .block.list_block .unlist > li > .column. */
width: 100%;
display: table;
margin-bottom: 0.5rem;
}

.block_site_main_menu li .buttons a img {
Expand Down
16 changes: 15 additions & 1 deletion course/classes/local/entity/content_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class content_item {
/** @var string $componentname the name of the component from which this content item originates. */
private $componentname;

/** @var string $purpose the purpose type of this component. */
private $purpose;

/**
* The content_item constructor.
*
Expand All @@ -68,9 +71,10 @@ class content_item {
* @param string $help The description of the item.
* @param int $archetype the archetype for the content item (see MOD_ARCHETYPE_X definitions in lib/moodlelib.php).
* @param string $componentname the name of the component/plugin with which this content item is associated.
* @param string $purpose the purpose type of this component.
*/
public function __construct(int $id, string $name, title $title, \moodle_url $link, string $icon, string $help,
int $archetype, string $componentname) {
int $archetype, string $componentname, string $purpose) {
$this->id = $id;
$this->name = $name;
$this->title = $title;
Expand All @@ -79,6 +83,7 @@ public function __construct(int $id, string $name, title $title, \moodle_url $li
$this->help = $help;
$this->archetype = $archetype;
$this->componentname = $componentname;
$this->purpose = $purpose;
}

/**
Expand Down Expand Up @@ -151,4 +156,13 @@ public function get_link(): \moodle_url {
public function get_icon(): string {
return $this->icon;
}

/**
* Get purpose for this item.
*
* @return string
*/
public function get_purpose(): string {
return $this->purpose;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ protected static function define_properties() {
'help' => ['type' => PARAM_RAW, 'description' => 'Html description / help for the content item'],
'archetype' => ['type' => PARAM_RAW, 'description' => 'The archetype of the module exposing the content item'],
'componentname' => ['type' => PARAM_TEXT, 'description' => 'The name of the component exposing the content item'],
'purpose' => ['type' => PARAM_TEXT, 'description' => 'The purpose of the component exposing the content item'],
];
}

Expand Down Expand Up @@ -136,7 +137,8 @@ protected function get_other_values(\renderer_base $output) {
'componentname' => $this->contentitem->get_component_name(),
'favourite' => $favourite,
'legacyitem' => ($this->contentitem->get_id() == -1),
'recommended' => $recommended
'recommended' => $recommended,
'purpose' => $this->contentitem->get_purpose()
];

return $properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ private function content_item_from_legacy_data(\stdClass $item): content_item {
// modname:link, i.e. lti:http://etc...
// We need to grab the module name out to create the componentname.
$modname = (strpos($item->name, ':') !== false) ? explode(':', $item->name)[0] : $item->name;

$purpose = plugin_supports('mod', $modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER);
return new content_item($item->id, $item->name, $item->title, $item->link, $item->icon, $item->help ?? '',
$item->archetype, 'mod_' . $modname);
$item->archetype, 'mod_' . $modname, $purpose);
}

/**
Expand Down Expand Up @@ -202,16 +202,18 @@ public function find_all(): array {
// If the module chooses to implement the hook, this may be thrown away.
$help = $this->get_core_module_help_string($mod->name);
$archetype = plugin_supports('mod', $mod->name, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
$purpose = plugin_supports('mod', $mod->name, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER);

$contentitem = new content_item(
$mod->id,
$mod->name,
new lang_string_title("modulename", $mod->name),
new \moodle_url(''), // No course scope, so just an empty link.
$OUTPUT->pix_icon('icon', '', $mod->name, ['class' => 'icon']),
$OUTPUT->pix_icon('icon', '', $mod->name, ['class' => 'icon activityicon']),
$help,
$archetype,
'mod_' . $mod->name
'mod_' . $mod->name,
$purpose,
);

$modcontentitemreference = clone($contentitem);
Expand Down Expand Up @@ -265,16 +267,18 @@ public function find_all_for_course(\stdClass $course, \stdClass $user): array {
// If the module chooses to implement the hook, this may be thrown away.
$help = $this->get_core_module_help_string($mod->name);
$archetype = plugin_supports('mod', $mod->name, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
$purpose = plugin_supports('mod', $mod->name, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER);

$contentitem = new content_item(
$mod->id,
$mod->name,
new lang_string_title("modulename", $mod->name),
new \moodle_url($urlbase, ['add' => $mod->name]),
$OUTPUT->pix_icon('icon', '', $mod->name, ['class' => 'icon']),
$OUTPUT->pix_icon('icon', '', $mod->name, ['class' => 'icon activityicon']),
$help,
$archetype,
'mod_' . $mod->name
'mod_' . $mod->name,
$purpose,
);

// Legacy vs new hooks.
Expand Down
1 change: 1 addition & 0 deletions course/format/classes/output/local/content/cm/title.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function export_for_template(\renderer_base $output): stdClass {
'pluginname' => get_string('pluginname', 'mod_' . $mod->modname),
'linkclasses' => $displayoptions['linkclasses'],
'textclasses' => $displayoptions['textclasses'],
'purpose' => plugin_supports('mod', $mod->modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER),
];

// File type after name, for alphabetic lists (screen reader).
Expand Down
6 changes: 4 additions & 2 deletions course/format/templates/local/content/cm/title.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
"pluginname": "File",
"altname": "PDF file",
"linkclasses": "",
"textclasses": ""
"textclasses": "",
"purpose": "content",
"modname": "resource"
}
}}
{{#url}}
<div class="activity-instance d-flex flex-column">
<div class="activitytitle media {{textclasses}} modtype_{{modname}} position-relative align-self-start">
<div class="activityiconcontainer courseicon align-self-start mr-3">
<div class="activityiconcontainer {{purpose}} courseicon align-self-start mr-3">
<img src="{{{icon}}}" class="activityicon " alt="{{{modname}}} icon">
</div>
<div class="media-body align-self-center">
Expand Down
10 changes: 7 additions & 3 deletions course/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,13 @@ public function course_section_cm_name_title(cm_info $mod, $displayoptions = arr
$onclick = htmlspecialchars_decode($mod->onclick, ENT_QUOTES);

// Display link itself.
$activitylink = html_writer::empty_tag('img', array('src' => $mod->get_icon_url(),
'class' => 'iconlarge activityicon', 'alt' => '', 'role' => 'presentation', 'aria-hidden' => 'true')) .
html_writer::tag('span', $instancename . $altname, array('class' => 'instancename'));
$instancename = html_writer::tag('span', $instancename . $altname, ['class' => 'instancename ml-1']);

$imageicon = html_writer::empty_tag('img', ['src' => $mod->get_icon_url(),
'class' => 'activityicon', 'alt' => '', 'role' => 'presentation', 'aria-hidden' => 'true']);
$imageicon = html_writer::tag('span', $imageicon, ['class' => 'activityiconcontainer courseicon']);
$activitylink = $imageicon . $instancename;

if ($mod->uservisible) {
$output .= html_writer::link($url, $activitylink, array('class' => 'aalink' . $linkclasses, 'onclick' => $onclick));
} else {
Expand Down
5 changes: 3 additions & 2 deletions course/templates/local/activitychooser/item.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
"urls": {
"addoption": "http://addoptionurl.com"
},
"icon": "<img class='icon' src='http://urltooptionicon'>"
"icon": "<img class='icon' src='http://urltooptionicon'>",
"purpose": "content"
}
}}
<div role="menuitem" tabindex="-1" aria-label="{{title}}" class="option border-0 card m-1 bg-white" data-region="chooser-option-container" data-internal="{{name}}" data-modname="{{componentname}}_{{link}}">
<div class="optioninfo card-body d-flex flex-column text-center p-1" data-region="chooser-option-info-container">
<a class="d-flex flex-column justify-content-between flex-fill" href="{{link}}" title="{{#str}} addnew, moodle, {{title}} {{/str}}" tabindex="-1" data-action="add-chooser-option">
<div class="optionicon mt-2 mb-1 icon-size-5 icon-no-margin">
<div class="optionicon mt-2 mb-1 mx-auto icon-no-margin modicon_{{name}} activityiconcontainer {{purpose}}">
{{{icon}}}
</div>
<div class="optionname clamp-2">{{title}}</div>
Expand Down
7 changes: 5 additions & 2 deletions course/tests/content_item_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function test_content_item() {
$this->resetAfterTest();

$contentitem = new content_item(22, 'Item name', new lang_string_title('modulename', 'mod_assign'),
new \moodle_url('mod_edit.php'), '<img src="test">', 'Description of the module', MOD_ARCHETYPE_RESOURCE, 'mod_page');
new \moodle_url('mod_edit.php'), '<img src="test">', 'Description of the module', MOD_ARCHETYPE_RESOURCE, 'mod_page',
MOD_PURPOSE_CONTENT);

$this->assertEquals(22, $contentitem->get_id());
$this->assertEquals('Item name', $contentitem->get_name());
Expand All @@ -57,6 +58,7 @@ public function test_content_item() {
$this->assertEquals('Description of the module', $contentitem->get_help());
$this->assertEquals(MOD_ARCHETYPE_RESOURCE, $contentitem->get_archetype());
$this->assertEquals('mod_page', $contentitem->get_component_name());
$this->assertEquals('content', $contentitem->get_purpose());
}

/**
Expand All @@ -66,7 +68,8 @@ public function test_content_item_custom_string_title() {
$this->resetAfterTest();

$contentitem = new content_item(22, 'Item name', new string_title('My custom string'),
new \moodle_url('mod_edit.php'), '<img src="test">', 'Description of the module', MOD_ARCHETYPE_RESOURCE, 'mod_page');
new \moodle_url('mod_edit.php'), '<img src="test">', 'Description of the module', MOD_ARCHETYPE_RESOURCE, 'mod_page',
MOD_PURPOSE_CONTENT);

$this->assertEquals('My custom string', $contentitem->get_title()->get_value());
}
Expand Down
3 changes: 2 additions & 1 deletion course/tests/exporters_content_item_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public function test_export_course_content_item_legacy() {
'* First point
* Another point',
MOD_ARCHETYPE_OTHER,
'core_test'
'core_test',
MOD_PURPOSE_CONTENT
);

$ciexporter = new course_content_item_exporter($contentitem, ['context' => \context_course::instance($course->id)]);
Expand Down
12 changes: 11 additions & 1 deletion course/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ This files describes API changes in /course/*,
information provided here is intended especially for developers.

=== 4.0 ===

* All activity icons have been replaced with black monochrome icons. The background
colour for these icons is defined using a new 'FEATURE_MOD_PURPOSE' support variable in the module lib.php file
Available purpose types are:
- MOD_PURPOSE_COMMUNICATION
- MOD_PURPOSE_ASSESSMENT
- MOD_PURPOSE_COLLABORATION
- MOD_PURPOSE_CONTENT
- MOD_PURPOSE_ADMINISTRATION
- MOD_PURPOSE_INTERFACE
- MOD_PURPOSE_OTHER
The colours for these types are defined in theme/boost/scss/moodle/variables.scss
* The format_base is now deprecated. Use core_courseformat\base instead.
* The new course output components deprecate many renderer methods from course
renderer and course format renderer:
Expand Down
17 changes: 17 additions & 0 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,23 @@
/** System (not user-addable) module archetype */
define('MOD_ARCHETYPE_SYSTEM', 3);

/** Type of module */
define('FEATURE_MOD_PURPOSE', 'mod_purpose');
/** Module purpose administration */
define('MOD_PURPOSE_ADMINISTRATION', 'administration');
/** Module purpose assessment */
define('MOD_PURPOSE_ASSESSMENT', 'assessment');
/** Module purpose communication */
define('MOD_PURPOSE_COLLABORATION', 'collaboration');
/** Module purpose communication */
define('MOD_PURPOSE_COMMUNICATION', 'communication');
/** Module purpose content */
define('MOD_PURPOSE_CONTENT', 'content');
/** Module purpose interface */
define('MOD_PURPOSE_INTERFACE', 'interface');
/** Module purpose other */
define('MOD_PURPOSE_OTHER', 'other');

/**
* Security token used for allowing access
* from external application such as web services.
Expand Down
4 changes: 3 additions & 1 deletion mod/assign/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function assign_update_events($assign, $override = null) {
* Return the list if Moodle features this module supports
*
* @param string $feature FEATURE_xx constant for requested feature
* @return mixed True if module supports feature, null if doesn't know
* @return mixed True if module supports feature, false if not, null if doesn't know or string for the module purpose.
*/
function assign_supports($feature) {
switch($feature) {
Expand Down Expand Up @@ -392,6 +392,8 @@ function assign_supports($feature) {
return true;
case FEATURE_COMMENT:
return true;
case FEATURE_MOD_PURPOSE:
return MOD_PURPOSE_ASSESSMENT;

default:
return null;
Expand Down
Binary file modified mod/assign/pix/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions mod/assign/pix/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion mod/assignment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ function assignment_delete_instance($id){

/**
* @param string $feature FEATURE_xx constant for requested feature
* @return mixed True if module supports feature, null if doesn't know
* @return mixed True if module supports feature, false if not, null if doesn't know or string for the module purpose.
*/
function assignment_supports($feature) {
switch($feature) {
case FEATURE_BACKUP_MOODLE2: return true;
case FEATURE_MOD_PURPOSE: return MOD_PURPOSE_ASSESSMENT;

default: return null;
}
Expand Down
Binary file modified mod/assignment/pix/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 625a22a

Please sign in to comment.