Skip to content

Commit

Permalink
fix #224; don't let withrdrawn students be members of teams
Browse files Browse the repository at this point in the history
  • Loading branch information
rtholmes committed Feb 4, 2019
1 parent 455a11d commit 2e1d893
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
18 changes: 8 additions & 10 deletions packages/portal/backend/src/controllers/TeamController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Log from "../../../../common/Log";

import {TeamTransport} from "../../../../common/types/PortalTypes";
import Util from "../../../../common/Util";
import {Deliverable, Person, Team} from "../Types";
import {Deliverable, Person, PersonKind, Team} from "../Types";

import {DatabaseController} from "./DatabaseController";
import {GitHubActions, IGitHubActions} from "./GitHubActions";
Expand Down Expand Up @@ -160,15 +160,13 @@ export class TeamController {
throw new Error("Team not created; students cannot form their own teams for this deliverable.");
}
}
// const people: Person[] = [];
// for (const ghId of gitHubIds) {
// const person = await pc.getGitHubPerson(ghId);
// if (person === null) {
// throw new Error("Team not created; GitHub id not associated with student registered in course: " + ghId);
// } else {
// people.push(person);
// }
// }

// make sure all students are still registered in the class
for (const p of people) {
if (p.kind === PersonKind.WITHDRAWN) {
throw new Error("Team not created; at least one student is not an active member of the class.");
}
}

// ensure members are all in the same lab section (if required)
if (deliv.teamSameLab === true) {
Expand Down
22 changes: 21 additions & 1 deletion packages/portal/backend/test/controllers/TeamControllerSpec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {expect} from "chai";
import "mocha";

import Log from "../../../../common/Log";

import {DatabaseController} from "../../src/controllers/DatabaseController";
import {PersonController} from "../../src/controllers/PersonController";
import {TeamController} from "../../src/controllers/TeamController";
import '../GlobalSpec';
import {PersonKind} from "../../src/Types";

import '../GlobalSpec';
import {Test} from "../TestHarness";
import './PersonControllerSpec';

Expand Down Expand Up @@ -245,6 +247,24 @@ describe("TeamController", () => {
expect(ex).to.not.be.null;
expect(team).to.be.null;

// student already withrdawn
team = null;
ex = null;
try {
// withdraw a student
const dbc = DatabaseController.getInstance();
const p6 = await pc.getGitHubPerson(Test.USER6.github);
p6.kind = PersonKind.WITHDRAWN;
await dbc.writePerson(p6);

team = await tc.formTeam('testTeamName_' + Date.now(), proj, [p2, p6], false);
} catch (err) {
Log.test(err);
ex = err;
}
expect(ex).to.not.be.null;
expect(team).to.be.null;

teams = await tc.getAllTeams();
expect(teams).to.have.lengthOf(3);
}).timeout(Test.TIMEOUT);
Expand Down

0 comments on commit 2e1d893

Please sign in to comment.