Skip to content

Commit

Permalink
Merge pull request #1431 from UniversityOfHelsinkiCS/dec24-ux-tweaks
Browse files Browse the repository at this point in the history
December 2024 UI/UX tweaks
  • Loading branch information
Veikkosuhonen authored Jan 20, 2025
2 parents 1d2fdea + 819d17c commit c0ba88f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 53 deletions.
2 changes: 1 addition & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
"qrCodeHelpText": "Easiest way to share the QR-code is by screenshotting it",
"deleteTeacherConfirmation": "Delete {{name}} from teachers?",
"noFeedbackResponseYet": "The teacher of the course has not yet given counter feedback",
"noAccess": "We couldn't find your enrolment for this course. If you enrollent recently, you might need to wait for 1-2 hours.",
"noAccess": "We couldn't find your enrolment for this course. If you have enrolled recently, you might need to wait for 1-2 hours.",
"noAccessOldCourse": "The feedback period ended over a year ago, and feedback can no longer be given for this course. Please check the information above to ensure that the course is correct.",
"noAccessEndedCourse": "The feedback period has ended, and feedback can no longer be given for this course. Please check the information above to ensure that the course is correct.",
"notFound": "Cannot find this course feedback! If you entered the URL manually, make sure it is correct",
Expand Down
72 changes: 20 additions & 52 deletions src/server/routes/organisations/organisationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ const { Router } = require('express')
const { Op } = require('sequelize')

const { formatActivityPeriod } = require('../../util/common')
const {
getOrganisationsList,
} = require('../../services/organisations/getOrganisationsList')
const { getOrganisationsList } = require('../../services/organisations/getOrganisationsList')
const { ORGANISATION_SURVEYS_ENABLED } = require('../../util/config')
const {
Organisation,
Expand All @@ -22,16 +20,12 @@ const getOpenFeedbackByOrganisation = require('./getOpenFeedbackByOrganisation')
const { getAccessAndOrganisation } = require('./util')
const feedbackCorrespondentRouter = require('./feedbackCorrespondentController')
const organisationSurveyRouter = require('./organisationSurveyController')
const {
getOrganisationData: getOrganisationDataFromJami,
} = require('../../util/jami')
const { getOrganisationData: getOrganisationDataFromJami } = require('../../util/jami')

const getUpdatedCourseCodes = async (updatedCourseCodes, organisation) => {
const organisationCourseCodes = await organisation.getCourseCodes()

return _.uniq(
updatedCourseCodes.filter((c) => organisationCourseCodes.includes(c))
)
return _.uniq(updatedCourseCodes.filter(c => organisationCourseCodes.includes(c)))
}

const getOrganisations = async (req, res) => {
Expand Down Expand Up @@ -69,11 +63,7 @@ const updateOrganisation = async (req, res) => {
const { user, body } = req
const { code } = req.params

const { organisation, hasAdminAccess } = await getAccessAndOrganisation(
user,
code,
{ write: true }
)
const { organisation, hasAdminAccess } = await getAccessAndOrganisation(user, code, { write: true })

const updates = _.pick(body, [
'studentListVisible',
Expand All @@ -83,21 +73,12 @@ const updateOrganisation = async (req, res) => {
'publicQuestionIds',
])

if (
!hasAdminAccess &&
(updates.disabledCourseCodes || updates.studentListVisibleCourseCodes)
) {
throw new ApplicationError(
403,
'Course codes can only be updated by organisation admins'
)
if (!hasAdminAccess && (updates.disabledCourseCodes || updates.studentListVisibleCourseCodes)) {
return ApplicationError.Forbidden('Course codes can only be updated by organisation admins')
}

if (updates.disabledCourseCodes) {
updates.disabledCourseCodes = await getUpdatedCourseCodes(
updates.disabledCourseCodes,
organisation
)
updates.disabledCourseCodes = await getUpdatedCourseCodes(updates.disabledCourseCodes, organisation)
}

if (updates.studentListVisibleCourseCodes) {
Expand All @@ -120,10 +101,9 @@ const getOrganisationByCode = async (req, res) => {
const { user } = req
const { code } = req.params

const { organisation, hasReadAccess, hasWriteAccess, hasAdminAccess } =
await getAccessAndOrganisation(user, code, {
read: true,
})
const { organisation, hasReadAccess, hasWriteAccess, hasAdminAccess } = await getAccessAndOrganisation(user, code, {
read: true,
})

const theOrganisation = await Organisation.findOne({
where: {
Expand All @@ -138,7 +118,7 @@ const getOrganisationByCode = async (req, res) => {
],
})

const tags = _.orderBy(await theOrganisation.getTags(), (tag) => tag.name?.fi)
const tags = _.orderBy(await theOrganisation.getTags(), tag => tag.name?.fi)

const publicOrganisation = {
...organisation.toJSON(),
Expand All @@ -159,17 +139,15 @@ const getOrganisationLogs = async (req, res) => {
const { code } = req.params

if (!user.isAdmin) {
throw new ApplicationError('Forbidden', 403)
return ApplicationError.Forbidden()
}

const { organisationLogs } = await Organisation.findOne({
where: {
code,
},
attributes: [],
order: [
[{ model: OrganisationLog, as: 'organisationLogs' }, 'createdAt', 'DESC'],
],
order: [[{ model: OrganisationLog, as: 'organisationLogs' }, 'createdAt', 'DESC']],
include: {
model: OrganisationLog,
as: 'organisationLogs',
Expand All @@ -190,12 +168,10 @@ const getOpenQuestionsByOrganisation = async (req, res) => {

const organisationAccess = await user.getOrganisationAccess()

const access = organisationAccess.filter(
(org) => org.organisation.code === code
)
const access = organisationAccess.filter(org => org.organisation.code === code)

if (access.length === 0) {
throw new ApplicationError('Forbidden', 403)
return ApplicationError.Forbidden()
}

const codesWithIds = await getOpenFeedbackByOrganisation(code)
Expand All @@ -211,12 +187,10 @@ const findFeedbackTargets = async (req, res) => {

const { search } = query

const access = organisationAccess.filter(
(org) => org.organisation.code === code
)
const access = organisationAccess.filter(org => org.organisation.code === code)

if (access.length === 0) {
throw new ApplicationError('Forbidden', 403)
return ApplicationError.Forbidden()
}

const activityPeriod = formatActivityPeriod(query)
Expand All @@ -239,18 +213,12 @@ const findFeedbackTargets = async (req, res) => {
[Op.or]: [
{
startDate: {
[Op.between]: [
activityPeriod.startDate,
activityPeriod.endDate,
],
[Op.between]: [activityPeriod.startDate, activityPeriod.endDate],
},
},
{
endDate: {
[Op.between]: [
activityPeriod.startDate,
activityPeriod.endDate,
],
[Op.between]: [activityPeriod.startDate, activityPeriod.endDate],
},
},
{
Expand Down Expand Up @@ -288,7 +256,7 @@ const findFeedbackTargets = async (req, res) => {
},
})

res.send(courseUnits)
return res.send(courseUnits)
}

const router = Router()
Expand Down

0 comments on commit c0ba88f

Please sign in to comment.