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

Method onClickEnableButton

app/views/courses/ClassroomView.js:263–288  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

261 }
262
263 onClickEnableButton (e) {
264 const $button = $(e.target).closest('.btn')
265 const courseInstance = this.courseInstances.get($button.data('course-instance-cid'))
266 console.log('looking for course instance', courseInstance, 'for', $button.data('course-instance-cid'), 'out of', this.courseInstances)
267 const userID = $button.data('user-id')
268 $button.attr('disabled', true)
269 if (application.tracker != null) {
270 application.tracker.trackEvent('Course assign student', { category: 'Courses', courseInstanceID: courseInstance.id, userID })
271 }
272
273 const onCourseInstanceCreated = () => {
274 courseInstance.addMember(userID)
275 return this.listenToOnce(courseInstance, 'sync', this.render)
276 }
277
278 if (courseInstance.isNew()) {
279 // adding the first student to this course, so generate the course instance for it
280 if (!courseInstance.saving) {
281 courseInstance.save(null, { validate: false })
282 courseInstance.saving = true
283 }
284 return courseInstance.once('sync', onCourseInstanceCreated)
285 } else {
286 return onCourseInstanceCreated()
287 }
288 }
289
290 // TODO: update newly visible level progress bar (currently all white)
291

Callers

nothing calls this directly

Calls 5

dataMethod · 0.80
logMethod · 0.80
getMethod · 0.45
trackEventMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected