Skip to content

Commit

Permalink
Merge pull request #615 from tutors-sdk/feature/enrollment-support
Browse files Browse the repository at this point in the history
Feature/enrollment support
  • Loading branch information
edeleastar authored Dec 6, 2023
2 parents af02f6a + 728f490 commit 7844596
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
4 changes: 3 additions & 1 deletion app/src/lib/services/models/course-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export function loadPropertyFlags(course: Course) {
course.areVideosHidden = (course.properties?.hideVideos as unknown as boolean) === true;
course.areLabStepsAutoNumbered = (course.properties?.labStepsAutoNumber as unknown as boolean) === true;
course.authLevel = course.properties.auth as unknown as number;
course.hasEnrollment = false;
if (course.enrollment) {
course.hasEnrollment = true;
}
course.hasWhiteList = false;
course.ignorePin = course.properties?.ignorepin?.toString();
if (course.properties?.icon) {
Expand Down
1 change: 1 addition & 0 deletions app/src/lib/services/models/lo-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export type Course = Composite & {
wallMap?: Map<string, Lo[]>;
properties: Properties; // contents of properties.yaml
calendar?: Properties; // contents of calendar.yaml
enrollment?: string[]; // contents of enrollment.yaml
courseCalendar?: Calendar;
authLevel: number;
isPortfolio: boolean;
Expand Down
17 changes: 6 additions & 11 deletions app/src/routes/(time)/time/[courseid]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@ export const load: PageLoad = async ({ parent, params, fetch }) => {
const users: Map<string, UserMetric> = await fetchAllUsers(params.courseid, allLabs);
const enrolledUsers: Map<string, UserMetric> = new Map<string, UserMetric>();
if (course.hasEnrollment) {
// const students = course.getEnrolledStudentIds();
// if (isStringArray(students)) {
// for (const githubId of users.keys()) {
// if (students.includes(githubId)) {
// const enrolledUser = users.get(githubId);
// if (enrolledUser) {
// enrolledUsers.set(githubId, enrolledUser);
// }
// }
// }
// }
course.enrollment?.forEach((studentId) => {
const enrolledUser = users.get(studentId);
if (enrolledUser) {
enrolledUsers.set(studentId, enrolledUser);
}
});
}
return {
user: user,
Expand Down
2 changes: 1 addition & 1 deletion cli/tutors-gen-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tutors-gen-lib",
"version": "3.2.10",
"version": "3.2.11",
"description": "Library for tutors generators",
"scripts": {
"build": "tsc --build",
Expand Down
5 changes: 5 additions & 0 deletions cli/tutors-gen-lib/src/generator/course-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,10 @@ export function buildCourse(lr: LearningResource): Course {
course.calendar = readYamlFile(calendarFile);
}

const enrollmentFile = getFileWithName(lr, "enrollment.yaml");
if (enrollmentFile) {
course.enrollment = readYamlFile(enrollmentFile);
}

return course;
}
1 change: 1 addition & 0 deletions cli/tutors-gen-lib/src/models/lo-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export type Course = Composite & {
wallMap?: Map<string, Lo[]>;
properties: Properties; // contents of properties.yaml
calendar?: Properties; // contents of calendar.yaml
enrollment?: string[]; // contents of enrollment.yaml
courseCalendar?: Calendar;
authLevel: number;
isPortfolio: boolean;
Expand Down
2 changes: 1 addition & 1 deletion cli/tutors-gen-lib/src/tutors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resourceBuilder } from "./generator/resource-builder";
import { writeFile } from "./generator/file-utils";
import { generateNetlifyToml } from "./generator/netlify";

export const version = "3.2.10";
export const version = "3.2.11";

export function parseCourse(folder: string): Course {
resourceBuilder.buildTree(folder);
Expand Down
4 changes: 2 additions & 2 deletions cli/tutors-publish-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tutors-publish-html",
"version": "3.2.10",
"version": "3.2.11",
"description": "Static course web site generator - html emitter",
"main": "./src/tutors-publish-html.js",
"scripts": {
Expand All @@ -24,7 +24,7 @@
"nunjucks": "^3.2.3",
"path": "^0.12.7",
"shelljs": "^0.8.5",
"tutors-gen-lib": "^3.2.10"
"tutors-gen-lib": "^3.2.11"
},
"devDependencies": {
"prettier": "2.8.4",
Expand Down
4 changes: 2 additions & 2 deletions cli/tutors-publish/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tutors-publish",
"version": "3.2.10",
"version": "3.2.11",
"description": "Static course web site generator - json emitter",
"main": "./src/tutors-publish.js",
"scripts": {
Expand All @@ -17,7 +17,7 @@
"tutors-publish": "./src/tutors-publish.js"
},
"dependencies": {
"tutors-gen-lib": "^3.2.10"
"tutors-gen-lib": "^3.2.11"
},
"devDependencies": {
"prettier": "2.8.8",
Expand Down

0 comments on commit 7844596

Please sign in to comment.