コード例 #1
0
 public static function createFromDataModel(VariableDeclaration $variableDeclaration)
 {
     $variable = parent::createFromDataModel($variableDeclaration);
     if ($variableDeclaration instanceof OutcomeDeclaration) {
         $variable->setViews($variableDeclaration->getViews());
         $variable->setNormalMaximum($variableDeclaration->getNormalMaximum());
         $variable->setNormalMinimum($variableDeclaration->getNormalMinimum());
         $variable->setMasteryValue($variableDeclaration->getMasteryValue());
         $variable->setLookupTable($variableDeclaration->getLookupTable());
         return $variable;
     } else {
         $msg = "OutcomeVariable::createFromDataModel only accept 'qtism\\data\\state\\OutcomeDeclaration' objects, '" . get_class($variableDeclaration) . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
コード例 #2
0
ファイル: TemplateVariable.php プロジェクト: nagyist/qti-sdk
 /**
  * Create a TemplateVariable object from its data model representation.
  *
  * @param \qtism\data\state\VariableDeclaration $variableDeclaration
  * @throws \InvalidArgumentException
  * @return \qtism\runtime\common\TemplateVariable
  */
 public static function createFromDataModel(VariableDeclaration $variableDeclaration)
 {
     $variable = parent::createFromDataModel($variableDeclaration);
     if ($variableDeclaration instanceof TemplateDeclaration) {
         $variable->setParamVariable($variableDeclaration->isParamVariable());
         $variable->setMathVariable($variableDeclaration->isMathVariable());
         return $variable;
     } else {
         $msg = "TemplateVariable::createFromDataModel only accept 'qtism\\data\\state\\TemplateVariable' objects, '" . get_class($variableDeclaration) . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }
コード例 #3
0
 public static function createFromDataModel(VariableDeclaration $variableDeclaration)
 {
     $variable = parent::createFromDataModel($variableDeclaration);
     if ($variableDeclaration instanceof ResponseDeclaration) {
         $variable->setMapping($variableDeclaration->getMapping());
         $variable->setAreaMapping($variableDeclaration->getAreaMapping());
         $dataModelCorrectResponse = $variableDeclaration->getCorrectResponse();
         if (!empty($dataModelCorrectResponse)) {
             $baseType = $variable->getBaseType();
             $cardinality = $variable->getCardinality();
             $dataModelValues = $dataModelCorrectResponse->getValues();
             $correctResponse = static::dataModelValuesToRuntime($dataModelValues, $baseType, $cardinality);
             $variable->setCorrectResponse($correctResponse);
         }
         return $variable;
     } else {
         $msg = "ResponseVariable::createFromDataModel only accept 'qtism\\data\\state\\ResponseDeclaration' objects, '" . get_class($variableDeclaration) . "' given.";
         throw new InvalidArgumentException($msg);
     }
 }