You are here

public function ScaleQuestion::saveNodeProperties in Quiz 7.4

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::saveNodeProperties()
  2. 8.5 question_types/quiz_scale/src/Plugin/quiz/QuizQuestion/ScaleQuestion.php \ScaleQuestion::saveNodeProperties()
  3. 6.4 question_types/scale/scale.classes.inc \ScaleQuestion::saveNodeProperties()
  4. 7.6 question_types/scale/scale.classes.inc \ScaleQuestion::saveNodeProperties()
  5. 7 question_types/scale/scale.classes.inc \ScaleQuestion::saveNodeProperties()
  6. 7.5 question_types/scale/scale.classes.inc \ScaleQuestion::saveNodeProperties()

Implementation of saveNodeProperties

Overrides QuizQuestion::saveNodeProperties

See also

QuizQuestion#saveNodeProperties()

File

question_types/scale/scale.classes.inc, line 47
The main classes for the scale question type.

Class

ScaleQuestion
Extension of QuizQuestion.

Code

public function saveNodeProperties($is_new = FALSE) {
  $is_new_node = $is_new || $this->node->revision == 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->nid,
      'vid' => $this->node->vid,
      '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->nid)
      ->condition('vid', $this->node->vid)
      ->execute();
  }
}