server/api/exams/exams.controller.js
/**
 * Delete a comment on an exam. The request url should contain the following:
 * - index: the index of the comment to delete
 *
 * @param {Koa context} ctx
 * @returns The updated exam
 */
Delete a comment on an exam. The request url should contain the following:
- index: the index of the comment to delete

@param {Koa context} ctx
@returns The updated exam
Delete a comment on an exam . The request url should contain the following : - index : the index of the comment to delete @param { Koa context } ctx @returns The updated exam
async function deleteComment (ctx) {
  const examID = ctx.params.examID;
  const index = ctx.params.commentIndex;
  ctx.state.exam.comments.splice(index, 1);
  try {
    await ctx.state.exam.save();
  } catch (e) {
    logger.error(
      `Failed to save exam ${examID} for ${ctx.state.user.rcs_id}: ${e}`
    );
    return ctx.badRequest('There was an error adding the comment.');
  }
  ctx.ok({ updatedExam: ctx.state.exam });
}
async function deleteComment ( ctx ) { const examID = ctx . params . examID ; const index = ctx . params . commentIndex ; ctx . state . exam . comments . splice ( index , 1 ) ; try { await ctx . state . exam . save ( ) ; } catch ( e ) { logger . error ( ` ${ examID } ${ ctx . state . user . rcs_id } ${ e } ` ) ; return ctx . badRequest ( 'There was an error adding the comment.' ) ; } ctx . ok ( { updatedExam : ctx . state . exam } ) ; }
Delete a comment on an exam.
Delete a comment on an exam .
// Remove the comment by its index