簡體   English   中英

LMS 中單個學生的 Next.js/Mongodb 分配狀態

[英]Next.js/Mongodb Assignment Status for Individual Student in a LMS

我正在構建一個 MERN(使用 Next.js)堆棧學習管理系統。 目前,我已經為列出該課程作業的作業構建了前端。 例如,如果我已登錄,如果我 go 到test.com/courses/PHIL204/Assignments ,我將看到我在 PHIL 204 課程中的所有作業。 現在,在此表中,有一列顯示“狀態”,說明作業是否已開始、已提交或已評分(只有 3 個值)。 我的問題是,我如何存儲/計算這個值? 我的數據庫中有兩個 collections (其中很多)學生和作業。 我的數據庫仍在開發中,因此我可以輕松遵循您的建議。 我不認為 Assignments col 應該有一個“status”字段,因為這對於所有有該作業的學生來說都是一樣的。 如果您需要我的任何代碼,我可以提供。 如果學生已經開始,提交或評分(由教授)該作業,我正在尋求幫助,主要是關於存儲什么/如何存儲的邏輯。

任何幫助將不勝感激。 非常感謝。

實際上,GitHub Copilot 建議我在學生模式中我有這樣的東西:

const studentSchema = mongoose.Schema({
    studentFirstName : {type : String, required: true},
    studentLastName : {type : String, required: true},
    studentEmail : {type : String, required: true},
    studentClass : {type : String},
    studentAssignments : [{
        assignmentId : {type : Schema.ObjectId, ref: 'Assignments'},
        assignmentGrade : {type : String, enum : ["A","A-","B+","B","B-","C+","C","C-","D+","D","D-","F"]},
        assignmentStatus : {type : String, enum : ["Not Started", "Started", "Submitted", "Returned"]},
        assignmentRemarks : {type : String},
        assignmentCompeletedDate : {type : Date},
    }],
    studentTestQuizzes : [{
        testQuizId : {type : Schema.ObjectId, ref: 'TestQuizzes'},
        testQuizGrade : {type : String, enum : ["A","A-","B+","B","B-","C+","C","C-","D+","D","D-","F"]},
        testQuizStatus : {type : String, enum : ["Not Started", "Submitted", "Returned"]},
        testQuizRemarks : {type : String},
        testQuizCompletedDate : {type : Date},
    }],
    studentAnnouncements : [{
        announcementId : {type : Schema.ObjectId, ref: 'Announcements'},
        announcementStatus : {type : String, enum : ["Read", "Not Read"]},
    }],
    // we need a courseId to link the student to a course

}, { collection: 'Students' });

這應該有效。 如果它不起作用或者我需要做更多的工作,我會更新這個線程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM