8000 Fix 'locked by prev' to continue in next module by adamkecskes · Pull Request #7835 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix 'locked by prev' to continue in next module #7835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2024
Merged
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
Expand Up @@ -136,6 +136,8 @@ export default {
const modulesForTable = []

// Get the name and content list of a module.
const isPlayableForStudent = {}
const lastLockDateForStudent = {}
Comment on lines +139 to +140
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider making the state objects reactive for proper Vue.js updates.

These objects store important per-student state but aren't reactive. Consider using Vue's reactive system to ensure proper updates and re-rendering.

-const isPlayableForStudent = {}
-const lastLockDateForStudent = {}
+const isPlayableForStudent = Vue.reactive({})
+const lastLockDateForStudent = Vue.reactive({})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const isPlayableForStudent = {}
const lastLockDateForStudent = {}
const isPlayableForStudent = Vue.reactive({})
const lastLockDateForStudent = Vue.reactive({})

for (const [moduleNum, moduleContent] of Object.entries(modules)) {
// Because we are only reading the easiest way to propagate _most_
// i18n is by transforming the content linearly here.
Expand Down Expand Up @@ -175,6 +177,8 @@ export default {
}))
// Iterate over all the students and all the sessions for the student.
for (const student of this.students) {
isPlayableForStudent[student._id] = typeof isPlayableForStudent[student._id] === 'undefined' ? true : isPlayableForStudent[student._id]
lastLockDateForStudent[student._id] = typeof lastLockDateForStudent[student._id] === 'undefined' ? null : lastLockDateForStudent[student._id]
const studentSessions = this.levelSessionsMapByUser[student._id] || {}
const levelOriginalCompletionMap = {}
const playTimeMap = {}
Expand All @@ -186,8 +190,6 @@ export default {
completionDateMap[session.level.original] = session.state.complete && session.changed
}

let isPlayable = true
let lastLockDate = null
moduleStatsForTable.studentSessions[student._id] = translatedModuleContent.map((content) => {
const { original, fromIntroLevelOriginal, practiceLevels } = content
const normalizedOriginal = original || fromIntroLevelOriginal
Expand All @@ -204,14 +206,14 @@ export default {
const isSkipped = isOptional && isLocked

if (lockDate && lockDate > new Date()) {
lastLockDate = lockDate
lastLockDateForStudent[student._id] = lockDate
if (!isOptional) {
isPlayable = false
isPlayableForStudent[student._id] = false
}
}

if (isLocked && !isOptional) {
isPlayable = false
isPlayableForStudent[student._id] = false
}

const isPractice = Boolean(content.practice)
Expand All @@ -222,12 +224,12 @@ export default {
isLocked,
isSkipped,
lockDate,
lastLockDate,
lastLockDate: lastLockDateForStudent[student._id],
original,
normalizedOriginal,
fromIntroLevelOriginal,
isOptional,
isPlayable,
isPlayable: isPlayableForStudent[student._id],
isPractice,
playTime: playTimeMap[normalizedOriginal],
completionDate: completionDateMap[normalizedOriginal],
Expand Down
Loading
0