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 b530f735800..4bb1930ebbb 100644 --- a/app/views/course/assessment/assessments/edit.json.jbuilder +++ b/app/views/course/assessment/assessments/edit.json.jbuilder @@ -27,6 +27,7 @@ end json.mode_switching @assessment.allow_mode_switching? json.gamified current_course.gamified? +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 756b99b41e7..8ffef0c2058 100644 --- a/app/views/course/assessment/submission/submissions/edit.json.jbuilder +++ b/app/views/course/assessment/submission/submissions/edit.json.jbuilder @@ -24,7 +24,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/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 && ( { gamified, folderAttributes, initialValues, + isCourseCodaveriEnabled, modeSwitching, onSubmit, pulsegridUrl, @@ -87,13 +88,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'); @@ -981,17 +976,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 dc6fb3ab5f5..dbe003af4d0 100644 --- a/client/app/bundles/course/assessment/components/AssessmentForm/types.ts +++ b/client/app/bundles/course/assessment/components/AssessmentForm/types.ts @@ -36,6 +36,7 @@ export interface AssessmentFormProps onSubmit: (data: FieldValues, setError: UseFormSetError) => void; initialValues?; + 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 f54f1c13a7f..998a749c112 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, @@ -92,6 +93,7 @@ class AssessmentEditPage extends Component { folderAttributes={folderAttributes} gamified={gamified} initialValues={initialValues} + isCourseCodaveriEnabled={isCourseCodaveriEnabled} modeSwitching={modeSwitching} monitoringEnabled={monitoringEnabled} onSubmit={this.onFormSubmit} @@ -122,6 +124,7 @@ AssessmentEditPage.propTypes = { conditionAttributes: achievementTypesConditionAttributes, // A set of assessment attributes: {:id , :title, etc}. initialValues: PropTypes.shape({}), + 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 4de4e32e1b1..ec472204974 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} modeSwitching={data.mode_switching} monitoringEnabled={data.monitoring_component_enabled} pulsegridUrl={data.monitoring_url} 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 6b3f2a34670..57955a29781 100644 --- a/client/app/bundles/course/assessment/submission/types.ts +++ b/client/app/bundles/course/assessment/submission/types.ts @@ -23,7 +23,7 @@ export interface AssessmentState { url: string; }[]; gamified: boolean; - isCodaveriEnabled: boolean; + isCourseCodaveriEnabled: boolean; liveFeedbackEnabled: boolean; passwordProtected: boolean; questionIds: number[];