You are here

public function LongAnswerQuestion::save in Quiz 6.3

Same name and namespace in other branches
  1. 6.6 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::save()
  2. 6.5 question_types/long_answer/long_answer.classes.inc \LongAnswerQuestion::save()

Responsible for handling insert/update of question-specific data. This is typically called from within the Node API, so there is no need to save the node. This function is only responsible for saving data specific to the implement ation.

The $is_new flag is set to TRUE whenever the node is being initially created.

A save function is required to handle the following three situations:

  • A new node is created ($is_new is TRUE)
  • A new node *revision* is created ($is_new is NOT set, because the node itself is not new).
  • An existing node revision is modified.

Parameters

$is_new: TRUE when the node is initially created.

Overrides QuizQuestion::save

File

question_types/long_answer/long_answer.classes.inc, line 24
Long answer classes.

Class

LongAnswerQuestion
Implementation of QuizQuestion.

Code

public function save($is_new = FALSE) {
  if (!isset($this->node->feedback)) {
    $this->node->feedback = '';
  }
  if ($is_new || $this->node->revision == 1) {
    $sql = 'INSERT INTO {quiz_long_answer_node_properties} (nid, vid, maximum_score) VALUES (%d, %d, %d)';
    db_query($sql, $this->node->nid, $this->node->vid, $this->node->maximum_score);
  }
  else {
    $sql = 'UPDATE {quiz_long_answer_node_properties} SET maximum_score = %d WHERE nid = %d AND vid = %d';
    db_query($sql, $this->node->maximum_score, $this->node->nid, $this->node->vid);
  }
}