Skip to content

Commit

Permalink
[Courses tab] Rename show substitutions to include substitutions
Browse files Browse the repository at this point in the history
  • Loading branch information
rikurauhala committed Jun 17, 2024
1 parent 832546c commit 5f33234
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const populationStatisticsToolTips = {
**Courses**
Tällä välilehdellä näkyy, mitä opetussuunnitelmaan kuuluvia kursseja opiskelija on suorittanut. Valitsemalla "Show substitutions" otetaan myös huomioon arvosanat vastaavista kursseista.
Tällä välilehdellä näkyy, mitä opetussuunnitelmaan kuuluvia kursseja opiskelija on suorittanut. Valitsemalla "Include substitutions" otetaan mukaan myös arvosanat vastaavista kursseista.
Merkkien selitykset:
- ✓ Vihreä tarkastusmerkki = Opiskelija on suorittanut kurssin hyväksytysti
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Radio } from 'semantic-ui-react'

export const IncludeSubstitutionsToggle = ({ includeSubstitutions, toggleIncludeSubstitutions }) => {
return (
<div style={{ marginTop: 15, marginBottom: 10 }}>
<Radio
checked={includeSubstitutions}
label="Include substitutions"
onChange={toggleIncludeSubstitutions}
toggle
/>
</div>
)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const getPassedStudents = (curriculum, includeSubstitutions, populationCourses,
return getPassedWithoutSubstitutions()
}

const CoursesTable = ({ curriculum, showSubstitutions, students, studyGuidanceCourses }) => {
const CoursesTable = ({ curriculum, includeSubstitutions, students, studyGuidanceCourses }) => {
const { getTextIn } = useLanguage()
const { visible: namesVisible } = useStudentNameVisibility()
const { data: populationCourses, pending } = useSelector(state => state?.populationSelectedStudentCourses)
Expand Down Expand Up @@ -105,14 +105,14 @@ const CoursesTable = ({ curriculum, showSubstitutions, students, studyGuidanceCo
totalPassed += calculatePassedCourses(studentNumber, defaultProgrammeCourses, hasPassedCourse)
totalPassed += calculatePassedCourses(studentNumber, secondProgrammeCourses, hasPassedCourse)

if (showSubstitutions) {
if (includeSubstitutions) {
totalPassed += calculatePassedCourses(studentNumber, defaultProgrammeCourses, hasPassedSubstitutionCourse)
totalPassed += calculatePassedCourses(studentNumber, secondProgrammeCourses, hasPassedSubstitutionCourse)
}

return totalPassed
},
[curriculum, hasPassedCourse, hasPassedSubstitutionCourse, showSubstitutions]
[curriculum, hasPassedCourse, hasPassedSubstitutionCourse, includeSubstitutions]
)

const columns = useMemo(() => {
Expand Down Expand Up @@ -358,7 +358,7 @@ const CoursesTable = ({ curriculum, showSubstitutions, students, studyGuidanceCo
const bestGrade = findBestGrade(student.courses, course.code)
const passedCourse = hasPassedCourse(student.studentNumber, course.code)
const passedSubstitutionCourse = hasPassedSubstitutionCourse(student.studentNumber, course.code)
if ((bestGrade && passedCourse) || (showSubstitutions && passedSubstitutionCourse)) {
if ((bestGrade && passedCourse) || (includeSubstitutions && passedSubstitutionCourse)) {
return getNumericGrade(bestGrade)
}
if (hasActiveEnrollments(student, course.code)) {
Expand All @@ -376,7 +376,7 @@ const CoursesTable = ({ curriculum, showSubstitutions, students, studyGuidanceCo
if (bestGrade && passedCourse) {
return <Icon color="green" fitted name="check" />
}
if (showSubstitutions && passedSubstitutionCourse) {
if (includeSubstitutions && passedSubstitutionCourse) {
return <Icon color="grey" fitted name="check" />
}
if (hasActiveEnrollments(student, course.code)) {
Expand Down Expand Up @@ -407,7 +407,7 @@ const CoursesTable = ({ curriculum, showSubstitutions, students, studyGuidanceCo
if (hasPassedCourse(student.studentNumber, course.code)) {
++total[course.code]
}
if (showSubstitutions && hasPassedSubstitutionCourse(student.studentNumber, course.code)) {
if (includeSubstitutions && hasPassedSubstitutionCourse(student.studentNumber, course.code)) {
++total[course.code]
}
})
Expand All @@ -423,7 +423,7 @@ const CoursesTable = ({ curriculum, showSubstitutions, students, studyGuidanceCo

return [row(totals, { ignoreFilters: true, ignoreSorting: true }), ...students]
}, [
showSubstitutions,
includeSubstitutions,
curriculum,
students,
passedStudents,
Expand Down Expand Up @@ -461,12 +461,12 @@ const StudyGuidanceGroupCoursesTabContainer = ({ curriculum, group, students })
return <CoursesTable curriculum={curriculum} students={students} studyGuidanceCourses={populationsCourses} />
}

export const CoursesTabContainer = ({ curriculum, showSubstitutions, students, studyGuidanceGroup, variant }) => {
export const CoursesTabContainer = ({ curriculum, includeSubstitutions, students, studyGuidanceGroup, variant }) => {
if (variant === 'studyGuidanceGroupPopulation') {
return (
<StudyGuidanceGroupCoursesTabContainer curriculum={curriculum} group={studyGuidanceGroup} students={students} />
)
}

return <CoursesTable curriculum={curriculum} showSubstitutions={showSubstitutions} students={students} />
return <CoursesTable curriculum={curriculum} includeSubstitutions={includeSubstitutions} students={students} />
}
12 changes: 6 additions & 6 deletions services/frontend/src/components/PopulationStudents/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { StudentNameVisibilityToggle } from '@/components/StudentNameVisibilityT
import { useGetAuthorizedUserQuery } from '@/redux/auth'
import { useGetTagsByStudyTrackQuery } from '@/redux/tags'
import { CheckStudentList } from './CheckStudentList'
import { ShowSubstitutionsToggle } from './ShowSubstitutionsToggle'
import { IncludeSubstitutionsToggle } from './IncludeSubstitutionsToggle'
import { CoursesTabContainer as CoursesTab } from './StudentTable/CoursesTab'
import { GeneralTabContainer as GeneralTab } from './StudentTable/GeneralTab'
import { ProgressTable as ProgressTab } from './StudentTable/ProgressTab'
Expand All @@ -35,7 +35,7 @@ const Panes = ({
year,
}) => {
const { handleTabChange } = useTabChangeAnalytics()
const [showSubstitutions, toggleShowSubstitutions] = useToggle(false)
const [includeSubstitutions, toggleIncludeSubstitutions] = useToggle(false)
const programmeForTagsLink = combinedProgramme ? `${mainProgramme}+${combinedProgramme}` : mainProgramme
const programme = studyGuidanceGroup?.tags?.studyProgramme || ''
const correctCode = combinedProgramme ? `${mainProgramme}+${combinedProgramme}` : mainProgramme
Expand Down Expand Up @@ -63,7 +63,7 @@ const Panes = ({
render: () => (
<CoursesTab
curriculum={curriculum}
showSubstitutions={showSubstitutions}
includeSubstitutions={includeSubstitutions}
students={filteredStudents}
studyGuidanceGroup={studyGuidanceGroup}
variant={variant}
Expand Down Expand Up @@ -104,9 +104,9 @@ const Panes = ({
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div style={{ display: 'flex', flexDirection: 'row', gap: '20px' }}>
<StudentNameVisibilityToggle />
<ShowSubstitutionsToggle
showSubstitutions={showSubstitutions}
toggleShowSubstitutions={toggleShowSubstitutions}
<IncludeSubstitutionsToggle
includeSubstitutions={includeSubstitutions}
toggleIncludeSubstitutions={toggleIncludeSubstitutions}
/>
</div>
{dataExport}
Expand Down

0 comments on commit 5f33234

Please sign in to comment.