diff --git a/frontend/src/components/BatchStudents.vue b/frontend/src/components/BatchStudents.vue index 43d315c0..72b05842 100644 --- a/frontend/src/components/BatchStudents.vue +++ b/frontend/src/components/BatchStudents.vue @@ -31,110 +31,29 @@ - -
-
- {{ __('Progress') }} -
- -
-
-
-
- {{ __('Courses') }} -
-
-
-
-
- {{ __('Assessments') }} -
-
-
-
@@ -279,7 +198,6 @@ const showStudentModal = ref(false) const showStudentProgressModal = ref(false) const selectedStudent = ref(null) const chartData = ref(null) -const chartOptions = ref(null) const showProgressChart = ref(false) const assessmentCount = ref(0) const readOnlyMode = window.read_only_mode @@ -367,104 +285,49 @@ const removeStudents = (selections, unselectAll) => { } const getChartData = () => { + let tasks = [] let data = [] - console.log(students.data) students.data.forEach((row) => { - row.assessments.forEach((assessment) => {}) + tasks = countAssessments(row, tasks) + tasks = countCourses(row, tasks) }) - /* let categories = {} - - if (!students.data?.length) return [] - console.log(students.data) - Object.keys(students.data[0].courses).forEach((course) => { - categories[course] = { - value: 0, - type: 'course', - label: course, - } - }) - - Object.keys(students.data?.[0].assessments).forEach((assessment) => { - categories[assessment] = { - value: 0, - type: 'assessment', - label: assessment, - } - }) - - students.data.forEach((student) => { - Object.keys(student.courses).forEach((course) => { - if (student.courses[course] === 100) { - categories[course].value += 1 - } - }) - - Object.keys(student.assessments).forEach((assessment) => { - if (student.assessments[assessment].result === 'Pass') { - categories[assessment].value += 1 - } + tasks.forEach((task) => { + data.push({ + task: task.label, + value: task.value, }) }) - - chartOptions.value = getChartOptions(categories) - console.log(Object.values(categories).map((item) => item.value)) - return [ - { - name: __('Completed by Students'), - data: Object.values(categories).map((item) => item.value), - }, - ] */ + return data } -const getChartOptions = (categories) => { - const courseColor = theme.colors.green[700] - const assessmentColor = theme.colors.blue[700] - const maxY = - students.data?.length % 5 - ? students.data?.length + (5 - (students.data?.length % 5)) - : students.data?.length +const countAssessments = (row, tasks) => { + Object.keys(row.assessments).forEach((assessment) => { + if (row.assessments[assessment].result === 'Pass') { + tasks.filter((task) => task.label === assessment).length + ? tasks.filter((task) => task.label === assessment)[0].value++ + : tasks.push({ + value: 1, + label: assessment, + }) + } + }) + return tasks +} - return { - chart: { - type: 'bar', - toolbar: { - show: false, - }, - }, - plotOptions: { - bar: { - distributed: true, - borderRadius: 3, - borderRadiusApplication: 'end', - horizontal: true, - barHeight: '40%', - }, - }, - colors: Object.values(categories).map((item) => - item.type === 'course' ? courseColor : assessmentColor - ), - xaxis: { - categories: Object.values(categories).map((item) => item.label), - labels: { - style: { - fontSize: '10px', - }, - rotate: 0, - formatter: function (value) { - return value.length > 30 ? `${value.substring(0, 30)}...` : value - }, - }, - }, - yaxis: { - max: maxY, - min: 0, - stepSize: 10, - tickAmount: maxY / 5, - /* reversed: true */ - }, - } +const countCourses = (row, tasks) => { + Object.keys(row.courses).forEach((course) => { + if (row.courses[course] === 100) { + tasks.filter((task) => task.label === course).length + ? tasks.filter((task) => task.label === course)[0].value++ + : tasks.push({ + value: 1, + label: course, + }) + } + }) + return tasks } watch(students, () => { @@ -484,8 +347,3 @@ const certificationCount = createResource({ auto: true, }) -