예제 #1
0
 /**
  * For vanilla questions:
  *  If no 'uses', then edit the question text and return true.
  *  Otherwise, return false.
  * For custom questions:
  *  If no 'uses', then edit the question text.
  *  If 'uses', then create new custom.
  *  Return true.
  */
 public static function edit(MongoId $questionId, $text)
 {
     $question = QuestionModel::getById($questionId, ['vanilla' => 1, 'uses' => 1, 'recruiter' => 1]);
     extract($question);
     // Return false if question text already exists.
     if (!is_null(QuestionModel::getByExactText($text))) {
         return false;
     }
     if (count($uses) > 0) {
         if ($vanilla) {
             return false;
         } else {
             self::createCustom($text, $recruiter);
             return true;
         }
     }
     QuestionModel::editText($questionId, $text);
     return true;
 }