Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>These are the table laid out, modified for your scenerio</p> <pre><code>+----User_Details------+ //You may or may not need this | UID | Particulars... | +----------------------+ +----User_Timeslots---------+ //Time slots per collumn | UID | SlotNumber(bool)... | //true/false if the user is avaliable +---------------------------+ //SlotNumber is replaced by s1, s2, etc +----User_Arrangements--------+ //Time slots per collumn | UID | SlotNumber(string)... | //Group session string +-----------------------------+ </code></pre> <p>Note: That the string in the Arrangement table, was in the following format : JSON</p> <blockquote> <p>'[12,15,32]' //From SMALLEST to BIGGEST!</p> </blockquote> <p>So what happens in the arrangement table, was that a script [Or an EXCEL column formula] would go through each slot per session, and randomly create a possible session. Checking all previous sessions for conflicts.</p> <pre><code>/** * Randomise a session, in which data is not yet set **/ function randomizeSession( sesionID ) { for( var id = [lowest UID], id &lt; [highest UID], id++ ) { if( id exists ) { randomizeSingleSession( id, sessionID ); } //else skips } } /** * Randomizes a single user in a session, without conflicts in previous sessions **/ function randomizeSingleSession( id, sessionID ) { convert sessionID to its collumns name =) get the collumns name of all ther previous session if( there is data, false, or JSON ) { Does nothing (Already has data) } if( ID is avaliable in time slot table (for this session) ) { Get all IDs who are avaliable, and contains no data this session Get all the UID previous session while( first time || not yet resolved ) { Randomly chose 2 if( there was conflict in UID previous session ) { try again (while) : not yet resolved } else { resolved } } Registers all 3 users as a group in the session } else { Set session result to false (no attendance) } } </code></pre> <p>You will realize the main part of the assignment of groups is via randomization. However, as the amount of sessions increases. There will be more and more data to check against for conflicts. Resulting to a much slower performance. However large being, ridiculously large, to an almost perfect permutation/combination formulation. </p> <p><strong>EDIT:</strong> </p> <p>This setup will also help ensure, that as long as the user is available, they will be in a group. Though you may have pockets of users, having no user group (a small number). These are usually remedied by recalculating (for small session numbers). Or just manually group them together, even if it is a repeat. (having a few here and there does not hurt). Or alternatively in your case, along with the remainders, join several groups of 3's to form groups of 4. =)</p> <p>And if this can work for EXCEL with about 100+ ppl, and about 10 sessions. I do not see how this would not work in SQL + PHP. Just that the calculations may actually take some considerable time both ways.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload