Giter Club home page Giter Club logo

moodle-local_resort_courses's Introduction

moodle-local_resort_courses

Moodle Plugin CI

Moodle plugin which sorts a category page automatically as soon as a course has been added or modified

Requirements

This plugin requires Moodle 4.3+

Motivation for this plugin

Moodle core does not take care that Moodle course categories are sorted automatically. There is a sort button on every category page, but this button has to be pushed manually.

This approach makes sense if the course manager really needs to be in control of the sort order, but most of the time pressing the sort button manually after adding or updating a course is a daunting task.

If you want to get rid of this senseless job of pushing the sort button manually, this plugin is for you.

Installation

Install the plugin like any other plugin to folder /local/resort_courses

See http://docs.moodle.org/en/Installing_plugins for details on installing Moodle plugins

Usage & Settings

After installing the plugin, it is active and fully working.

As soon as a course has been added or modified in a category, the plugin verifies that the containing category page is automatically sorted just as it would be sorted when you change the sorting filter on the course category management page.

To configure the plugin and its behaviour, please visit: Site administration -> Courses -> Re-sort courses.

There, you find two sections:

1. Sort order

By default, local_resort_courses sorts categories by course full name in ascending order, just as the filter on the course category management page is set by default. By setting the "Sort order" setting to another value, you can control the sort order of the course list.

2. Skip categories

By default, local_resort_courses handles re-sort jobs for every category. By selecting one or multiple categories in the "Skip categories" setting, you can define categories which mustn't be sorted automatically and whose sort order can still be controlled manually.

By default, when you select one or multiple categories in the "Skip categories" setting, local_resort_courses skips only the categories which are selected in the preceding setting. By checking the "Skip categories recursively" setting, you can define that local_resort_courses should skip the selected categories and all of their descendant categories when handling re-sort jobs.

Capabilities

This plugin does not add any additional capabilities.

How this plugin works

This plugin simply catches the course_created and course_updated events which are fired when a course is created and updates and sorts the course's category automatically. That's it.

Additionally, there is a scheduled task local_resort_courses\task\resort_courses which is disabled by default but which can be enabled to make sure that all categories are sorted properly in any case.

Theme support

This plugin acts behind the scenes, therefore it should work with all Moodle themes. This plugin is developed and tested on Moodle Core's Boost theme. It should also work with Boost child themes, including Moodle Core's Classic theme. However, we can't support any other theme than Boost.

Plugin repositories

This plugin is published and regularly updated in the Moodle plugins repository: http://moodle.org/plugins/view/local_resort_courses

The latest development version can be found on Github: https://github.com/moodle-an-hochschulen/moodle-local_resort_courses

Bug and problem reports / Support requests

This plugin is carefully developed and thoroughly tested, but bugs and problems can always appear.

Please report bugs and problems on Github: https://github.com/moodle-an-hochschulen/moodle-local_resort_courses/issues

We will do our best to solve your problems, but please note that due to limited resources we can't always provide per-case support.

Feature proposals

Due to limited resources, the functionality of this plugin is primarily implemented for our own local needs and published as-is to the community. We are aware that members of the community will have other needs and would love to see them solved by this plugin.

Please issue feature proposals on Github: https://github.com/moodle-an-hochschulen/moodle-local_resort_courses/issues

Please create pull requests on Github: https://github.com/moodle-an-hochschulen/moodle-local_resort_courses/pulls

We are always interested to read about your feature proposals or even get a pull request from you, but please accept that we can handle your issues only as feature proposals and not as feature requests.

Moodle release support

Due to limited resources, this plugin is only maintained for the most recent major release of Moodle as well as the most recent LTS release of Moodle. Bugfixes are backported to the LTS release. However, new features and improvements are not necessarily backported to the LTS release.

Apart from these maintained releases, previous versions of this plugin which work in legacy major releases of Moodle are still available as-is without any further updates in the Moodle Plugins repository.

There may be several weeks after a new major release of Moodle has been published until we can do a compatibility check and fix problems if necessary. If you encounter problems with a new major release of Moodle - or can confirm that this plugin still works with a new major release - please let us know on Github.

If you are running a legacy version of Moodle, but want or need to run the latest version of this plugin, you can get the latest version of the plugin, remove the line starting with $plugin->requires from version.php and use this latest plugin version then on your legacy Moodle. However, please note that you will run this setup completely at your own risk. We can't support this approach in any way and there is an undeniable risk for erratic behavior.

Translating this plugin

