| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente |
| local:my:modules [2016/05/17 15:06] – [Les widgets de la page my améliorée] admin | local:my:modules [2026/11/13 20:37] (Version actuelle) – modification externe 127.0.0.1 |
|---|
| ===== Modules de page d'accueil ===== | <html><!-- nomoodle --></html>{{ :blocks:pagetracker:logo-apl.png?nolink |}}<html><!-- /nomoodle --></html> |
| ===== Mon Moodle Amélioré ===== | ===== Improved My Moodle Widgets===== |
| |
| ==== Les widgets de la page my améliorée ==== | ==== The widgets of the improved my page ==== |
| |
| La page My améliorée utilise sont propre système de widgets pour composer la structure du tableau de bord de l'utilisateur. Ces widgets peuvent être appelés dans l'ordre de parution dans la configuration centrale du composant local ''Ma page améliorée'' | The improved My page uses widgets to compose a customised structure of the user's dashboard. These widgets can be called in their order of appearance in the central configuration of the ''Improved my page'' local component |
| |
| Les widgets sont conçus pour adopter une apparence de blocs, afin de ne pas perturber la logique d'affichage sur des colonnes de blocs latérales sont alimentées. | The widgets are designed to take on the appearance of blocks, so as not to disturb the display logic if blocks are used in Moodle's side areas. |
| |
| ==== Extensibilité du composant ==== | |
| |
| La fabrication de nouveaux widgets est une opération relativement simple, et consiste en l'écriture d'une fonction de nom préfixé par ''local_my_print_<widgetname>'' dans le fichier ''modules.php'' du composant. | ==== List of widgets==== |
| |
| ==== Liste des modules ==== | * ''me'': My identity (simple) |
| | * ''fullme'': My identity (extended) |
| | * ''my_caption'': Lets you fill in a label with the content of your choice. Will be displayed at the top (students and teachers). |
| | * ''static_<n>'': Display of a text block with the message of your choice in the area where the widget is placed |
| | * ''admin_stats'': Useful statistical data (as an administrator) |
| | * ''my_courses'': My courses (as a student) (simple list display) |
| | * ''my_courses_slider'': My courses displayed in a slider or grid (as a student) |
| | * ''my_courses_grid'': My courses displayed in a grid (as a student) |
| | * ''my_favorite_courses_by_role_grid'': My favourite courses taking roles into account |
| | * ''authored_courses'': My courses as author (editing teacher) |
| | * ''authored_courses_slider'': My courses displayed in a slider or grid (editing teacher) |
| | * ''managed_courses'': My courses as coordinator (on capability local/my:iscoursemanager) |
| | * ''managed_courses_slider'': My courses displayed in a slider or grid for the editing teacher role responsible for courses (on capability local/my:iscoursemanager) |
| | * ''teacher_courses'': A combined version of the course display (in collapsible and expandable lists remembered in preferences) as editing and non-editing teacher, which displays a differentiating signal icon for the courses where I have editing rights. |
| | * ''teacher_courses_slider'': Display of courses in a slider for editing or non-editing teachers |
| | * ''teacher_courses_grid'': Display of courses in a grid for editing or non-editing teachers |
| | * ''available_courses'': The courses available for self-enrolment |
| | * ''my_remote_courses'': the courses available on another platform, through the mnet network |
| | * ''my_templates'': The course templates that belong to me (requires teacher role in the templates concerned) |
| | * ''course_areas'': Static "course areas" (which can point to 9 course categories) that display the courses while excluding them from all the other display widgets. |
| | * ''course_areas2'': A second static "course areas" (which can point to 9 course categories) that display the courses while excluding them from all the other display widgets. |
| | * ''course_areas_and_availables'': Same as above, but also includes the courses accessible by self-enrolment. |
| | * ''course_categories_grid'' and ''course_categories2_grid'': A display of the categories designated for highlighting on the dashboard (two possible, to differentiate categories for students and teachers for example) |
| | * ''latestnews_full'': The site news, in full mode (expanded messages) |
| | * ''latestnews_headers'': The site news, in compact mode (titles) |
| | * ''latestnews_simple'': The site news, in simple display (non-hierarchical) |
| | * ''my_heatmap'': An "activity temperature" table |
| | * ''my_network'': My accessible network sites (in the sense of the [[:blocks:UserMnetHosts|User Mnet Hosts]] block) |
| | * ''my_calendar'': The expression of the standard Calendar block |
| | * ''course_search'': The course search engine entry |
| | * ''left_edition_column'': Splits the layout into two columns and adds an editorial column on the left. |
| |
| * ''me'' : Mon identité (simple) | |
| * ''fullme'' : Mon identité (développée) | |
| * ''my_courses'' : Mes cours (en tant qu'étudiant) | |
| * ''authored_courses'' : Mes cours en tant qu'auteur | |
| * ''available_courses'' : Les cours disponibles en auto-inscription | |
| * ''my_templates'' : Les modèles de cours qui m'appartiennent | |
| * ''course_areas'' : Des "Zones de cours" statiques (catégories) qui affichent les cours en les excluant de tous les autres widgets d'affichage. | |
| * ''course_areas_and_availables'' : Idem ci-dessus, mais intègle aussi les cours accessibles en auto-inscription. | |
| * ''latestnews_full'' : Les nouvelles du site, en mode complet (messages développés) | |
| * ''latestnews_headers'' : Les nouvelles du site, en mode compact (titres) | |
| * ''latestnews_simple'' : Les nouvelles du site, en affichage simple (non hiérarchique) | |
| * ''my_heatmap'' : Une table de "température d'activité" | |
| * ''my_network'' : Mes sites accéssibles du réseau (au sens du bloc [[:blocks:UserMnetHosts|User Mnet Hosts]]) | |
| * ''my_calendar'' : L'expression du bloc Calendar standard | |
| * ''course_search'' : L'entrée du moteur de recherche de cours | |
| * ''left_edition_column'' : Dédouble le colonnage et ajoute une colonne éditoriale sur la gauche. | |
| |
| ==== Impact du double colonnage ==== | <html><!-- nomoodle --></html> |
| | * [[local:my:userguidecoursearea|Course areas widget (course_areas and course_areas2]]. |
| | * [[local:my:userguide|User guide and use cases]] |
| | <html><!-- /nomoodle --></html> |
| |
| Si le double colonnage est activé par la présence du ''widget left_edition_column'', alors il est possible de répartir les widgets entre la colonne de droite et le colonne de gauche. Ajoutez le suffixe _L pour obliger un widget à s'empiler dans la colonne de gauche. | ==== Impact of the double column layout ==== |
| |
| [[:Local:My:Technique|Revenir au guide technique]] | If the double column layout is enabled by the presence of the ''left_edition_column'' widget, then it is possible to distribute the widgets between the right column and the left column. Add the _L suffix to force a widget to stack in the left column. |
| | |
| | ==== Static and conditional contents ==== |
| | |
| | The ''static_<n>'' widget has a particular behaviour. It generally lets you publish static contents on the dashboard, between widgets, possibly tied to a condition to meet. Using static widgets requires installing the [[:local:staticguitexts|Static contents]] plugin, which will provide the editing principle. |
| | |
| | The general form of the widget name is ''static_<extension>''. |
| | |
| | * **Simple contents:** if <extension> is an integer (e.g. ''static_1'', ''static_2'', etc), the content is unique and is displayed unconditionally. |
| | * **Contents depending on a profile value:** if the extension has the form ''profile_field_<fieldshortname>__<modalvalue>'', the content is unique and is only displayed if the expected modal value is in the user's profile. |
| | |
| | **profile name shortname:** local_my now accepts a profile field name with underscore. If a value is to be filled in, use a double underscore |
| | |
| | |
| | * **Contents depending on the profile:** if the extension does not mention a value (''profile_field_<fieldshortname>''), then the administrator can enter a different content per available modal value. |
| | |
| | === Modal values === |
| | |
| | Modal values are the different values available for a profile field. If the field is of "list" type, these are the list values. If it is of "text" type, it will be the set of all the texts entered for this field in Moodle. |
| | |
| | The field name and the modal value are separated by a DOUBLE "_". Profile field names containing a single '_' are therefore accepted. |
| | |
| | Modal values are filtered as follows to obtain the modal keys: |
| | |
| | * Spaces and '_' are converted to '-', |
| | * All characters that are not strictly alphanumeric and different from the hyphen (-) are removed. |
| | |
| | ==== Extensibility/customisation of the component ==== |
| | |
| | Making new widgets is a relatively simple operation, and consists of writing a function with a name prefixed by ''local_my_print_<widgetname>(&$excludedcourses, &$courseareacourses)'' in a new ''local_modules.php'' file at the root of the component. The generic modules are coded in the ''modules.php'' file in the same place. |
| | |
| | The widget function receives two parameters: |
| | |
| | * ''&$excludedcourses'': an array of the course ids that must be excluded from the displays of widgets subsequent to this widget. This array is completed by each widget to tell the following widgets which course entries have already been presented to the user, and thus avoid a multitude of display redundancies. The widget function code must add to this array the ids of the courses it presents in its content. |
| | * ''&$courseareacourses'': an array of the courses that will be presented in the 'Course areas' type widgets, even if the course areas are displayed lower in the page. This array must be used read-only. |
| | |
| | The widget function is a pseudo renderer that must return the HTML contained in the widget. You can generate this content directly in the function |
| | |
| | function local_my_print_mysimplewidget(&$excludedcourses, &$courseareacourses) { |
| | // Get a list of courses through a custom function (associative by id). |
| | $courses = local_my_get_custom_courseset(); |
| | |
| | // Remove the courses captured by the course areas. |
| | if (!empty($courseareacourses)) { |
| | foreach ($courseareacourses as $cid) { |
| | if (array_key_exists($cid, $courses)) { |
| | unset($courses[$cid]); |
| | } |
| | } |
| | } |
| | |
| | // Remove the courses excluded before. |
| | if (!empty($excludedcourses)) { |
| | foreach ($excludedcourses as $cid) { |
| | if (array_key_exists($cid, $courses)) { |
| | unset($courses[$cid]); |
| | } |
| | } |
| | } |
| | |
| | // Add what remains to the exclusions. |
| | foreach (array_keys($courses) as $cid) { |
| | $excludedcourses[] = $cid; |
| | } |
| | |
| | $str = ''; |
| | // Print the lists... |
| | return $str; |
| | } |
| | |
| | You can also, as in some widgets, use a template that must be located in the component's ''templates'' directory: |
| | |
| | function local_my_print_templatedwidget(&$excludedcourses, &$courseareacourses) { |
| | global $OUTPUT; |
| | |
| | // ... exclusion code (see above) |
| | |
| | $template = new StdClass(); |
| | $template->data1 = 'value1'; |
| | // .... |
| | |
| | return $OUTPUT->render_from_template('local_my/customtemplate', $template); |
| | } |
| | |
| | <html><!-- nomoodle --></html> |
| | ---- |
| | |
| | [[:Local:My:Technique|Back to the technical guide]] - [[:Local:My|Back to the component index]] - [[:plugins|Back to plugins index]] - [[:start|Back to catalogue]] |
| | <html><!-- /nomoodle --></html> |