You are here

public function ScaleQuestion::saveNodeProperties in Quiz 8.4

Implementation of saveNodeProperties

Overrides QuizQuestion::saveNodeProperties

See also

QuizQuestion#saveNodeProperties()

File

question_types/scale/lib/Drupal/scale/ScaleQuestion.php, line 40
The main classes for the short answer question type.

Class

ScaleQuestion
Extension of QuizQuestion.

Namespace

Drupal\scale

Code

public function saveNodeProperties($is_new = FALSE) {
  $is_new_node = $is_new || $this->node
    ->isNewRevision() == 1;
  $answer_collection_id = $this
    ->saveAnswerCollection($is_new_node);

  // Save the answer collection as a preset if the save preset option is checked
  if ($this->node->save == 1) {
    $this
      ->setPreset($answer_collection_id);
  }
  if ($is_new_node) {
    $id = db_insert('quiz_scale_node_properties')
      ->fields(array(
      'nid' => $this->node
        ->id(),
      'vid' => $this->node
        ->getRevisionId(),
      'answer_collection_id' => $answer_collection_id,
    ))
      ->execute();
  }
  else {
    db_update('quiz_scale_node_properties')
      ->fields(array(
      'answer_collection_id' => $answer_collection_id,
    ))
      ->condition('nid', $this->node
      ->id())
      ->condition('vid', $this->node
      ->getRevisionId())
      ->execute();
  }
}