From 99d184b4090dfaab32acb1d544d15307790d880a Mon Sep 17 00:00:00 2001 From: bivanalhar Date: Sat, 14 Sep 2024 22:29:33 +0800 Subject: [PATCH] refactor(live_feedback): settings when codaveri is disabled for course - remove "Get Help" button inside SubmissionForm, regardless of whether question has live feedback enabled or not - disable Live Feedback Toggle inside Assessment Edit - Not returning any programming questions for live feedback inside assessment edit - Add Info Label when course has its codaveri disabled, and when no programming questions supportible by codaveri is present --- .../course/assessment/answer/programming.rb | 1 + .../assessment/assessments/edit.json.jbuilder | 1 + .../live_feedback_settings.json.jbuilder | 36 ++++++++++--------- .../submission/submissions/edit.json.jbuilder | 2 +- .../buttons/CodaveriToggleButtons.tsx | 6 +++- .../buttons/LiveFeedbackToggleButton.tsx | 22 ++++++++---- .../components/AssessmentForm/index.tsx | 25 +++++++------ .../components/AssessmentForm/types.ts | 1 + .../AssessmentEdit/AssessmentEditPage.jsx | 3 ++ .../assessment/pages/AssessmentEdit/index.tsx | 1 + .../components/AutogradedActionButtonsRow.tsx | 5 +-- ...nAutogradedProgrammingActionButtonsRow.tsx | 6 +++- .../components/button/ReevaluateButton.tsx | 4 +-- .../course/assessment/submission/types.ts | 1 + 14 files changed, 72 insertions(+), 42 deletions(-) diff --git a/app/models/course/assessment/answer/programming.rb b/app/models/course/assessment/answer/programming.rb index 13a57b3885c..5f0e05b41cc 100644 --- a/app/models/course/assessment/answer/programming.rb +++ b/app/models/course/assessment/answer/programming.rb @@ -96,6 +96,7 @@ def generate_live_feedback should_retrieve_feedback = submission.attempting? && current_answer? && + current_course.component_enabled?(Course::CodaveriComponent) && question.live_feedback_enabled return unless should_retrieve_feedback diff --git a/app/views/course/assessment/assessments/edit.json.jbuilder b/app/views/course/assessment/assessments/edit.json.jbuilder index 4a2bc8a7d34..bc055b858bf 100644 --- a/app/views/course/assessment/assessments/edit.json.jbuilder +++ b/app/views/course/assessment/assessments/edit.json.jbuilder @@ -31,6 +31,7 @@ json.mode_switching @assessment.allow_mode_switching? json.gamified current_course.gamified? json.isQuestionsValidForKoditsu is_all_questions_programming_type && @programming_qns_invalid_for_koditsu.empty? json.isKoditsuExamEnabled current_course.component_enabled?(Course::KoditsuPlatformComponent) +json.isCourseCodaveriEnabled current_course.component_enabled?(Course::CodaveriComponent) json.show_personalized_timeline_features current_course.show_personalized_timeline_features? json.randomization_allowed current_course.allow_randomization diff --git a/app/views/course/assessment/assessments/live_feedback_settings.json.jbuilder b/app/views/course/assessment/assessments/live_feedback_settings.json.jbuilder index db1099e6d42..d45d5298e2a 100644 --- a/app/views/course/assessment/assessments/live_feedback_settings.json.jbuilder +++ b/app/views/course/assessment/assessments/live_feedback_settings.json.jbuilder @@ -6,23 +6,27 @@ json.assessments [@assessment] do |assessment| json.title assessment.title json.url course_assessment_path(current_course, assessment) - json.programmingQuestions @programming_questions do |programming_qn| - next unless CodaveriAsyncApiService.language_valid_for_codaveri?(programming_qn.language) + if current_course.component_enabled?(Course::CodaveriComponent) + json.programmingQuestions @programming_questions do |programming_qn| + next unless CodaveriAsyncApiService.language_valid_for_codaveri?(programming_qn.language) - if programming_qn.title.blank? - question_assessment = assessment.question_assessments.select do |qa| - qa.question_id == programming_qn.question.id - end.first - question_title = question_assessment&.default_title - else - question_title = programming_qn.title - end + if programming_qn.title.blank? + question_assessment = assessment.question_assessments.select do |qa| + qa.question_id == programming_qn.question.id + end.first + question_title = question_assessment&.default_title + else + question_title = programming_qn.title + end - json.id programming_qn.id - json.editUrl url_for([:edit, current_course, assessment, programming_qn]) - json.assessmentId assessment.id - json.title question_title - json.isCodaveri programming_qn.is_codaveri - json.liveFeedbackEnabled programming_qn.live_feedback_enabled + json.id programming_qn.id + json.editUrl url_for([:edit, current_course, assessment, programming_qn]) + json.assessmentId assessment.id + json.title question_title + json.isCodaveri programming_qn.is_codaveri + json.liveFeedbackEnabled programming_qn.live_feedback_enabled + end + else + json.programmingQuestions [] end end diff --git a/app/views/course/assessment/submission/submissions/edit.json.jbuilder b/app/views/course/assessment/submission/submissions/edit.json.jbuilder index 01fc2de9c6f..652fe5b5e1b 100644 --- a/app/views/course/assessment/submission/submissions/edit.json.jbuilder +++ b/app/views/course/assessment/submission/submissions/edit.json.jbuilder @@ -27,7 +27,7 @@ json.assessment do json.url url_to_material(@assessment.course, @assessment.folder, material) json.name format_inline_text(material.name) end - json.isCodaveriEnabled current_course.component_enabled?(Course::CodaveriComponent) + json.isCourseCodaveriEnabled current_course.component_enabled?(Course::CodaveriComponent) end current_answer_ids = @submission.current_answers.pluck(:id) diff --git a/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/CodaveriToggleButtons.tsx b/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/CodaveriToggleButtons.tsx index 3e54ab8cbd1..dc098daa292 100644 --- a/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/CodaveriToggleButtons.tsx +++ b/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/CodaveriToggleButtons.tsx @@ -19,7 +19,11 @@ const CodaveriToggleButtons: FC = (props) => { for={title} type={type} /> - + ); }; diff --git a/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/LiveFeedbackToggleButton.tsx b/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/LiveFeedbackToggleButton.tsx index d4eac37a570..24604dfef94 100644 --- a/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/LiveFeedbackToggleButton.tsx +++ b/client/app/bundles/course/admin/pages/CodaveriSettings/components/buttons/LiveFeedbackToggleButton.tsx @@ -16,11 +16,17 @@ import CodaveriSettingsChip from '../CodaveriSettingsChip'; interface LiveFeedbackToggleButtonProps { assessmentIds: number[]; for: string; - forSpecificAssessment?: boolean; + isSpecificAssessment?: boolean; + isCourseCodaveriEnabled?: boolean; } const LiveFeedbackToggleButton: FC = (props) => { - const { assessmentIds, for: title, forSpecificAssessment } = props; + const { + assessmentIds, + for: title, + isSpecificAssessment, + isCourseCodaveriEnabled, + } = props; const { t } = useTranslation(); const dispatch = useAppDispatch(); @@ -44,7 +50,7 @@ const LiveFeedbackToggleButton: FC = (props) => { const updateLiveFeedbackEnabled = ( liveFeedbackEnabled: boolean, ): Promise => - forSpecificAssessment + isSpecificAssessment ? updateLiveFeedbackForAllQuestionsInAssessment( assessmentIds[0], liveFeedbackEnabled, @@ -86,19 +92,23 @@ const LiveFeedbackToggleButton: FC = (props) => {
{ setLiveFeedbackChecked(isChecked); setLiveFeedbackSettingsConfirmation(true); }} /> - {!forSpecificAssessment && ( + {!isSpecificAssessment && ( { initialValues, isKoditsuExamEnabled, isQuestionsValidForKoditsu, + isCourseCodaveriEnabled, modeSwitching, onSubmit, pulsegridUrl, @@ -100,13 +101,7 @@ const AssessmentForm = (props: AssessmentFormProps): JSX.Element => { getProgrammingQuestionsForAssessments(state, [assessmentId]), ); - const qnsWithLiveFeedbackEnabled = programmingQuestions.filter( - (question) => question.liveFeedbackEnabled, - ); - const hasNoProgrammingQuestions = programmingQuestions.length === 0; - const isSomeLiveFeedbackEnabled = - qnsWithLiveFeedbackEnabled.length < programmingQuestions.length; // Load all tabs if data is loaded, otherwise fall back to current assessment tab. const loadedTabs = tabs ?? watch('tabs'); @@ -848,17 +843,21 @@ const AssessmentForm = (props: AssessmentFormProps): JSX.Element => {
- {t(translations.toggleLiveFeedbackDescription, { - enabled: - hasNoProgrammingQuestions || isSomeLiveFeedbackEnabled, - })} + {t(translations.toggleLiveFeedbackDescription)} - {hasNoProgrammingQuestions && ( - + {(hasNoProgrammingQuestions || !isCourseCodaveriEnabled) && ( + )}
diff --git a/client/app/bundles/course/assessment/components/AssessmentForm/types.ts b/client/app/bundles/course/assessment/components/AssessmentForm/types.ts index 348013fed9a..35dce7bfb3e 100644 --- a/client/app/bundles/course/assessment/components/AssessmentForm/types.ts +++ b/client/app/bundles/course/assessment/components/AssessmentForm/types.ts @@ -38,6 +38,7 @@ export interface AssessmentFormProps initialValues?; isKoditsuExamEnabled: boolean; isQuestionsValidForKoditsu: boolean; + isCourseCodaveriEnabled?: boolean; disabled?: boolean; showPersonalizedTimelineFeatures?: boolean; randomizationAllowed?: boolean; diff --git a/client/app/bundles/course/assessment/pages/AssessmentEdit/AssessmentEditPage.jsx b/client/app/bundles/course/assessment/pages/AssessmentEdit/AssessmentEditPage.jsx index d023cead62a..ec821bb07f2 100644 --- a/client/app/bundles/course/assessment/pages/AssessmentEdit/AssessmentEditPage.jsx +++ b/client/app/bundles/course/assessment/pages/AssessmentEdit/AssessmentEditPage.jsx @@ -53,6 +53,7 @@ class AssessmentEditPage extends Component { render() { const { intl, + isCourseCodaveriEnabled, conditionAttributes, disabled, folderAttributes, @@ -94,6 +95,7 @@ class AssessmentEditPage extends Component { folderAttributes={folderAttributes} gamified={gamified} initialValues={initialValues} + isCourseCodaveriEnabled={isCourseCodaveriEnabled} isKoditsuExamEnabled={isKoditsuExamEnabled} isQuestionsValidForKoditsu={isQuestionsValidForKoditsu} modeSwitching={modeSwitching} @@ -128,6 +130,7 @@ AssessmentEditPage.propTypes = { initialValues: PropTypes.shape({}), isKoditsuExamEnabled: PropTypes.bool, isQuestionsValidForKoditsu: PropTypes.bool, + isCourseCodaveriEnabled: PropTypes.bool, // Whether to disable the inner form. disabled: PropTypes.bool, diff --git a/client/app/bundles/course/assessment/pages/AssessmentEdit/index.tsx b/client/app/bundles/course/assessment/pages/AssessmentEdit/index.tsx index b0d53febe51..c92b93584ec 100644 --- a/client/app/bundles/course/assessment/pages/AssessmentEdit/index.tsx +++ b/client/app/bundles/course/assessment/pages/AssessmentEdit/index.tsx @@ -63,6 +63,7 @@ const AssessmentEdit = (): JSX.Element => { ? DEFAULT_MONITORING_OPTIONS : undefined), }} + isCourseCodaveriEnabled={data.isCourseCodaveriEnabled} isKoditsuExamEnabled={data.isKoditsuExamEnabled} isQuestionsValidForKoditsu={data.isQuestionsValidForKoditsu} modeSwitching={data.mode_switching} diff --git a/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/AutogradedActionButtonsRow.tsx b/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/AutogradedActionButtonsRow.tsx index 68b8cd52435..d8469913869 100644 --- a/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/AutogradedActionButtonsRow.tsx +++ b/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/AutogradedActionButtonsRow.tsx @@ -27,7 +27,7 @@ const AutogradedActionButtonsRow: FC = (props) => { const submission = useAppSelector(getSubmission); const questions = useAppSelector(getQuestions); - const { questionIds } = assessment; + const { questionIds, isCourseCodaveriEnabled } = assessment; const { workflowState } = submission; const attempting = workflowState === workflowStates.Attempting; @@ -43,7 +43,8 @@ const AutogradedActionButtonsRow: FC = (props) => { {question.type === questionTypes.Programming && - question.liveFeedbackEnabled && ( + question.liveFeedbackEnabled && + isCourseCodaveriEnabled && ( )} diff --git a/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/NonAutogradedProgrammingActionButtonsRow.tsx b/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/NonAutogradedProgrammingActionButtonsRow.tsx index cf56a7f9e7e..4a9796cdafb 100644 --- a/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/NonAutogradedProgrammingActionButtonsRow.tsx +++ b/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/NonAutogradedProgrammingActionButtonsRow.tsx @@ -5,6 +5,7 @@ import { questionTypes, workflowStates, } from 'course/assessment/submission/constants'; +import { getAssessment } from 'course/assessment/submission/selectors/assessments'; import { getQuestions } from 'course/assessment/submission/selectors/questions'; import { getSubmission } from 'course/assessment/submission/selectors/submissions'; import { useAppSelector } from 'lib/hooks/store'; @@ -20,6 +21,7 @@ interface Props { const NonAutogradedProgrammingActionButtonsRow: FC = (props) => { const { questionId } = props; + const assessment = useAppSelector(getAssessment); const submission = useAppSelector(getSubmission); const questions = useAppSelector(getQuestions); @@ -30,6 +32,8 @@ const NonAutogradedProgrammingActionButtonsRow: FC = (props) => { const question = questions[questionId]; const { viewHistory } = question; + const { isCourseCodaveriEnabled } = assessment; + return ( !viewHistory && attempting && @@ -38,7 +42,7 @@ const NonAutogradedProgrammingActionButtonsRow: FC = (props) => { {question.autogradable && } - {question.liveFeedbackEnabled && ( + {question.liveFeedbackEnabled && isCourseCodaveriEnabled && ( )} diff --git a/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/button/ReevaluateButton.tsx b/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/button/ReevaluateButton.tsx index 9b75b241eea..8d8c768e6fb 100644 --- a/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/button/ReevaluateButton.tsx +++ b/client/app/bundles/course/assessment/submission/pages/SubmissionEditIndex/components/button/ReevaluateButton.tsx @@ -35,7 +35,7 @@ const ReevaluateButton: FC = (props) => { const dispatch = useAppDispatch(); - const { isCodaveriEnabled } = assessment; + const { isCourseCodaveriEnabled } = assessment; const question = questions[questionId]; const { answerId } = question; @@ -46,7 +46,7 @@ const ReevaluateButton: FC = (props) => { const shouldRender = question.type === questionTypes.Programming && - isCodaveriEnabled && + isCourseCodaveriEnabled && question.isCodaveri; const onGenerateFeedback = (): void => { diff --git a/client/app/bundles/course/assessment/submission/types.ts b/client/app/bundles/course/assessment/submission/types.ts index 83430871370..e6a8538e027 100644 --- a/client/app/bundles/course/assessment/submission/types.ts +++ b/client/app/bundles/course/assessment/submission/types.ts @@ -25,6 +25,7 @@ export interface AssessmentState { gamified: boolean; isCodaveriEnabled: boolean; isKoditsuEnabled: boolean; + isCourseCodaveriEnabled: boolean; liveFeedbackEnabled: boolean; passwordProtected: boolean; questionIds: number[];