Skip to content

Commit

Permalink
refactor(live_feedback): settings when codaveri is disabled for course
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
bivanalhar committed Oct 28, 2024
1 parent 74a4777 commit 089b1e3
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 41 deletions.
1 change: 1 addition & 0 deletions app/models/course/assessment/answer/programming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/views/course/assessment/assessments/edit.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ import CodaveriSettingsChip from '../CodaveriSettingsChip';
interface LiveFeedbackToggleButtonProps {
assessmentIds: number[];
for: string;
forSpecificAssessment?: boolean;
isSpecificAssessment?: boolean;
isCourseCodaveriEnabled?: boolean;
}

const LiveFeedbackToggleButton: FC<LiveFeedbackToggleButtonProps> = (props) => {
const { assessmentIds, for: title, forSpecificAssessment } = props;
const {
assessmentIds,
for: title,
isSpecificAssessment,
isCourseCodaveriEnabled,
} = props;
const { t } = useTranslation();

const dispatch = useAppDispatch();
Expand All @@ -44,7 +50,7 @@ const LiveFeedbackToggleButton: FC<LiveFeedbackToggleButtonProps> = (props) => {
const updateLiveFeedbackEnabled = (
liveFeedbackEnabled: boolean,
): Promise<void> =>
forSpecificAssessment
isSpecificAssessment
? updateLiveFeedbackForAllQuestionsInAssessment(
assessmentIds[0],
liveFeedbackEnabled,
Expand Down Expand Up @@ -86,19 +92,23 @@ const LiveFeedbackToggleButton: FC<LiveFeedbackToggleButtonProps> = (props) => {
<div>
<Switch
checked={
hasNoProgrammingQuestions
hasNoProgrammingQuestions || !isCourseCodaveriEnabled
? false
: qnsWithLiveFeedbackEnabled.length ===
programmingQuestions.length
}
color="primary"
disabled={hasNoProgrammingQuestions || isLiveFeedbackUpdating}
disabled={
hasNoProgrammingQuestions ||
!isCourseCodaveriEnabled ||
isLiveFeedbackUpdating
}
onChange={(_, isChecked): void => {
setLiveFeedbackChecked(isChecked);
setLiveFeedbackSettingsConfirmation(true);
}}
/>
{!forSpecificAssessment && (
{!isSpecificAssessment && (
<CodaveriSettingsChip
assessmentIds={assessmentIds}
for="live_feedback"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const AssessmentForm = (props: AssessmentFormProps): JSX.Element => {
initialValues,
isKoditsuExamEnabled,
isQuestionsValidForKoditsu,
isCourseCodaveriEnabled,
modeSwitching,
onSubmit,
pulsegridUrl,
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -848,17 +843,21 @@ const AssessmentForm = (props: AssessmentFormProps): JSX.Element => {
<LiveFeedbackToggleButton
assessmentIds={[assessmentId]}
for={title}
forSpecificAssessment
isCourseCodaveriEnabled={isCourseCodaveriEnabled}
isSpecificAssessment
/>
<div>
<Typography className="mt-3" variant="body1">
{t(translations.toggleLiveFeedbackDescription, {
enabled:
hasNoProgrammingQuestions || isSomeLiveFeedbackEnabled,
})}
{t(translations.toggleLiveFeedbackDescription)}
</Typography>
{hasNoProgrammingQuestions && (
<InfoLabel label={t(translations.noProgrammingQuestion)} />
{(hasNoProgrammingQuestions || !isCourseCodaveriEnabled) && (
<InfoLabel
label={
!isCourseCodaveriEnabled
? t(translations.isCourseCodaveriDisabled)
: t(translations.noProgrammingQuestion)
}
/>
)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface AssessmentFormProps
initialValues?;
isKoditsuExamEnabled: boolean;
isQuestionsValidForKoditsu: boolean;
isCourseCodaveriEnabled?: boolean;
disabled?: boolean;
showPersonalizedTimelineFeatures?: boolean;
randomizationAllowed?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AssessmentEditPage extends Component {
render() {
const {
intl,
isCourseCodaveriEnabled,
conditionAttributes,
disabled,
folderAttributes,
Expand Down Expand Up @@ -94,6 +95,7 @@ class AssessmentEditPage extends Component {
folderAttributes={folderAttributes}
gamified={gamified}
initialValues={initialValues}
isCourseCodaveriEnabled={isCourseCodaveriEnabled}
isKoditsuExamEnabled={isKoditsuExamEnabled}
isQuestionsValidForKoditsu={isQuestionsValidForKoditsu}
modeSwitching={modeSwitching}
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const AutogradedActionButtonsRow: FC<Props> = (props) => {
const submission = useAppSelector(getSubmission);
const questions = useAppSelector(getQuestions);

const { questionIds } = assessment;
const { questionIds, isCourseCodaveriEnabled } = assessment;
const { workflowState } = submission;

const attempting = workflowState === workflowStates.Attempting;
Expand All @@ -43,7 +43,8 @@ const AutogradedActionButtonsRow: FC<Props> = (props) => {
<ContinueButton onContinue={handleNext} stepIndex={stepIndex} />
<Box sx={{ flex: '1', width: '100%' }} />
{question.type === questionTypes.Programming &&
question.liveFeedbackEnabled && (
question.liveFeedbackEnabled &&
isCourseCodaveriEnabled && (
<LiveFeedbackButton questionId={questionId} />
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -20,6 +21,7 @@ interface Props {
const NonAutogradedProgrammingActionButtonsRow: FC<Props> = (props) => {
const { questionId } = props;

const assessment = useAppSelector(getAssessment);
const submission = useAppSelector(getSubmission);
const questions = useAppSelector(getQuestions);

Expand All @@ -30,6 +32,8 @@ const NonAutogradedProgrammingActionButtonsRow: FC<Props> = (props) => {
const question = questions[questionId];
const { viewHistory } = question;

const { isCourseCodaveriEnabled } = assessment;

return (
!viewHistory &&
attempting &&
Expand All @@ -38,7 +42,7 @@ const NonAutogradedProgrammingActionButtonsRow: FC<Props> = (props) => {
<ResetProgrammingAnswerButton questionId={questionId} />
{question.autogradable && <RunCodeButton questionId={questionId} />}
<Box sx={{ flex: '1', width: '100%' }} />
{question.liveFeedbackEnabled && (
{question.liveFeedbackEnabled && isCourseCodaveriEnabled && (
<LiveFeedbackButton questionId={questionId} />
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ReevaluateButton: FC<Props> = (props) => {

const dispatch = useAppDispatch();

const { isCodaveriEnabled } = assessment;
const { isCourseCodaveriEnabled } = assessment;

const question = questions[questionId];
const { answerId } = question;
Expand All @@ -46,7 +46,7 @@ const ReevaluateButton: FC<Props> = (props) => {

const shouldRender =
question.type === questionTypes.Programming &&
isCodaveriEnabled &&
isCourseCodaveriEnabled &&
question.isCodaveri;

const onGenerateFeedback = (): void => {
Expand Down
1 change: 1 addition & 0 deletions client/app/bundles/course/assessment/submission/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface AssessmentState {
gamified: boolean;
isCodaveriEnabled: boolean;
isKoditsuEnabled: boolean;
isCourseCodaveriEnabled: boolean;
liveFeedbackEnabled: boolean;
passwordProtected: boolean;
questionIds: number[];
Expand Down

0 comments on commit 089b1e3

Please sign in to comment.