MCPcopy Create free account
hub / github.com/codecombat/codecombat / removeCourse

Function removeCourse

app/core/store/modules/courseInstances.js:273–296  ·  view source on GitHub ↗
({ state }, { course, members, classroom })

Source from the content-addressed store, hash-verified

271 },
272
273 async removeCourse ({ state }, { course, members, classroom }) {
274 const courseInstanceData = state.courseInstanceByClassroom[classroom._id].find((ci) => ci.courseID === course._id)
275 if (!courseInstanceData) {
276 noty({ text: `No course found to remove.`, type: 'error', layout: 'topCenter', timeout: 5000 })
277 return
278 }
279 const courseInstance = new CourseInstance(courseInstanceData)
280 const membersBefore = courseInstance.get('members').length
281
282 if (members.length) {
283 noty({ text: $.i18n.t('teacher.removing_course'), layout: 'center', type: 'information', killer: true })
284
285 await courseInstance.removeMembers(members)
286
287 const membersAfter = courseInstance.get('members').length || 0
288 const numRemoved = membersBefore - membersAfter
289 const lines = [
290 $.i18n.t('teacher.removed_course_msg')
291 .replace('{{numberRemoved}}', numRemoved)
292 .replace('{{courseName}}', course.name)
293 ]
294 noty({ text: lines.join('<br />'), layout: 'center', type: 'information', killer: true, timeout: 5000 })
295 }
296 },
297
298 // creates free course instances for a new classroom, so that when students join the classroom they are assigned the free courses
299 // TODO move to server in the classroom creation flow

Callers

nothing calls this directly

Calls 2

removeMembersMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected