/**
  * Transmit a test-level QtiSm Runtime Variable to the target Result Server as a test result.
  * 
  * @param mixed $variable An OutcomeVariable object to be transmitted to the target Result Server.
  * @param string $transmissionId A unique identifier that identifies uniquely the visited test.
  * @param string $testUri An optional URL that identifies uniquely the test the $variable comes from.
  */
 public function transmitTestVariable($variable, $transmissionId, $testUri = '')
 {
     $resultVariable = new taoResultServer_models_classes_OutcomeVariable();
     $resultVariable->setIdentifier($variable->getIdentifier());
     $resultVariable->setBaseType(BaseType::getNameByConstant($variable->getBaseType()));
     $resultVariable->setCardinality(Cardinality::getNameByConstant($variable->getCardinality()));
     $value = $variable->getValue();
     $resultVariable->setValue(self::transformValue($value));
     try {
         $this->getResultServer()->storeTestVariable($testUri, $resultVariable, $transmissionId);
     } catch (Exception $e) {
         $msg = "An error occured while transmitting a Response Variable to the target result server.";
         $code = taoQtiCommon_helpers_ResultTransmissionException::OUTCOME;
         throw new taoQtiCommon_helpers_ResultTransmissionException($msg, $code);
     }
 }
Exemplo n.º 2
0
 // store results value (id, test taker, delivery)
 $deliverIdentifier = "myCoolId#" . $i . $time_start;
 $rs->storeRelatedTestTaker($deliverIdentifier, "MyTestTaker#" . $i);
 $rs->storeRelatedDelivery($deliverIdentifier, "MyDelivery#" . $i);
 //        $deliveryResult = $rs->storeDeliveryResult($deliverIdentifier);
 //        $rs->storeTestTaker($deliveryResult, "MyTestTaker#".$i);
 //        $rs->storeDelivery($deliveryResult,"MyDelivery#".$i);
 $test = "myTestid" . $i;
 // Create ItemVariables then store them
 for ($j = 0; $j < 10; $j++) {
     if ($j < 3) {
         $itemVariable = new taoResultServer_models_classes_OutcomeVariable();
         $itemVariable->setNormalMaximum("123" . $i . $j);
         $itemVariable->setNormalMinimum("Maximum" . $i . $j);
         $itemVariable->setValue("MyValue" . $i . $j);
         $itemVariable->setIdentifier("identifier" . $i . $j);
         $itemVariable->setCardinality("single");
         $itemVariable->setBaseType("float");
     } else {
         $itemVariable = new taoResultServer_models_classes_ResponseVariable();
         $itemVariable->setCandidateResponse("[Jerome Awesome]");
         $itemVariable->setCorrectResponse("[nop,plop]");
         $itemVariable->setIdentifier("identifier" . $i . $j);
         $itemVariable->setCardinality("single");
         $itemVariable->setBaseType("pair");
     }
     $callIdItem = "An identifier of the execution of an item occurence for a test taker#" . $j;
     $item = "anotherId#" . $j;
     $rs->storeItemVariable($deliverIdentifier, $test, $item, $itemVariable, $callIdItem);
     //            $rs->storeItemVariable($deliveryResult, $test, $item, $itemVariable, $callIdItem);
 }
 public function testStoreTestVariable()
 {
     $deliveryResultIdentifier = "MyDeliveryResultIdentifier#1";
     $test = "MyGreatTest#3";
     $callId = "MyCallId#3";
     $testVariable = new \taoResultServer_models_classes_OutcomeVariable();
     $testVariable->setBaseType('float');
     $testVariable->setCardinality('multiple');
     $testVariable->setEpoch(microtime());
     $testVariable->setIdentifier('TestIdentifier');
     $testVariable->setValue('MyValue');
     $this->instance->storeTestVariable($deliveryResultIdentifier, $test, $testVariable, $callId);
     $tmp = $this->instance->getVariable($callId, 'TestIdentifier');
     $object = array_shift($tmp)[0];
     $this->assertEquals($test, $object->test);
     $this->assertNull($object->item);
     $this->assertEquals('float', $object->variable->getBaseType());
     $this->assertEquals('multiple', $object->variable->getCardinality());
     $this->assertEquals('TestIdentifier', $object->variable->getIdentifier());
     $this->assertEquals('MyValue', $object->variable->getValue());
     $this->assertInstanceOf('taoResultServer_models_classes_OutcomeVariable', $object->variable);
     $this->assertEquals('float', $this->instance->getVariableProperty($object->uri, 'baseType'));
     $this->assertEquals('multiple', $this->instance->getVariableProperty($object->uri, 'cardinality'));
     $this->assertEquals('TestIdentifier', $this->instance->getVariableProperty($object->uri, 'identifier'));
     $this->assertEquals('MyValue', $this->instance->getVariableProperty($object->uri, 'value'));
 }
 /**
  * @author  "Patrick Plichart, <*****@*****.**>"
  */
 public function storeItemVariableSet()
 {
     $variables = array();
     $item = $this->hasRequestParameter("itemId") ? $this->getRequestParameter("itemId") : "undefined";
     $callIdItem = $this->hasRequestParameter("serviceCallId") ? $this->getRequestParameter("serviceCallId") : "undefined";
     $test = $this->hasRequestParameter("testId") ? $this->getRequestParameter("testId") : "undefined";
     if ($this->hasRequestParameter("outcomeVariables")) {
         $outcomeVariables = $this->getRequestParameter("outcomeVariables");
         foreach ($outcomeVariables as $variableName => $outcomeValue) {
             $outComeVariable = new taoResultServer_models_classes_OutcomeVariable();
             //$outComeVariable->setBaseType("int");
             $outComeVariable->setCardinality("single");
             $outComeVariable->setIdentifier($variableName);
             $outComeVariable->setValue($outcomeValue);
             $variables[] = $outComeVariable;
         }
     }
     if ($this->hasRequestParameter("responseVariables")) {
         $responseVariables = $this->getRequestParameter("responseVariables");
         foreach ($responseVariables as $variableName => $responseValue) {
             $responseVariable = new taoResultServer_models_classes_ResponseVariable();
             //$responseVariable->setBaseType("int");
             //$responseVariable->setCardinality("single");
             $responseVariable->setIdentifier($variableName);
             $responseVariable->setCandidateResponse($responseValue);
             //$responseVariable->setCorrectResponse(true);
             $variables[] = $responseVariable;
         }
     }
     if ($this->hasRequestParameter("traceVariables")) {
         $traceVariables = $this->getRequestParameter("outcomeVariables");
         foreach ($traceVariables as $variableName => $traceValue) {
             $traceVariable = new taoResultServer_models_classes_TraceVariable();
             //$outComeVariable->setBaseType("int");
             $traceVariable->setIdentifier($variableName);
             $traceVariable->setTrace($traceValue);
             $variables[] = $traceVariable;
         }
     }
     try {
         $data = $this->service->storeItemVariableSet($test, $item, $variables, $callIdItem);
     } catch (exception $e) {
         $this->returnFailure($e);
     }
     return $this->returnSuccess($data);
 }