This Moodle plugin is shipped with an english language pack only. All translations into other languages must be managed through AMOS (https://lang.moodle.org) by what they will become part of Moodle's official language pack.

As the plugin creator, we manage the translation into german for our own local needs on AMOS. Please contribute your translation into all other languages in AMOS where they will be reviewed by the official language pack maintainers for Moodle.

Right-to-left support

This plugin has not been tested with Moodle's support for right-to-left (RTL) languages. If you want to use this plugin with a RTL language and it doesn't work as-is, you are free to send us a pull request on Github with modifications.

Maintainers

The plugin is maintained by
Moodle an Hochschulen e.V.

Copyright

The copyright of this plugin is held by
Moodle an Hochschulen e.V.

Individual copyrights of individual developers are tracked in PHPDoc comments and Git commits.

Initial copyright

This plugin was initially built, maintained and published by
Ulm University
Communication and Information Centre (kiz)
Alexander Bias

It was contributed to the Moodle an Hochschulen e.V. plugin catalogue in 2022.

moodle-local_resort_courses's People

Contributors

abias avatar ewallah avatar kathrin84 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

moodle-local_resort_courses's Issues

PHPUnit errors

THX for this great plugin!

However this plugin works so rigorously that other core and extra plugins fail their tests:

Moodle 3.7.2+ (Build: 20191008), 4e034ba84a11d24de26a37ba9470f9ced6a0c379
Php: 7.2.19.0.0.18.04.2, pgsql: 10.10 (Ubuntu 10.10-0ubuntu0.18.04.1), OS: Linux 4.15.0-65-generic x86_64
PHPUnit 7.5.15 by Sebastian Bergmann and contributors.

There were 24 failures:

1) core_course_category_testcase::test_get_search_courses
 vendor/bin/phpunit "core_course_category_testcase" course/tests/category_test.php

2) core_course_courselib_testcase::test_course_change_sortorder_after_course
 vendor/bin/phpunit "core_course_courselib_testcase" course/tests/courselib_test.php

3) core_course_courselib_testcase::test_course_change_sortorder_by_one
 vendor/bin/phpunit "core_course_courselib_testcase" course/tests/courselib_test.php

4) core_course_courselib_testcase::test_course_get_tagged_course_modules
 vendor/bin/phpunit "core_course_courselib_testcase" course/tests/courselib_test.php

5) core_course_management_helper_test::test_action_course_movedown_and_moveup
 vendor/bin/phpunit "core_course_management_helper_test" course/tests/management_helper_test.php

6) core_enrollib_testcase::test_enrol_get_my_courses_include_hidden
 vendor/bin/phpunit "core_enrollib_testcase" enrol/tests/enrollib_test.php

7) core_enrollib_testcase::test_enrol_get_my_courses_all_accessible
 vendor/bin/phpunit "core_enrollib_testcase" enrol/tests/enrollib_test.php

8) mod_book_lib_testcase::test_mod_book_get_tagged_chapters
 vendor/bin/phpunit "mod_book_lib_testcase" mod/book/tests/lib_test.php

9) mod_data_external_testcase::test_mod_data_get_databases_by_courses
 vendor/bin/phpunit "mod_data_external_testcase" mod/data/tests/externallib_test.php

10) mod_feedback_external_testcase::test_mod_feedback_get_feedbacks_by_courses
 vendor/bin/phpunit "mod_feedback_external_testcase" mod/feedback/tests/external_test.php

11) mod_forum_lib_testcase::test_mod_forum_get_tagged_posts
 vendor/bin/phpunit "mod_forum_lib_testcase" mod/forum/tests/lib_test.php

12) mod_glossary_lib_testcase::test_mod_glossary_get_tagged_entries
 vendor/bin/phpunit "mod_glossary_lib_testcase" mod/glossary/tests/lib_test.php

13) mod_label_external_testcase::test_mod_label_get_labels_by_courses
 vendor/bin/phpunit "mod_label_external_testcase" mod/label/tests/externallib_test.php

14) mod_lesson_external_testcase::test_mod_lesson_get_lessons_by_courses
 vendor/bin/phpunit "mod_lesson_external_testcase" mod/lesson/tests/external_test.php

15) mod_lti_external_testcase::test_mod_lti_get_ltis_by_courses
 vendor/bin/phpunit "mod_lti_external_testcase" mod/lti/tests/externallib_test.php

16) mod_page_external_testcase::test_mod_page_get_pages_by_courses
 vendor/bin/phpunit "mod_page_external_testcase" mod/page/tests/externallib_test.php

17) mod_quiz_external_testcase::test_mod_quiz_get_quizzes_by_courses
 vendor/bin/phpunit "mod_quiz_external_testcase" mod/quiz/tests/external_test.php

18) mod_resource_external_testcase::test_mod_resource_get_resources_by_courses
 vendor/bin/phpunit "mod_resource_external_testcase" mod/resource/tests/externallib_test.php

19) mod_scorm_external_testcase::test_mod_scorm_get_scorms_by_courses
 vendor/bin/phpunit "mod_scorm_external_testcase" mod/scorm/tests/externallib_test.php

