hkajava / s2g

Students2Groups Meteor application. Noticed in Spanish conversation class that the teacher doesn't have a good method to divide students into small groups for conversation so this application will provide easy way to do that. Also testing Meteor/React technologies with this application.
MIT License
1 stars 0 forks source link

Integrate new randomization algorithm #1

Closed hkajava closed 6 years ago

hkajava commented 6 years ago

Integrate new randomization algorithm. It has already been coded:

const numberOfGroups = 5; const nbrPresentStudents = 9; const minGroupSize = 3;

export function findNumberOfSmallGroups(nbrPresentStudents, minGroupSize) { // TODO: if nbrPresentStudents <= 3, then return nbrOfGroups == 1 let nbrOfGroups = 0; if (nbrPresentStudents % minGroupSize === 0) { nbrOfGroups = (nbrPresentStudents / minGroupSize); return nbrOfGroups; } nbrOfGroups = Math.round(nbrPresentStudents / (minGroupSize + 1)); return nbrOfGroups; }

... and ... export function generateRandomGroups(numberOfGroups, randomizedStudentArray) { const studentArrayOfArrays = []; for (let i = 0, j = 0; i < randomizedStudentArray.length; i += 1) { // take one student and put into small group if (studentArrayOfArrays[j] === undefined) { studentArrayOfArrays[j] = []; } studentArrayOfArrays[j].push(randomizedStudentArray[i]); if (j === numberOfGroups - 1) { j = 0; } else { j += 1; } } return studentArrayOfArrays; } ..... and also is needed function that randomizes the studentArray that was fetched from mongo.

Remember to add jest unit tests. :-)