Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-6160

email admin when course is requested

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.9.4
    • Component/s: Course
    • Labels:
      None
    • Environment:
      All
    • Affected Branches:
      MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      As the site admin, I would like to receive an email to notify me that a course has been requested so I know to look at the pending requests.

      Ours is a small site, and I do not routinely go to the course creation page where I would see the message that a request was made.

      The email does not need to include any details - a simple statement that a request has been made, so I know that I should deal with it.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            mcampbell Matt Campbell added a comment -

            This is the code I added to /admin/cron.php, just after the language cache is checked (so the course request check will be done every time the cron job is run). I've hard-coded the strings, so you might want to change it a bit and add it to a language file:

            mtrace("Checking course creation requests");
            if ($pending = get_records("course_request"))

            { $admin = get_admin(); $subject = "Course requests pending approval"; $messagetext = "Course requests have been submitted for approval. Please check pending.html."; email_to_user($admin,$admin,$subject,$messagetext); }

            mtrace("Course requests checked");

            Show
            mcampbell Matt Campbell added a comment - This is the code I added to /admin/cron.php, just after the language cache is checked (so the course request check will be done every time the cron job is run). I've hard-coded the strings, so you might want to change it a bit and add it to a language file: mtrace("Checking course creation requests"); if ($pending = get_records("course_request")) { $admin = get_admin(); $subject = "Course requests pending approval"; $messagetext = "Course requests have been submitted for approval. Please check pending.html."; email_to_user($admin,$admin,$subject,$messagetext); } mtrace("Course requests checked");
            Hide
            baltaner Bertold Altaner added a comment -

            Hi,
            i've attached a new cron_course_pending.php which is called by an new crontab-entry e.g. twice a day.
            Possible crontab-entry:
            //0 6,18 * * * root wget -O /var/log/moodle-cron-course-pending http://localhost/moodle/admin/cron-course-pending.php >/dev/null 2>&1 &

            Notice: every time you call this skript admin will receive a email if pending courses are available - so think about your cron-intervall you will call this script...

            Bertold

            Show
            baltaner Bertold Altaner added a comment - Hi, i've attached a new cron_course_pending.php which is called by an new crontab-entry e.g. twice a day. Possible crontab-entry: //0 6,18 * * * root wget -O /var/log/moodle-cron-course-pending http://localhost/moodle/admin/cron-course-pending.php >/dev/null 2>&1 & Notice: every time you call this skript admin will receive a email if pending courses are available - so think about your cron-intervall you will call this script... Bertold
            Hide
            skodak Petr Skoda added a comment -

            oh. forgot about this, sorry :-O
            this should definitely be in 1.9.x

            Show
            skodak Petr Skoda added a comment - oh. forgot about this, sorry :-O this should definitely be in 1.9.x
            Hide
            zwennie Sven Laudel added a comment -

            We did something similar, but not in cron.ph instead in course/request.php:

            //Begin: Informing Admin
            $moodleadmin = get_record('user','id',3);
            $emailText = "Es liegt eine neue Kursanforderung von $USER->firstname $USER->lastname vor! \n\n Titel: $data->fullname \n Grund: $data->reason\n";
            email_to_user($moodleadmin, $USER, 'Neue Kursanforderung', $emailText);
            //End: Informing Admin

            notice(get_string('courserequestsuccess'));

            Thanks to Andre Krüger from Berlin who suggested this to me at moodle.de.

            Show
            zwennie Sven Laudel added a comment - We did something similar, but not in cron.ph instead in course/request.php: //Begin: Informing Admin $moodleadmin = get_record('user','id',3); $emailText = "Es liegt eine neue Kursanforderung von $USER->firstname $USER->lastname vor! \n\n Titel: $data->fullname \n Grund: $data->reason\n"; email_to_user($moodleadmin, $USER, 'Neue Kursanforderung', $emailText); //End: Informing Admin notice(get_string('courserequestsuccess')); Thanks to Andre Krüger from Berlin who suggested this to me at moodle.de.
            Hide
            drecklier James Barrett added a comment -

            We did something similar to this in course_request.php

            but used the form:

            $admin = get_admin();
            $subject = 'course request';
            $messagetext = 'a course has been requested. Go to '.$CFG->wwwroot.'/course/pending.php to see it';
            email_to_user($admin,$USER, $subject, $messagetext);

            This way it is easy to reply to the requesting user and also link to /course/pending.php

            Show
            drecklier James Barrett added a comment - We did something similar to this in course_request.php but used the form: $admin = get_admin(); $subject = 'course request'; $messagetext = 'a course has been requested. Go to '.$CFG->wwwroot.'/course/pending.php to see it'; email_to_user($admin,$USER, $subject, $messagetext); This way it is easy to reply to the requesting user and also link to /course/pending.php
            Hide
            timhunt Tim Hunt added a comment -

            Fixed, mostly thanks to Petr.

            Show
            timhunt Tim Hunt added a comment - Fixed, mostly thanks to Petr.
            Hide
            tsala Helen Foster added a comment -

            Tim and Petr, thanks a lot for fixing this issue

            It's now noted in the documentation:

            http://docs.moodle.org/en/Course_request
            http://docs.moodle.org/en/Moodle_1.9.4_release_notes

            Show
            tsala Helen Foster added a comment - Tim and Petr, thanks a lot for fixing this issue It's now noted in the documentation: http://docs.moodle.org/en/Course_request http://docs.moodle.org/en/Moodle_1.9.4_release_notes
            Hide
            tsala Helen Foster added a comment -

            Thinking a bit more about this feature, it seems weird to enter a username for the user to be notified when new course requested.

            Why not instead have email notification sent to all admins or have a field for entering an email address to which notification should be sent?

            Show
            tsala Helen Foster added a comment - Thinking a bit more about this feature, it seems weird to enter a username for the user to be notified when new course requested. Why not instead have email notification sent to all admins or have a field for entering an email address to which notification should be sent?
            Hide
            timhunt Tim Hunt added a comment -

            Helen, is there a precedent in any of the other admin settings?

            Show
            timhunt Tim Hunt added a comment - Helen, is there a precedent in any of the other admin settings?
            Hide
            tsala Helen Foster added a comment -

            Hi Tim,

            In Administration > Security > Notifications the notifyloginfailures setting has 3 options - Nobody, Administrator and All administrators (I'm not sure how this is working since the implementation of roles!)

            Alternatively, perhaps we could have a notifycourserequest capability similar to mod/quiz:emailnotifysubmission.

            Show
            tsala Helen Foster added a comment - Hi Tim, In Administration > Security > Notifications the notifyloginfailures setting has 3 options - Nobody, Administrator and All administrators (I'm not sure how this is working since the implementation of roles!) Alternatively, perhaps we could have a notifycourserequest capability similar to mod/quiz:emailnotifysubmission.
            Hide
            timhunt Tim Hunt added a comment -

            The attached patch (HEAD only) changes to admin setting to be a multi-select box with a list of all the users who have the 'moodle/site:approvecourse' capability, and lets you select any number of those users.

            What do people think?

            And should we do something similar for notify login failures?

            Show
            timhunt Tim Hunt added a comment - The attached patch (HEAD only) changes to admin setting to be a multi-select box with a list of all the users who have the 'moodle/site:approvecourse' capability, and lets you select any number of those users. What do people think? And should we do something similar for notify login failures?
            Hide
            timhunt Tim Hunt added a comment -

            We need to add a 'Nobody' option to the select box, for the benefit of the 99% of the world who do not know to use CTRL+click.

            Show
            timhunt Tim Hunt added a comment - We need to add a 'Nobody' option to the select box, for the benefit of the 99% of the world who do not know to use CTRL+click.
            Hide
            tsala Helen Foster added a comment -

            I think the multi-select box for course notification is great! It's really clever that only relevant users are listed.

            A Nobody option would be helpful for people like me who don't know about CTRL+click. Alternatively, the following text could be added to the lang string:

            Multiple users may be selected/deselected by holding down the Apple or Ctrl key whilst clicking on the users' names.

            +1 for a multi-select box for notifyloginfailures. I can't find any other admin settings which would benefit from the same treatment.

            Show
            tsala Helen Foster added a comment - I think the multi-select box for course notification is great! It's really clever that only relevant users are listed. A Nobody option would be helpful for people like me who don't know about CTRL+click. Alternatively, the following text could be added to the lang string: Multiple users may be selected/deselected by holding down the Apple or Ctrl key whilst clicking on the users' names. +1 for a multi-select box for notifyloginfailures. I can't find any other admin settings which would benefit from the same treatment.
            Hide
            timhunt Tim Hunt added a comment -

            Right. fixed now. Please test.

            Note, I only changed the notifyloginfailures setting in HEAD.

            Show
            timhunt Tim Hunt added a comment - Right. fixed now. Please test. Note, I only changed the notifyloginfailures setting in HEAD.
            Hide
            howardsmiller Howard Miller added a comment -

            I think there's a problem here... please see:

            http://tracker.moodle.org/browse/MDL-17877

            Show
            howardsmiller Howard Miller added a comment - I think there's a problem here... please see: http://tracker.moodle.org/browse/MDL-17877
            Hide
            timhunt Tim Hunt added a comment -

            Actually, MDL-17877 is not caused by this. Re-resolving.

            And I don't see the point of reopening this bug after you have filed a separate bug. (By all means link the bugs.)

            Show
            timhunt Tim Hunt added a comment - Actually, MDL-17877 is not caused by this. Re-resolving. And I don't see the point of reopening this bug after you have filed a separate bug. (By all means link the bugs.)
            Hide
            tsala Helen Foster added a comment -

            Tim, thanks a lot for further improving course request notifications. Everything seems to be working fine

            Show
            tsala Helen Foster added a comment - Tim, thanks a lot for further improving course request notifications. Everything seems to be working fine
            Hide
            tsala Helen Foster added a comment -

            notifyloginfailures improvement noted in the documentation:

            http://docs.moodle.org/en/Notifications

            Show
            tsala Helen Foster added a comment - notifyloginfailures improvement noted in the documentation: http://docs.moodle.org/en/Notifications
            Hide
            skodak Petr Skoda added a comment -

            the username is not unique user identifier, we have to use userid or username+mnethostid
            going to switch to list of user ids in 2.0

            Show
            skodak Petr Skoda added a comment - the username is not unique user identifier, we have to use userid or username+mnethostid going to switch to list of user ids in 2.0

              People

              • Votes:
                15 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  28/Jan/09