Skip to content

Commit

Permalink
chore(assessment): remove draft programming answer
Browse files Browse the repository at this point in the history
- the feature is no longer used by anyone
- it's rendered useless after our autosave feature takes place
- remove all isDraftAnswer from FE, and draft_answer from BE
- remove the column related to allow draft programming answer
- rake command to remove all non-current attempting programming answer to make the system consistent
  • Loading branch information
bivanalhar authored and cysjonathan committed Dec 11, 2024
1 parent 0d23ff2 commit 3b77d0d
Show file tree
Hide file tree
Showing 28 changed files with 34 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def assessment_params
:bonus_end_at, :published, :autograded, :show_mcq_mrq_solution, :show_private,
:show_evaluation, :use_public, :use_private, :use_evaluation, :has_personal_times,
:affects_personal_times, :block_student_viewing_after_submitted, :has_todo,
:allow_record_draft_answer, :time_limit, :is_koditsu_enabled]
:time_limit, :is_koditsu_enabled]
base_params += if autograded?
[:skippable, :allow_partial_submission, :show_mcq_answer]
else
Expand Down
4 changes: 0 additions & 4 deletions app/models/course/assessment/answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ def generate_live_feedback
actable.generate_live_feedback
end

def draft_answer?
attempting? && !current_answer?
end

protected

def finalise
Expand Down
26 changes: 6 additions & 20 deletions app/services/course/assessment/submission/update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def update_submission # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComple

answer = @submission.answers.includes(:actable).find { |a| a.id == answer_params[:id].to_i }

if answer && !update_answer(answer, answer_params)
logger.error("Failed to update answer #{answer.errors.inspect}")
answer.errors.messages.each do |attribute, message|
@submission.errors.add(attribute, message)
end
raise ActiveRecord::Rollback
next unless answer && !update_answer(answer, answer_params)

logger.error("Failed to update answer #{answer.errors.inspect}")
answer.errors.messages.each do |attribute, message|
@submission.errors.add(attribute, message)
end
raise ActiveRecord::Rollback
end
end

Expand All @@ -125,20 +125,6 @@ def update_submission # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComple
end
end

def attempt_draft_answer(answer)
return unless answer

reattempt_answer(answer, finalise: false) if should_attempt_draft_answer?(answer)
end

def should_attempt_draft_answer?(answer)
is_save_draft = update_submission_additional_params[:is_save_draft].to_s.downcase == 'true'
is_programming = answer.actable_type == Course::Assessment::Answer::Programming.name
assessment_save_draft_answer = @assessment.allow_record_draft_answer

is_save_draft && is_programming && assessment_save_draft_answer
end

def unsubmit?
params[:submission] && params[:submission][:unsubmit].present?
end
Expand Down
1 change: 0 additions & 1 deletion app/views/course/assessment/answers/_answer.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ json.questionId answer.question_id
json.questionType answer.question.question_type
json.createdAt answer.created_at&.iso8601
json.clientVersion answer.client_version
json.isDraftAnswer answer.draft_answer?

specific_answer = answer.specific
can_grade = can?(:grade, answer.submission)
Expand Down
2 changes: 1 addition & 1 deletion app/views/course/assessment/assessments/edit.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ json.attributes do
:skippable, :tabbed_view, :view_password, :session_password, :delayed_grade_publication, :tab_id,
:use_public, :use_private, :use_evaluation, :allow_partial_submission, :has_personal_times,
:affects_personal_times, :show_mcq_answer, :block_student_viewing_after_submitted, :has_todo,
:allow_record_draft_answer, :time_limit, :is_koditsu_enabled)
:time_limit, :is_koditsu_enabled)

# TODO: [PR#5491] Edit Assessment only changes time in the Default Timeline
json.start_at @assessment.start_at&.iso8601
Expand Down
1 change: 0 additions & 1 deletion app/views/course/assessment/assessments/show.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ if can_attempt && assessment.folder.materials.exists?
end

