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

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