20) mod_survey_external_testcase::test_mod_survey_get_surveys_by_courses
 vendor/bin/phpunit "mod_survey_external_testcase" mod/survey/tests/externallib_test.php

21) mod_url_external_testcase::test_mod_url_get_urls_by_courses
 vendor/bin/phpunit "mod_url_external_testcase" mod/url/tests/externallib_test.php

22) mod_wiki_external_testcase::test_mod_wiki_get_wikis_by_courses
 vendor/bin/phpunit "mod_wiki_external_testcase" mod/wiki/tests/externallib_test.php

23) mod_wiki_lib_testcase::test_mod_wiki_get_tagged_pages
 vendor/bin/phpunit "mod_wiki_lib_testcase" mod/wiki/tests/lib_test.php

24) mod_workshop_external_testcase::test_mod_workshop_get_workshops_by_courses
 vendor/bin/phpunit "mod_workshop_external_testcase" mod/workshop/tests/external_test.php

Perhaps adding a PHPUNIT_RESORT global to pass the local_resort_courses phpunit tests could be an option? If PHPUNIT_RESORT AND PHPUNIT_TEST then do resort, If PHPUNIT_TEST only then do nothing.

skipcategories has wrong default value

The local_resort_courses/skipcategories setting is skipped.

Steps to detect the error:

  1. Install plugin
  2. Initialize behat
  3. Test the admin_bookmarks block using vendor/bin/behat -- blocks/admin_bookmarks/tests/behat/bookmark_admin_pages.feature

Expected result: 3 scenarios (3 passed) 28 steps (28 passed)
Actual result: 3 scenarios (1 passed, 2 failed) 28 steps (21 passed, 2 failed, 5 skipped)

The 2 failures are related to a not yet stored skipcategories setting:

capture_001_08032020_154144

Moodle 37 throws notice Undefined property: stdClass::$visible

I have successfully installed the plugin on Moodle 3.7.1.
However, the debugger throws this whenever re-sorting is triggered:

Notice: Undefined property: stdClass::$visible in ...\course\classes\category.php on line 677

It's just a notice, but apparently something is not compatible with Moodle 37* .

Moodle 4.0

Hello
Do you plan a release for Moodle 4.0 ?
if so, when will it be published?
Thank you

Regularly sorting courses using cron

Hi
do you think it would be possible to add this ?
or maybe have a CLI script that i would be able to run each time i want to sort everything ?

PHPUnit reports warnings

In file localib.php please fix to:

if(!empty($config->skipcategories)){
    $skipcategories = explode(',', $config->skipcategories);
    if (is_array($skipcategories)) {
        if (in_array($category->id, $skipcategories)) {
            return true; // Category has to be skipped -> let's return and leave the category unsorted
        }
    }

}
``
beacuse reports a lot of warnings:

EDebugging: Exception encountered in event observer 'resort_courses': Undefined property: stdClass::$skipcategories

  • line 64 of /local/resort_courses/locallib.php: call to PHPUnit_Util_ErrorHandler::handleError()
  • line ? of unknownfile: call to resort_courses()
  • line 155 of /lib/classes/event/manager.php: call to call_user_func()
  • line 75 of /lib/classes/event/manager.php: call to core\event\manager::process_buffers()
  • line 721 of /lib/classes/event/base.php: call to core\event\manager::dispatch()
  • line 2583 of /course/lib.php: call to core\event\base->trigger()
  • line 383 of /lib/testing/generator/data_generator.php: call to create_course()
  • line 359 of /lib/tests/datalib_test.php: call to testing_data_generator->create_course()
  • line ? of unknownfile: call to core_datalib_testcase->test_get_coursemodule_from_id()
  • line 988 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php: call to ReflectionMethod->invokeArgs()
  • line 838 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php: call to PHPUnit_Framework_TestCase->runTest()
  • line 80 of /lib/phpunit/classes/advanced_testcase.php: call to PHPUnit_Framework_TestCase->runBare()
  • line 648 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php: call to advanced_testcase->runBare()
  • line 783 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php: call to PHPUnit_Framework_TestResult->run()
  • line 779 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php: call to PHPUnit_Framework_TestCase->run()
  • line 749 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php: call to PHPUnit_Framework_TestSuite->runTest()
  • line 709 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php: call to PHPUnit_Framework_TestSuite->run()
  • line 709 of /vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php: call to PHPUnit_Framework_TestSuite->run()
  • line 350 of /vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php: call to PHPUnit_Framework_TestSuite->run()
  • line 176 of /vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php: call to PHPUnit_TextUI_TestRunner->doRun()
  • line 129 of /vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php: call to PHPUnit_TextUI_Command->run()
  • line 63 of /vendor/phpunit/phpunit/composer/bin/phpunit: call to PHPUnit_TextUI_Command::main()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.