Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DreadfulCthulhu's avatar

Master action to call action on slaves

Hi, do you have any "easy" solution to the following model situation?:

Model Situation: Classroom of ~30 students and one teacher. Each of them have opened site with test (made in laravel). Test consists of about 50 pages. There are some wait-in-progress (wip) pages to synchronize progress of all students - to disallow quicker students to see some spoiler pages before other students. Each wip page have continue button, which is disabled. Teacher have an administrative tool (special page of the same site), where are shown wip pages with common switches "On/Off". When students are on e.g. page 12 (teacher can see them all), which is wip, teacher switches that page to ON and on all computers is in that moment enabled button "Continue".

Actual solution: Each instance of test is in given interval checking some file existence. When teacher switches to ON, file is created and all buttons are enabled.

Is there some more Laravelish way to do that? Site is hosted on common hosting, so many background features like workers etc. are not available.

0 likes
3 replies
Sinnbeck's avatar

I would recommend reading up on broadcasting.

https://laravel.com/docs/6.x/broadcasting#introduction

When some data is updated on the server, a message is typically sent over a WebSocket connection to be handled by the client. This provides a more robust, efficient alternative to continually polling your application for changes.

DreadfulCthulhu's avatar

Hi, yes, when you wrote it, it looks as the best solution for me, but with some time taken to think about it, I'm finding it not to be the right solution for me. E.g. for this case

All students all rolled to test, all of them are on e.g. 3rd wait-in-progress page. When teacher broadcasts an action to let them go to the next page, everything works fine. But, there can happen, that someone losts its connection or get some client's PC issue and he/she must start from beggining. Then it must be possible to him/her to catch up all other students (go through w-i-p pages without teacher's action).

So I'm not sure here about broadcasting. Maybe some "global caching" where will be for each classroom stored array of wip pages which are currently allowed e.g.(page=>isAllowed): {1=>true, 7=> true, 12=>true, 19=>false,...} (maybe only one integer with last allowed page number), but then there is still problem how to make all clients have always actual cache. It means to have some ajax interval, which each second check controller for cache content? Is it ok? Is it possible to use Laravel's cache as global cache for all clients? Or is there another solution to use (best to be standalone, not like broadcasting, where is required external service)?

DreadfulCthulhu's avatar
Level 4

So I solved it for now by storing Cache values of the last allowed page in admin and reading them by Ajax->Controller->getCacheValue each second on each client on wait-in-progress pages.

Please or to participate in this conversation.