Skip to content

Commit

Permalink
added completeHomework()
Browse files Browse the repository at this point in the history
  • Loading branch information
chopster44 committed Mar 25, 2023
1 parent 8183ace commit ffc4f8b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/API/edulink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import {
RawTimetableResult,
Week
} from "../types/result.js";
import {AuthParams, HomeworkDescriptionParams, Params, RawHomeworkParams, RawTimetableParams} from "../types/params.js";
import {
AuthParams,
HomeworkCompleteParams,
HomeworkDescriptionParams,
Params,
RawHomeworkParams,
RawTimetableParams
} from "../types/params.js";

/**
* Class for interaction with the Edulink API
Expand Down Expand Up @@ -185,4 +192,21 @@ export class Edulink {
//@ts-ignore
return await this.request(reqParams);
}

/**
* tell edulink to change a given homework's state of completion
* @param {HomeworkCompleteParams} params
*/
public async completeHomework(params: HomeworkCompleteParams) {
let reqParams: Params = {
action: "HomeworkCompleted",
data: {
completed: params.completed,
homework_id: params.id,
learner_id: this.learner_id,
source: "Edulink"
}
}
await this.request(reqParams);
}
}
5 changes: 5 additions & 0 deletions src/types/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ export interface RawHomeworkParams extends Params {
export interface HomeworkDescriptionParams {
id: string,
source: string
}

export interface HomeworkCompleteParams {
id: string,
completed: boolean,
}

0 comments on commit ffc4f8b

Please sign in to comment.