Scheduling events for workdays

Hello! I am a professor and have made a shortcut breaks up my grading over the days that I have before I need to return something to students. So if I get a batch of 23 exams and I want them graded in the next week I can run a shortcut that will create a to-do in Things 3 over the next week that says to grade exams 1-3.

The problem is that right now it creates events for all of the days between now and my target date — including Saturdays and Sundays. I’m wondering if there is a way to do this and have it not count those days.

This is the shortcut I’m currently using: https://www.icloud.com/shortcuts/3fd9fa9ef07f44a49fb91bcad06ce4de

I figured out part of it. I can check whether the day is a Saturday or Sunday, but I’m not sure how to increment the index to skip over those days.

Here’s what I’ve got: https://www.icloud.com/shortcuts/2f46ebcc94f9426e81f98077283f4f6c

Hopefully someone else can help with the rest of it. And I’ll keep thinking.

You actually need to do it the other way around, go through the days between your start date and end date, count those which aren’t Saturday or Sunday, and then divide the number of exams by that count. Of I get a chance I’ll do it myself but that might not be for some time :slight_smile:

1 Like

Yeah, the problem is how to get an index to skip Saturdays and Sundays when it creates the tasks for Things. I’m wondering if I have to re-think how I’m doing the whole thing.

Working dates is something that I’ve seen come up a couple of times so I took a whirl at creating a drop in solution. I’m sure it’ll come up again, and having this available should make it a little easier/quicker to produce workable solutions.

Working Days

I’ve created a “Working Days” shortcut that is intended as a ‘helper’ shortcut, as in one you don’t run directly but run from other shortcuts. The principle should be pretty straight forward to get. Given a range of dates, the shortcut examines each in turn, figures out if it is a ‘working’ day, and if it is adds it to an accumulating list of dates it returns at the end.

Here’s how it works in a bit more detail.

The shortcut is designed to take an input in two parts - a start date, and an end date. These are taken as inclusive dates. i.e. if you specify 1 March and 3 March, that would be three days it would be checking against.

The shortcut also contains a dictionary of the days of the week. Each entry has a Boolean value. When set as true it is considered a working day and when set as false it is not. People can therefore customise the names of the days and the working days to suit their own needs.

The shortcut iterates over the range of dates, checks if it is a working day, and if it is, adds it to a result variable. This result variable in effect becomes an ordered list of dates in the specified date range which are ‘working dates’. This list is returned by the shortcut at the end to the calling shortcut.

Here’s the shortcut and a testing shortcut to accompany it. The latter calls the former and outputs the results for viewing.


Screenshots of a test run

Grading Shortcut

I’ve modified the existing Grading shortcut to use the Working Days shortcut - consider the Working Days shortcut a prerequisite. The original version is based on iterating over a number of dates and I’ve kept that as is, though given there’s actually a list of dates being passed back to the shortcut, performance could be improved very slightly by iterating over the list directly without counts, etc.; but it seemed so insignificant in reality, and such a fundamental shift in approach I left well alone on this occasion.

The loop now references the date list by index rather than calculating dates (and then having to skip), but otherwise it works the same.

I also added an alert in at the end as, whilst I have Drafts, I’m not a Things users and so the final couple of actions makes no difference for me (and in fact the open in doesn’t list the app for me).

Here’s the amended shortcut - do remember you’ll need the Working Days shortcut from above for it to work.

I’ve included some screenshots of a couple of example runs:

Example Grading Run # 1


Example Grading Run # 2


Hopefully the above matches what to what is required and gives some flexibility for other solutions for other people in the future.

4 Likes

This is exactly what I was looking for. Thank you!!! You are a miracle worker.

1 Like