if can_observe
json.allowRecordDraftAnswer assessment.allow_record_draft_answer
json.showMcqMrqSolution assessment.show_mcq_mrq_solution
json.gradedTestCases display_graded_test_types(assessment)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,18 +575,6 @@ const AssessmentForm = (props: AssessmentFormProps): JSX.Element => {
sticksToNavbar={editing}
title={t(translations.answersAndTestCases)}
>
<Controller
control={control}
name="allow_record_draft_answer"
render={({ field, fieldState }): JSX.Element => (
<FormCheckboxField
disabled={disabled}
field={field}
fieldState={fieldState}
label={t(translations.allowRecordDraftAnswer)}
/>
)}
/>
<Controller
control={control}
name="skippable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ const translations = defineMessages({
id: 'course.assessment.AssessmentForm.calculateGradeWith',
defaultMessage: 'Calculate grade and EXP with',
},
allowRecordDraftAnswer: {
id: 'course.assessment.AssessmentForm.allowRecordDraftAnswer',
defaultMessage: 'Allow versioning of draft programming answer',
},
skippable: {
id: 'course.assessment.AssessmentForm.skippable',
defaultMessage: 'Allow to skip steps',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const validationSchema = yup.object({
has_todo: yup.bool(),
autograded: yup.bool(),
block_student_viewing_after_submitted: yup.bool(),
allow_record_draft_answer: yup.bool(),
skippable: yup.bool(),
allow_partial_submission: yup.bool(),
show_mcq_answer: yup.bool(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const INITIAL_VALUES = {
time_limit: null,
allow_partial_submission: false,
block_student_viewing_after_submitted: false,
allow_record_draft_answer: false,
delayed_grade_publication: false,
password_protected: false,
view_password: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ const AssessmentDetails = (props: AssessmentDetailsProps): JSX.Element => {

{assessment.permissions.canObserve && (
<>
<TableRow>
<TableCell variant="head">
{t(translations.allowRecordDraftAnswer)}
</TableCell>

<TableCell>
{assessment.allowRecordDraftAnswer ? '✅' : '❌'}
</TableCell>
</TableRow>

<TableRow>
<TableCell variant="head">
{t(translations.showMcqMrqSolution)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class NewAssessmentFormButton extends Component {
autograded: false,
is_koditsu_enabled: false,
block_student_viewing_after_submitted: false,
allow_record_draft_answer: false,
skippable: false,
allow_partial_submission: false,
show_mcq_answer: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ export default class PastProgrammingAnswer extends Component {
return (
<div>
<ProgrammingImportHistoryView historyAnswer={answer} />
<TestCaseView
answerId={answer.id}
isDraftAnswer={answer.isDraftAnswer}
viewHistory
/>
<TestCaseView answerId={answer.id} viewHistory />
</div>
);
}
Expand All @@ -33,11 +29,7 @@ export default class PastProgrammingAnswer extends Component {
return (
<div>
{file && <ReadOnlyEditor answerId={answer.id} file={file} />}
<TestCaseView
answerId={answer.id}
isDraftAnswer={answer.isDraftAnswer}
viewHistory
/>
<TestCaseView answerId={answer.id} viewHistory />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class PastAnswers extends Component {
return (
<MenuItem key={index} value={answer}>
{formatLongDateTime(answer.createdAt)}
{answer.isDraftAnswer && (
<>&nbsp;{intl.formatMessage(translations.draftAnswer)}</>
)}
</MenuItem>
);
};
Expand Down Expand Up @@ -100,10 +97,7 @@ class PastAnswers extends Component {
return (
<div key={answer.id}>
<Typography variant="h6">
{answer.isDraftAnswer
? intl.formatMessage(translations.savedAt)
: intl.formatMessage(translations.submittedAt)}
: {date}
{intl.formatMessage(translations.submittedAt)} : {date}
</Typography>
{this.getAnswersHistory(question, answer)}
<hr />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class VisibleTestCaseView extends Component {
);
}

renderTestCases(testCases, testCaseType, warn, isDraftAnswer) {
renderTestCases(testCases, testCaseType, warn) {
const {
collapsible,
testCases: { canReadTests },
Expand Down Expand Up @@ -277,10 +277,10 @@ export class VisibleTestCaseView extends Component {

return (
<Accordion
className={!isDraftAnswer && testCaseComponentClassName()}
className={testCaseComponentClassName()}
defaultExpanded={!collapsible}
disableGutters
icon={!isDraftAnswer && <TestCasesIndicatorChip />}
icon={<TestCasesIndicatorChip />}
id={testCaseType}
subtitle={
warn && <FormattedMessage {...translations.staffOnlyTestCases} />
Expand Down Expand Up @@ -326,7 +326,6 @@ export class VisibleTestCaseView extends Component {
testCases,
collapsible,
showStdoutAndStderr,
isDraftAnswer,
} = this.props;
if (!testCases) {
return null;
Expand All @@ -349,27 +348,20 @@ export class VisibleTestCaseView extends Component {
</Alert>
)}

{this.renderTestCases(
testCases.public_test,
'publicTestCases',
false,
isDraftAnswer,
)}
{this.renderTestCases(testCases.public_test, 'publicTestCases', false)}

{showPrivateTest &&
this.renderTestCases(
testCases.private_test,
'privateTestCases',
!showPrivateTestToStudents,
isDraftAnswer,
)}

{showEvaluationTest &&
this.renderTestCases(
testCases.evaluation_test,
'evaluationTestCases',
!showEvaluationTestToStudents,
isDraftAnswer,
)}

{showOutputStreams &&
Expand Down Expand Up @@ -412,11 +404,10 @@ VisibleTestCaseView.propTypes = {
stdout: PropTypes.string,
stderr: PropTypes.string,
}),
isDraftAnswer: PropTypes.bool,
};

function mapStateToProps({ assessments: { submission } }, ownProps) {
const { questionId, answerId, viewHistory, isDraftAnswer } = ownProps;
const { questionId, answerId, viewHistory } = ownProps;
let testCases;
let isAutograding;
if (viewHistory) {
Expand All @@ -437,7 +428,6 @@ function mapStateToProps({ assessments: { submission } }, ownProps) {
collapsible: viewHistory,
isAutograding,
testCases,
isDraftAnswer,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export const answerShape = PropTypes.shape({
file: PropTypes.object,
files: PropTypes.arrayOf(fileShape),
option_ids: PropTypes.arrayOf(PropTypes.number),
isDraftAnswer: PropTypes.bool,
createdAt: PropTypes.string,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default function (state = {}, action) {
...obj,
[answer.id]: {
...answer.fields,
isDraftAnswer: answer.isDraftAnswer,
createdAt: answer.createdAt,
},
}),
Expand All @@ -25,7 +24,6 @@ export default function (state = {}, action) {
...state,
[latestAnswer.id]: {
...latestAnswer.fields,
isDraftAnswer: latestAnswer.isDraftAnswer,
createdAt: latestAnswer.createdAt,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export interface QuestionHistory {
}

export type AnswerHistory = AnswerData & {
isDraftAnswer: boolean;
createdAt: Date;
};
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ const translations = defineMessages({
id: 'course.assessment.submission.attemptedAt',
defaultMessage: 'Attempted At',
},
savedAt: {
id: 'course.assessment.submission.savedAt',
defaultMessage: 'Saved At',
},
submittedAt: {
id: 'course.assessment.submission.submittedAt',
defaultMessage: 'Submitted At',
Expand Down Expand Up @@ -512,10 +508,6 @@ const translations = defineMessages({
id: 'course.assessment.submission.getPastAnswersFailure',
defaultMessage: 'Failed to load past answers',
},
draftAnswer: {
id: 'course.assessment.submission.draftAnswer',
defaultMessage: ' - Draft',
},
statistics: {
id: 'course.assessment.submission.statistics',
defaultMessage: 'Statistics',
Expand Down
1 change: 0 additions & 1 deletion client/app/bundles/course/assessment/submission/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ interface Topic {
export type TopicState = Record<number, Topic>;

export type HistoryAnswer = AnswerData & {
isDraftAnswer: boolean;
createdAt: Date;
};

Expand Down
4 changes: 0 additions & 4 deletions client/app/bundles/course/assessment/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ const translations = defineMessages({
id: 'course.assessment.show.baseExp',
defaultMessage: 'Base EXP',
},
allowRecordDraftAnswer: {
id: 'course.assessment.show.allowRecordDraftAnswer',
defaultMessage: 'Allow versioning of draft programming answer',
},
showMcqMrqSolution: {
id: 'course.assessment.show.showMcqMrqSolution',
defaultMessage: 'Show MCQ/MRQ solutions',
Expand Down
1 change: 0 additions & 1 deletion client/app/types/course/assessment/assessments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export interface AssessmentData extends AssessmentActionsData {
isKoditsuAssessmentEnabled?: boolean;
isSyncedWithKoditsu?: boolean;
isStudent: boolean;
allowRecordDraftAnswer?: boolean;
showMcqMrqSolution?: boolean;
gradedTestCases?: string;
skippable?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface AnswerBaseData {
questionId: number;
createdAt: string;
clientVersion: number | null;
isDraftAnswer: boolean;
grading: {
id: number; // Answer ID
grade?: number | null;
Expand Down
Loading

0 comments on commit 3b77d0d

Please sign in to comment.