Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instances #7

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

Instances #7

wants to merge 36 commits into from

Conversation

fschuett
Copy link

Hi, I coded multiplce instances version or MRBS.
I do need to do some more testing, especially testing of the import.php functions.
I added code to upgrade.php to create an instance for the existing data in the database, so
that it is not lost.
Each instance is identified by html parameter instance=xxx, which is appended to each link.
I would be happy if you reviewed my changes.

@fschuett
Copy link
Author

I added a moodle tracker issue for tracking https://tracker.moodle.org/browse/CONTRIB-7121.

@davosmith
Copy link
Collaborator

It's going to take me a long time to review those changes, but before I do so a few of points:

  1. 17 commits is a lot for me to go through, can you please squash these into a single commit (or, if that doesn't make sense, a few commits which each do something self-contained)
  2. Please make sure that there are no whitespace changes to lines that are otherwise unchanged (I thought I spotted one, I haven't reviewed much further).
  3. Please check that existing functionality is unchanged - e.g. if a site has multiple block instances and expects them all to point at the same MRBS, then that will continue to work the same after the changes, if a site has hard-coded links to a particular week / day / etc. in their booking system, this link will continue to function without changes.
  4. I know that MRBS does not have anything in the way of PHPUnit or Behat tests (due to its age), but I think that when making extensive changes such as this it would be a really good idea to add some. This may not be easy to do, but I would ask that you have a look at doing so.

@fschuett
Copy link
Author

fschuett commented Nov 23, 2017 via email

@fschuett
Copy link
Author

Hi Davo,
I squashed all commits into one single commit that contains all changes:
7fe7622

There are no whitespace changes with one exception to my knowledge. In import.php I did need
to iterate over all instances, so I needed to wrap nearly the whole code in a new "foreach(){ }",
so I had to adjust the tabs.

There is a "default_instance", which is the one instance existing at the time of import. Each link without an instance number will point to this instance.

I didn't add any test code. I've never done so far and that will need some time for me to learn.
But I might add some in the future.

@davosmith
Copy link
Collaborator

Sorry for the slow reply - I've been pretty busy over the last month and not had any free evenings to sit down and look at Moodle code (after a day of looking at it at work).

As you can see - I've made a number of comments inline in the code.

My biggest concerns at the moment are:
a) you are messing around with existing site configuration during install/upgrade (changing core roles / adding a block to the front page)
b) existing sites with multiple instances of the block, that currently all point at the same booking system are going to suddenly find that most of the blocks don't point at the booking system they were expecting
c) What happens if a block is deleted (by accident or on purpose) - in the current system you'd just create a new instance of the block and it would be working again, with your changes, the data would still be sitting in the database (as far as I can tell), but there would no longer be a way to access it. This is very likely to happen when someone who previously had the MRBS block on a course page suddenly finds it appearing on the front page of their site, so immediately removes it again, thereby losing their only link to their existing room bookings ...
d) Backup & restore - as each MRBS set up is directly linked to a single block, I'd expect that backing up and restoring a course with that block would copy all the booking data (or at least have some clear warnings about what is going on).

Can I suggest a (hopefully) better alternative solution (which I don't think would be a huge amount of extra work)? Maybe it would be better to add an extra layer of configuration between MRBS and the block instances. So, instead of creating a new MRBS instance for each block instance, have an admin page that allows you to create and configure separate MRBS instances, with the block configuration only being about selecting which MRBS instance that block instance links to.
That way, all existing blocks could continue to point to the existing MRBS instance, deleting a block would just delete the link to the MRBS instance - adding a new block and selecting the same MRBS instance would allow you to continue as you were. You also would have no need of forcing a block to appear on the front page to act as the 'default' instance.
Capability checks would become a bit more complicated - you'd need to find all the block instances that linked to a given MRBS instance and check capabilities in each of those (you'd almost certainly want to store the links in the Moodle cache, so you don't have to re-parse every block config during every page load). There is also the problem that, in theory, a teacher could gain editing access to any MRBS instance they liked, simply by adding the block and pointing it at that MRBS instance.

What do you think?

Please note that unless solutions are found to a), b) and c) [d) is less important] I'm not going to be able to merge these changes as they will cause unexpected behaviour on existing sites.

@fschuett
Copy link
Author

fschuett commented Dec 24, 2017 via email

@davosmith
Copy link
Collaborator

Not a problem - it looks like a good new feature, it just needs to land without breaking anything on existing sites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants