You are here

function CourseObjectPollFulfillment::delete in Course 8.3

Same name and namespace in other branches
  1. 8.2 modules/course_poll/src/Course/Object/CourseObjectPollFulfillment.php \Drupal\course_poll\Course\Object\CourseObjectPollFulfillment::delete()

Remove poll votes for this user.

File

modules/course_poll/src/Course/Object/CourseObjectPollFulfillment.php, line 12

Class

CourseObjectPollFulfillment

Namespace

Drupal\course_poll\Course\Object

Code

function delete() {
  $account = Drupal\user\Entity\User::load($this->uid);
  \Drupal::database()
    ->delete('poll_vote')
    ->condition('nid', $this
    ->getCourseObject()
    ->getInstanceId())
    ->condition('uid', $account->uid)
    ->execute();
  db_update('poll_choice')
    ->expression('chvotes', 'chvotes - 1')
    ->condition('chid', $this
    ->getOption('instance'))
    ->execute();
  parent::delete();
}