When I first arrived at the school where I am now, I was rather astonished at how much human effort went into the publication of the daily notices. “Boxing club is canceled.” “There will be cookies for sale at break time.” I think any school could potentially have this issue. Imagine you’re a Principal and you don’t know much about using content management systems or other similar software to get that sort of stuff done. So you think one of the ways to get daily notices done for the staff under your charge is to ask them to email you the notices, which you’ll collate for everyone else and send out every morning.
It’s funny to me, someone who builds and maintains software that can easily solve this problem, how often people use email in this way. “I’ll just have everyone email me their response and I’ll get it formatted for them in reply.” Yikes.
Anyway, so I was given the opportunity to completely revamp how they did this, and I’m documenting here the solution that I came up with, and I’ll try to do so in a way that any other school could potentially lift from, although I cannot help but talk about the assumptions this particular community makes.
If it doesn’t have one already, your community really should have a WordPress Multisite installation available to itself. If you don’t, that’s a great way to get notices for your school or organization working for this example, and in addition to that, you’ll have a goodly sum of other good uses for it down the line as well. It’s not too difficult for a competent sysadmin to get installed and running smoothly.
Anyway, so using WordPress Multisite, with the default settings, you could have users enter new posts onto a blog that take care of the data entry aspect. They just login to the WordPress installation and click Add New Post. Now the problem is collating them and getting them out to staff’s inboxes.
With the Subscribe2 plug-in, WordPress gets the additional feature of emailing out the content of posts when they are published. Hence, your staff get an email with — and you have the liberty of choosing which works best for your community — either a link to the post in question or the content itself (properly formatted with HTML). As an administrator I prefer HTML to be viewed in the context in which it’s meant: the browser. Others point out that they wish the content was in the email themselves so that everything is in their inbox and they don’t have to switch to the browser.
The Subscribe2 plugin lets you choose if you want the emails to be sent whenever the post is published, so that users get emails one-by-one as they come out, or whether they get a daily digest version (i.e. “once daily”):
For a school we almost certainly want some sort of digest thing going, probably at a certain time of the day — early morning — as well. So that way, people do the data entry bit whenever, and it goes out the next morning to everyone in a digest format. If staff want to enter something on Monday that goes out to everyone on Thursday, they can schedule the post to be published then. This is great and does most of what we need it to do.
Except a few things, like repeating events.
At my school, this was a requested feature. Teachers felt that they wanted to advertise an activity that was about to happen for a few days. This makes sense, since notices are scanned far more than they are read. Reminders are always welcome, right? WordPress doesn’t have any built-in way of handling repeat events, short of requiring uses to enter the same info again and again.
There was an additional wrinkle: That WordPress blog is not constantly used by staff, it isn’t going to be the first place they go to as a general routine. If they want to enter something into the notices, they are instead expecting it to be a part of our Moodle installation which teachers already use constantly for their teaching. There was also talk about forcing word limits on each notice.
So I decided to figure out if I could have the data entry part of the work-flow done in Moodle. For that, the best bet was the database module, which provides a built-in way to create a form for users to fill out. It is really rudimentary form-making tool, but it does the basic job: It creates a database in the back-end with the benefit of a straight-forward user interface on the front-end:
Now all we need to do is extract the information stored in the database, and then send it on to WordPress for publication. So wrote a Python script that did a bunch of cool stuff. When run, it knows what day it is and scans the database entries and catches any entries that are to be published at the target date (between “Start date” and “End date” inclusive). It gets the information by simply connecting to the database directly, which any script can do with a database driver and programming context. In my case I use py-postgresql.
After getting the target entries, it starts analyzing in order to spit out a formatted result. Notices that are appearing for the first time get placed higher up, while notices that have been there longest will end up at the bottom. I also put in a some code that would prioritize certain users, like the Dean of Students, whose entries would always appear first. The code that does all this stuff can be found here. This is a sample of the raw output:
<b>All Secondary:</b> <ul> <li><strong>Photography Competition: </strong>the photos will be on exhibit for the whole of next week, along the second floor corridor which overlooks the secondary gymnasium. Come over to enjoy the photographs and vote for your favorite series and single shot. The photos can also be browsed online at <a href="http://photographycompe
Now the problem is how to get that data into WordPress. Enter the wp-cli command line tool. Using the following command:
wp post create --path=/var/www/wordpress --post_type=post \ --post_title='{title}' content='{content}' \ --post_author={author} \ --post_status=future --post_date='{date}' \ --url={blog}
We get the output that we read in from Moodle into WordPress. The –post_status=future makes it a scheduled post, and since we have Subscribe2 it will automatically send out an email, at the time indicated by –post_date.
If you don’t want or can’t use a Moodle, you could also use the wp-cli command line tool to get the content of posts from WordPress, and reformat it in whatever way you need, using the wp export command. It allows you to specify start and end date. To get repeating events, probably you could the post custom fields feature in WordPress, which you can access with wp post-meta get command.
After a few months of use now, we’re now at the refection and evaluation stage. Now that it’s so easy to enter notices, and to have them repeat as desired, there are a number of notices that go out every day that are simply too much to keep up with. Basically, since it’s so easy, we have more of them, and the issues that come with it being a bit too overwhelming. We also have teachers doing things like colorizing their text to annoying colors and adding emoticons, which has garnered comment as well.