diff --git a/src/automate.c b/src/automate.c index 530b9ee39..24c34e903 100644 --- a/src/automate.c +++ b/src/automate.c @@ -81,13 +81,13 @@ void autostudy_run(scholar scholars[], int nscholars) int mint; ts += scholars[se].u->number; /* count total scholars */ mint = (ts + 10) / 11; /* need a minimum of ceil(ts/11) teachers */ - for (; mint > tt && si != nscholars; ++si) { + for (; mint > tt && si != nscholars && scholars[si].sk == sk; ++si) { tt += scholars[si].u->number; } } /* now si splits the teachers and students 1:10 */ /* first student must be 2 levels below first teacher: */ - for (; si != se && scholars[ti].level - TEACHDIFFERENCE > scholars[si].level; ++si) { + for (; si != se && scholars[ti].level - TEACHDIFFERENCE > scholars[si].level && scholars[si].sk == sk; ++si) { tt += scholars[si].u->number; } if (si == se) { @@ -134,7 +134,7 @@ void autostudy_run(scholar scholars[], int nscholars) learning(scholars + s, (n - i)); i = 0; if (++s == se) { - continue; + break; } n = scholars[s].u->number; } while (scholars[t].level - TEACHDIFFERENCE < scholars[s].level);