| 683 | |
| 684 | // Build table of student/teacher paid/trial/free totals |
| 685 | const updateCourseTotalsMap = (courseTotalsMap, furthestCourseMap, paidStatusMap, columnSuffix) => { |
| 686 | return (() => { |
| 687 | const result = [] |
| 688 | for (user in furthestCourseMap) { |
| 689 | var name, name1 |
| 690 | const courseIndex = furthestCourseMap[user] |
| 691 | const courseName = this.courses.models[courseIndex].get('name') |
| 692 | if (courseTotalsMap[courseName] == null) { courseTotalsMap[courseName] = {} } |
| 693 | const columnName = (() => { |
| 694 | switch (paidStatusMap[user]) { |
| 695 | case 'paid': return 'Paid ' + columnSuffix |
| 696 | case 'trial': return 'Trial ' + columnSuffix |
| 697 | case 'free': return 'Free ' + columnSuffix |
| 698 | } |
| 699 | })() |
| 700 | if (courseTotalsMap[courseName][columnName] == null) { courseTotalsMap[courseName][columnName] = 0 } |
| 701 | courseTotalsMap[courseName][columnName]++ |
| 702 | if (courseTotalsMap[courseName][name = 'Total ' + columnSuffix] == null) { courseTotalsMap[courseName][name] = 0 } |
| 703 | courseTotalsMap[courseName]['Total ' + columnSuffix]++ |
| 704 | if (courseTotalsMap['All Courses'][name1 = 'Total ' + columnSuffix] == null) { courseTotalsMap['All Courses'][name1] = 0 } |
| 705 | courseTotalsMap['All Courses']['Total ' + columnSuffix]++ |
| 706 | if (courseTotalsMap['All Courses'][columnName] == null) { courseTotalsMap['All Courses'][columnName] = 0 } |
| 707 | result.push(courseTotalsMap['All Courses'][columnName]++) |
| 708 | } |
| 709 | return result |
| 710 | })() |
| 711 | } |
| 712 | const courseTotalsMap = { 'All Courses': {} } |
| 713 | updateCourseTotalsMap(courseTotalsMap, teacherFurthestCourseMap, teacherPaidStatusMap, 'Teachers') |
| 714 | updateCourseTotalsMap(courseTotalsMap, studentFurthestCourseMap, studentPaidStatusMap, 'Students') |