Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: New feedback is not shown in results #1457

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/integration/interimFeedback.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ describe('Students', () => {
// New tabs are rendered when feedback was given
cy.get('[data-cy="interim-feedback-target-edit-feedback-tab"]').should('exist')
cy.get('[data-cy="interim-feedback-target-results-tab"]').should('exist').click()
cy.get('[data-cy="notEnoughFeedbacks"]').should('exist')
cy.contains('Multiple choice questions')

cy.url().should('include', '/results')

Expand Down
17 changes: 17 additions & 0 deletions cypress/integration/userfeedbacks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ describe('User feedbacks view', () => {
.should('not.exist')
})

it('Feedback is visible immediately after being given', () => {
cy.loginAs(student)
cy.get('@fbtId').then(id => cy.visit(`/targets/${id}`))
cy.get('input[value=5]').each($el => {
cy.get($el).click()
})
cy.getUniversityQuestions().then(questions => {
const openQuestion = questions.find(q => q.type === 'OPEN')
cy.get(`textarea[id=${openQuestion.id}-label]`).type('Other comments and such')
})
cy.get('[data-cy=feedback-view-give-feedback]').click()

cy.get('[data-cy="feedback-target-results-tab"]')

cy.contains('Multiple choice questions')
})

it('Teacher can censor a feedback', () => {
// student gives feedback
cy.loginAs(student)
Expand Down
9 changes: 3 additions & 6 deletions src/client/pages/FeedbackTarget/tabs/FeedbackView/utils.js
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tässä olennainen osa fixiä

Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,11 @@ export const useSaveValues = () => {
return data
},
{
onSuccess: feedback => {
queryClient.setQueryData(['feedbackTarget', String(feedbackTarget.id)], prev => ({
...prev,
feedback,
}))

onSuccess: () => {
// Invalidate the waiting feedback count for the student
queryClient.invalidateQueries('myFeedbacksWaitingFeedbackCount')
// Invalidate the feedbackTarget data
queryClient.invalidateQueries(['feedbackTarget', String(feedbackTarget.id)])
},
}
)
Expand Down
12 changes: 11 additions & 1 deletion src/server/util/logger.ts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jostain syystä loggeri kaatoi sovelluksen kun yritti JSON.stringifyiaa objectia jossa referenssi itseensä, kun Jamiin ei lokaalisti saanut yhteyttä - tämä korjaa sen tilanteen

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ if (process.env.NODE_ENV !== 'test') {
if (!inProduction) {
const devFormat = printf(
// eslint-disable-next-line @typescript-eslint/no-shadow
({ level, message, timestamp, ...rest }) => `${timestamp} ${level}: ${message} ${JSON.stringify(rest)}`
({ level, message, timestamp, ...rest }) => {
let restMsg = ''
try {
restMsg = JSON.stringify(rest)
} catch (e) {
// eslint-disable-next-line no-console
console.error('Failed to stringify log message', rest)
}
const msg = `${timestamp} ${level}: ${message} ${restMsg}`
return msg
}
)

transports.push(
Expand Down
Loading