Created a system to go directly to an assignment from a URL
This commit is contained in:
@@ -8,6 +8,7 @@ import {getUserCorporate} from "./groups.be";
|
||||
import {Db, ObjectId} from "mongodb";
|
||||
import client from "@/lib/mongodb";
|
||||
import {MODULE_ARRAY} from "./moduleUtils";
|
||||
import { mapBy } from ".";
|
||||
|
||||
const db = client.db(process.env.MONGODB_DB);
|
||||
|
||||
@@ -37,7 +38,7 @@ export const getExamsByIds = async (ids: {module: Module; id: string}[]) => {
|
||||
async (m) =>
|
||||
await db
|
||||
.collection(m)
|
||||
.find<Exam>({id: {$in: groupedByModule[m]}})
|
||||
.find<Exam>({id: {$in: mapBy(groupedByModule[m], 'id')}})
|
||||
.toArray(),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -9,3 +9,8 @@ export const getSessionsByUser = async (id: string, limit?: number) =>
|
||||
.find<Session>({user: id})
|
||||
.limit(limit || 0)
|
||||
.toArray();
|
||||
|
||||
export const getSessionByAssignment = async (assignmentID: string) =>
|
||||
await db
|
||||
.collection("sessions")
|
||||
.findOne<Session>({"assignment.id": assignmentID})
|
||||
|
||||
Reference in New Issue
Block a user