Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 6x 9x 2x 7x 4x 3x 9x 9x 3x 2x 6x | import {
Booklet, isTestlet, isUnit, Testlet, Unit
} from '../group-monitor.interfaces';
export class BookletUtil {
static getFirstUnit(testletOrUnit: Testlet | Unit): Unit | null {
while (!isUnit(testletOrUnit)) {
if (!testletOrUnit.children.length) {
return null;
}
// eslint-disable-next-line no-param-reassign,prefer-destructuring
testletOrUnit = testletOrUnit.children[0];
}
return testletOrUnit;
}
static getFirstUnitOfBlock(blockId: string, booklet: Booklet): Unit | null {
for (let i = 0; i < booklet.units.children.length; i++) {
const child = booklet.units.children[i];
if (!isUnit(child) && (child.blockId === blockId)) {
return BookletUtil.getFirstUnit(child);
}
}
return null;
}
static getBlockById(blockId: string, booklet: Booklet): Testlet {
return <Testlet>booklet.units.children
.filter(isTestlet)
.reduce((found: Testlet | null, block: Testlet) => ((block.blockId === blockId) ? block : found), null);
}
}
|