mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: update quest and user schema
* add requirements in quest * add progress in user
This commit is contained in:
1 parent
710eb8fc2e
commit
fac91e0f10
6 files changed
+67
-7
No files matched your search
@@ -54,7 +54,10 @@ const stageSchema = new Schema({
|
|||||||
required: true,
|
required: true,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
condition: conditionSchema,
|
condition: {
|
||||||
|
type: conditionSchema,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
responses: {
|
responses: {
|
||||||
type: [responseSchema],
|
type: [responseSchema],
|
||||||
required: true,
|
required: true,
|
||||||
@@ -68,11 +71,32 @@ const stageSchema = new Schema({
|
|||||||
const Quest = model(
|
const Quest = model(
|
||||||
'Quest',
|
'Quest',
|
||||||
new Schema({
|
new Schema({
|
||||||
_id: String,
|
_id: {
|
||||||
title: String,
|
type: String,
|
||||||
order: Number,
|
unique: true,
|
||||||
instruction: String,
|
required: true,
|
||||||
stages: [stageSchema],
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
requirements: {
|
||||||
|
type: [
|
||||||
|
{
|
||||||
|
type: String,
|
||||||
|
ref: 'Quest',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
instruction: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
stages: {
|
||||||
|
type: [stageSchema],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
import { model, Schema } from 'mongoose'
|
import { model, Schema } from 'mongoose'
|
||||||
|
|
||||||
|
const progressSchema = new Schema({
|
||||||
|
quest: {
|
||||||
|
type: String,
|
||||||
|
ref: 'Quest',
|
||||||
|
},
|
||||||
|
sessions: [
|
||||||
|
{
|
||||||
|
type: Schema.ObjectId,
|
||||||
|
ref: 'Session',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
completionStatus: {
|
||||||
|
type: String,
|
||||||
|
enum: ['incomplete', 'completed'],
|
||||||
|
},
|
||||||
|
startedAt: Date,
|
||||||
|
finishedAt: Date,
|
||||||
|
})
|
||||||
|
|
||||||
const User = model(
|
const User = model(
|
||||||
'User',
|
'User',
|
||||||
new Schema(
|
new Schema(
|
||||||
@@ -23,6 +42,7 @@ const User = model(
|
|||||||
id: String,
|
id: String,
|
||||||
displayName: String,
|
displayName: String,
|
||||||
},
|
},
|
||||||
|
progress: [progressSchema],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timestamps: true,
|
timestamps: true,
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
title: Discover the World!
|
||||||
|
instruction: |
|
||||||
|
試著探索這個世界吧!
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
- spell
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
title: Read the File
|
||||||
|
instruction: |
|
||||||
|
閱讀檔案
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
- spell
|
||||||
@@ -4,6 +4,10 @@ instruction: |
|
|||||||
|
|
||||||
「輸入 echo Hello World!」
|
「輸入 echo Hello World!」
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
- helloworld
|
||||||
|
- noexists
|
||||||
|
|
||||||
conditions:
|
conditions:
|
||||||
pwd_home: &pwd_home
|
pwd_home: &pwd_home
|
||||||
pwd:
|
pwd:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export default async function loadAndUpdateQuests() {
|
|||||||
return Quest.findByIdAndUpdate(
|
return Quest.findByIdAndUpdate(
|
||||||
id,
|
id,
|
||||||
{
|
{
|
||||||
id,
|
_id: id,
|
||||||
...quest,
|
...quest,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user