Giter Club home page Giter Club logo

moodle-lifecycletrigger_byrole's People

Contributors

ninaherrmann avatar tobiasreischmann avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

moodle-lifecycletrigger_byrole's Issues

Nesting of if statements in handle_course

I would suggest an a bit more readable version of the if statement nesting in handle course.
Either:

if ($intable === false && $hasrole === false) {
  \\ Code
} else if ($intable === false && $hasrole === false) {
  \\ Code
} else if ($intable === false && $hasrole === false) {
  \\ Code
}
return false;

or

if ($intable === true) {
    if ($hasrole === true) {
        \\ Code
    } else {
        \\ Code
    }
} else {
    if ($hasrole === true) {
        \\ Code
    } else {
        \\ Code
    }
}

Bug: category enrolments are not found

If a course has only teachers which are enrolled by category enrolment, this course is detected by this trigger.

This enrolment is not found under the contextid of this course, but under the contextid of the category. ๐Ÿ˜ž

Use courseid separate database field

I think it is better to create a new database field courseid. Usually in moodle each table has an id field, which is just a sequence. Then you no longer need to set custom sequence to true in your DB calls.
To still guarantee that courseid is unique in your database table, you should create a unique key for this column.

Improve PHPdoc of handle_course()

Can you specify the PHPDoc for the two parameters? Especially for $hasrole.
Further scenario 1 of this function is difficult to understand. What is meant with "the course has no role"?

When should the database record be deleted, when a course is triggered?

We already discussed about this earlier. I am still not satisfied with the way handle_course() first removes the database record from your db table and then returning true, without the guarantee that the process is actually triggered.
I would suggest to add events to the core API, when a process for a course is triggered. Then you could listen for this event and remove the db entry only in this case.

Exception 'No Roles defined' is never catched

You should apply a validation to the settings page that at least one role has to be selected.
Additionally, you should catch the exception thrown in get_roles() within check_course(), which should result in an error log and returning next without calling handle_course().

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.