You are here

public function OpignoTincanQuestionTypeQuestion::validateNode in Opigno TinCan Question Type 7

Provides validation for question before it is created.

When a new question is created and initially submited, this is called to validate that the settings are acceptable.

Parameters

array $form: The processed form.

File

includes/opigno_tincan_question_type.question.inc, line 136
This file contains the class OpignoTincanQuestionTypeQuestion.

Class

OpignoTincanQuestionTypeQuestion
This class goal is to provide specific TinCan question information.

Code

public function validateNode(array &$form) {
  $file = file_load($form['file']['#value']['fid']);
  if ($file && $file->status != FILE_STATUS_PERMANENT) {
    if ($this
      ->unzipPackage($file)) {
      $package_info = self::getInfoFromExtractedPackage($file);
      if ($package_info === FALSE) {
        form_set_error('file', t('The package does not contain the activity ID or the launch file'));
      }
      else {
        $_SESSION[self::SESSIONKEY_FILE] = $form['file']['#value']['fid'];
      }
    }
    else {
      form_set_error('file', t('Unable to open the archive'));
    }
  }
}