Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import app from "../../d2l_brightspace.app.mjs";

export default {
key: "d2l_brightspace-create-enrollment",
name: "Create Enrollment",
description: "Enrolls a user in a course on D2L Brightspace. [See the documentation](https://docs.valence.desire2learn.com/res/enroll.html)",
version: "0.0.1",
type: "action",
props: {
app,
orgUnitId: {
propDefinition: [
app,
"orgUnitId",
],
},
userId: {
propDefinition: [
app,
"userId",
],
},
roleId: {
propDefinition: [
app,
"roleId",
],
},
},
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
idempotentHint: false,
},
async run({ $ }) {
const response = await this.app.createEnrollment({
data: {
OrgUnitId: this.orgUnitId,
UserId: this.userId,
RoleId: this.roleId,
},
$,
});

$.export("$summary", `Successfully enrolled user ${this.userId} in course ${this.orgUnitId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../d2l_brightspace.app.mjs";

export default {
key: "d2l_brightspace-get-grade-values",
name: "Get Grade Values",
description: "Retrieves the grade value for a specific user and grade object from D2L Brightspace. [See the documentation](https://docs.valence.desire2learn.com/res/grade.html)",
version: "0.0.1",
type: "action",
props: {
app,
orgUnitId: {
propDefinition: [
app,
"orgUnitId",
],
},
gradeObjectId: {
propDefinition: [
app,
"gradeObjectId",
(c) => ({
orgUnitId: c.orgUnitId,
}),
],
},
userId: {
propDefinition: [
app,
"userId",
],
},
},
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
idempotentHint: true,
},
async run({ $ }) {
const response = await this.app.getGradeValue({
orgUnitId: this.orgUnitId,
gradeObjectId: this.gradeObjectId,
userId: this.userId,
$,
});

$.export("$summary", `Successfully retrieved grade value for user ${this.userId}`);
return response;
},
};
33 changes: 33 additions & 0 deletions components/d2l_brightspace/actions/get-user/get-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import app from "../../d2l_brightspace.app.mjs";

export default {
key: "d2l_brightspace-get-user",
name: "Get User",
description: "Retrieves information about a specific user from D2L Brightspace. [See the documentation](https://docs.valence.desire2learn.com/res/user.html)",
version: "0.0.1",
type: "action",
props: {
app,
userId: {
propDefinition: [
app,
"userId",
],
},
},
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
idempotentHint: true,
},
async run({ $ }) {
const response = await this.app.getUser({
userId: this.userId,
$,
});

$.export("$summary", `Successfully retrieved user ${response.FirstName} ${response.LastName}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../d2l_brightspace.app.mjs";

export default {
key: "d2l_brightspace-list-dropbox-folders",
name: "List Dropbox Folders",
description: "Retrieves all dropbox folders (assignments) for a specific course from D2L Brightspace. [See the documentation](https://docs.valence.desire2learn.com/res/dropbox.html)",
version: "0.0.1",
type: "action",
props: {
app,
orgUnitId: {
propDefinition: [
app,
"orgUnitId",
],
},
},
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
idempotentHint: true,
},
async run({ $ }) {
const response = await this.app.listDropboxFolders({
orgUnitId: this.orgUnitId,
$,
});

const folders = Array.isArray(response)
? response
: [];
$.export("$summary", `Successfully retrieved ${folders.length} dropbox folder${folders.length === 1
? ""
: "s"}`);
return folders;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import app from "../../d2l_brightspace.app.mjs";

export default {
key: "d2l_brightspace-list-enrollments",
name: "List Enrollments",
description: "Retrieves a list of enrollments for a specific course from D2L Brightspace. [See the documentation](https://docs.valence.desire2learn.com/res/enroll.html)",
version: "0.0.1",
type: "action",
props: {
app,
orgUnitId: {
propDefinition: [
app,
"orgUnitId",
],
},
roleId: {
propDefinition: [
app,
"roleId",
],
optional: true,
description: "Filter enrollments by role (optional)",
},
max: {
type: "integer",
label: "Maximum Results",
description: "The maximum number of enrollments to return",
optional: true,
default: 100,
},
},
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
idempotentHint: true,
},
async run({ $ }) {
const enrollments = [];

const params = {};
if (this.roleId) {
params.roleId = this.roleId;
}

const iterator = this.app.paginate({
fn: this.app.listEnrollmentsByOrgUnit,
params: {
orgUnitId: this.orgUnitId,
...params,
},
maxResults: this.max,
});

for await (const enrollment of iterator) {
enrollments.push(enrollment);
}

$.export("$summary", `Successfully retrieved ${enrollments.length} enrollment${enrollments.length === 1
? ""
: "s"}`);
return enrollments;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import app from "../../d2l_brightspace.app.mjs";

export default {
key: "d2l_brightspace-list-org-units",
name: "List Organizational Units",
description: "Retrieves a list of organizational units (courses, departments, etc.) from D2L Brightspace. [See the documentation](https://docs.valence.desire2learn.com/res/orgunit.html)",
version: "0.0.1",
type: "action",
props: {
app,
orgUnitType: {
type: "string",
label: "Org Unit Type",
description: "Filter by organizational unit type ID (e.g., type ID for course offerings). Leave empty to retrieve all types.",
optional: true,
},
orgUnitName: {
type: "string",
label: "Org Unit Name Filter",
description: "Filter by names containing this substring",
optional: true,
},
orgUnitCode: {
type: "string",
label: "Org Unit Code Filter",
description: "Filter by codes containing this substring",
optional: true,
},
max: {
type: "integer",
label: "Maximum Results",
description: "The maximum number of organizational units to return",
optional: true,
default: 100,
},
},
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
async run({ $ }) {
const {
app,
orgUnitType,
orgUnitName,
orgUnitCode,
max,
} = this;

const orgUnits = [];

const iterator = app.paginate({
fn: app.listOrgUnits,
params: {
orgUnitType,
orgUnitName,
orgUnitCode,
},
maxResults: max,
});

for await (const orgUnit of iterator) {
orgUnits.push(orgUnit);
}

$.export("$summary", `Successfully retrieved ${orgUnits.length} organizational unit${orgUnits.length === 1
? ""
: "s"}`);
return orgUnits;
},
};
20 changes: 20 additions & 0 deletions components/d2l_brightspace/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const DOMAIN_PLACEHOLDER = "{domain}";
const BASE_URL_TEMPLATE = `https://${DOMAIN_PLACEHOLDER}/d2l/api`;
const DEFAULT_LIMIT = 100;
const DEFAULT_MAX = 600;
const LP_VERSION = "1.0";
const LE_VERSION = "1.0";
const API_CONTEXTS = {
LP: "lp",
LE: "le",
};

export default {
BASE_URL_TEMPLATE,
DOMAIN_PLACEHOLDER,
DEFAULT_LIMIT,
DEFAULT_MAX,
LP_VERSION,
LE_VERSION,
API_CONTEXTS,
};
Loading
Loading