Version 25 (activities in timetables)

Hello!
I know that v25 will have activities finally appearing in the timetables. But I can’t wait for the v25 release. I need that feature now. So my question is… Does the bleeding edge code on GitHub have that feature? Is it possible to just patch my v24 installation with the new code for this feature (and only this feature)? Thank you ?

Hi pacom, great to hear you’re excited about this feature. Yes, luckily the changes are contained in only two files in the system and should be backwards compatible. You can find the changes here: https://github.com/GibbonEdu/core/commit/2c9c07eb183ce6d1b399c249f3cb9ab5e466489d

If you click the … and View File > Raw, you can copy the files and replace the existing files in your system (rename the existing ones first to keep a backup). There are two files to update, modules/Timetable/moduleFunctions.php and src/Domain/Activities/ActivityGateway.php

Hope this helps!

Hi Sandra,

Thanks, but I keep getting this error in my apache log with the new files:

[php:error] [pid 243259] PHP Fatal error: Uncaught Error: PDO object is uninitialized in /var/www/html/modules/Timetable/moduleFunctions.php:615\ Stack trace:\ #0 /var/www/html/modules/Timetable/moduleFunctions.php(615): PDOStatement->fetchAll()\ #1 /var/www/html/index_tt_ajax.php(52): renderTT()\ #2 {main}\ thrown in /var/www/html/modules/Timetable/moduleFunctions.php on line 615

[php:warn] [pid 243257] PHP Warning: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘gibbonSchoolYearTerm.firstDay’ in ‘field list’ in /var/www/html/src/Database/Connection.php on line 195

On the frontend, the timetable doesn’t load because of this fatal error. Any thoughts? I looked at line 615 in modeFunctions.php, and I am trying to figure out what is wrong with it. Thanks again.

Sandra,

BTW, I am using PHP version 8.1.2. I am thinking of downgrading to see if it’s an issue with PHP8.

Okay, I downgraded to 7.4.32, and that fatal error went away. However, I have a new problem. The registered activities are not showing up on the timetable. Also, I am getting a warning in my error log:

PHP Warning: Invalid argument supplied for foreach() in /var/www/html/modules/Timetable/moduleFunctions.php on line 626

Hi pacom, yes, the current version of Gibbon supports up to PHP 8.0, we are adding 8.1+ support for our next version.

I’ve taken a look and it appears that this error is related to the selectActiveEnrolledActivities() method on line 615 returning null rather than an empty array. Are you able to double-check that you’ve updated both the moduleFunctions.php file as well as the ActivitiesGateway.php file? Otherwise, this is a PHP warning rather than an error, so it shouldn’t be causing any issues in the front-end, it’s just warning that the query has returned a null value.

As a note, can you let me know if you are using activities by term or by date range (from School Admin > Activity Settings)? If you continue to not see the activities on the timetable let me know and I can dig into it further. Thanks!

Hi Sandra,

Yes, I updated both files, and with 8.1.2, I get a fatal error (PDO object is uninitialized) as shown above.

I am using activities by date range. And with version 7.4, they are not showing up in the timetable. Thanks ?

Hi pacom, thanks for the heads up, since this is some brand new code it turns out there was indeed a bug in there related to using activities by Date type. I’ve fixed it for v25, however there are a few changes in there that are not backwards compatible, so I’ve created and tested a set of the two files that will work for v24. Thanks!

Hi Sandra, those new files did not work for me. The accepted activities do not show up in the timetables.
Here are some details about the activities:

  • The start dates and end dates are the same (so the activity happens on one day in the future).
  • Activities have a provider and a type
  • Defining a time slot doesn't fix the issue
  • The activity is accepted
  • For both the organizer and the student, the accepted activity doesn't appear on the corresponding timetable
Again, I am using PHP version 7.4.32 on Ubuntu with Gibbon v24. Thank you for your help.

Hi Sandra,
Thank you again for all your help! Okay, so I did some debugging and found some problems in the code from the zip file. On line 633 of moduleFunctions.php, there is a problem with how the elements are declared. If there is only one accepted activity, then it needs to be:

$activities = [

Instead of: $activities[] = [

Otherwise, the activities array will be empty no matter what!
I am using PHP version 7.4, and I don’t know if this behavior is specific to that version. Perhaps it would be better for you to use array_push in the loop?

Moving on, in the renderTTDay function, I am not able to draw activities because on line 1299, the rowCount is not equal to 1. Can you please tell me the purpose of the sql on line 1292? Do you have any insight on how I could get this working? Thank you again.

Hi pacom,

The $activities variable is an array of arrays, so it should be $activities[] = [ ]; , this is the PHP syntax to add new elements to the array. I've tested the files locally with the settings you shared and I was able to see activities on the timetable, even if the start and end date of the activity was the same date. The activity definitely needs a time slot in order to show up, and the time slot needs to be the same weekday that the activity occurs on (eg: Wednesday for a Nov 2, 2022 activity date). To help debug, you could <code class="CodeInline">print_r($activities); on line 649 after the array is created to see if it is populating with information.

On line 1292, there shouldn’t be multiple timetable days assigned to the same date from the same timetable, this could certainly cause an error in the timetable rendering. You can use the Timetable Admin > Tie Days to Dates tool to assign a timetable day to a date on the calendar, and you can do so for multiple separate timetables, but each timetable should only have one timetable day structure associated with a particular calendar date. Can you share a screenshot of your Tie Days to Dates view, and possibly also your list of Timetable Days. This may help

Hi Sandra,

Thank you again for your help! I finally had free time to look at this issue again.

On line 1292, there shouldn't be multiple timetable days assigned to the same date from the same timetable, this could certainly cause an error in the timetable rendering.

On line 1299, the rowCount was equal to 0. So nothing rendered. I didn’t assign a timetable day structure to the date of the activity. It took me a long time to realize that I needed to do that for the activity to appear in the timetable.

At first, I figured that since the activity date was a “school day”, then I didn’t need to do anything else. The timetable showed that school was open on that date, so I expected the activity to appear in the timetable.

Let me explain how I am using Gibbon… I am working with an organization that does workshops (activities) for students. So they want those activities to appear in the timetables. However, they have no need for periods, units, etc. All they care about are the activities. That’s it!

What I eventually did was create a timetable day that had no periods/columns and then assign that day structure to the activity date and it worked! The activity showed up in the timetable.

Thanks pacom, I appreciate you investigating this and sharing your solution. I can see where, using Gibbon in a different context, that having the activities on the timetable without having a timetable could be useful. I’ve added it to our development list, otherwise your workaround sounds good and will hopefully benefit other schools with similar needs.

Cheers,
Sandra