app/models/annotation.rb
# check if the submission file is associated with a remark result or a released result
check if the submission file is associated with a remark result or a released result
check if the submission file is associated with a remark result or a released result
def check_if_released
    annotation_results = result.submission.results
    return if is_remark && annotation_results.where.not(remark_request_submitted_at: nil)
                                             .where('results.released_to_students': false)
    return if annotation_results.where('results.released_to_students': true).empty? &&
              annotation_results.where.not(remark_request_submitted_at: nil).empty?
    errors.add(:base, 'Cannot create/destroy annotation once results are released.')
    throw(:abort)
  end
def check_if_released annotation_results = result . submission . results return if is_remark && annotation_results . where . not ( remark_request_submitted_at : nil ) . where ( 'results.released_to_students' : false ) return if annotation_results . where ( 'results.released_to_students' : true ) . empty? && annotation_results . where . not ( remark_request_submitted_at : nil ) . empty? errors . add ( :base , 'Cannot create/destroy annotation once results are released.' ) throw ( :abort ) end
check if the submission file is associated with a remark result or a released result
check if the submission file is associated with a remark result or a released result