/** * Create a new AssessmentItemSession object. * * * The built-in response variables 'numAttempts' and 'duration' will be created and set up with appropriate default values, respectively Integer(0) and Duration('PT0S'). * * The built-in outcome variable 'completionStatus' will be created and set up with an appropriate default value of String('not_attempted'). * * The item session is set up with a default ItemSessionControl object. If you want a specific ItemSessionControl object to rule the session, use the setItemSessionControl() method. * * The item session is set up with no TimeLimits object. If you want to set a a specfici TimeLimits object to rule the session, use the setTimeLimits() method. * * @param \qtism\data\IAssessmentItem $assessmentItem The description of the item that the session handles. * @param integer $navigationMode (optional) A value from the NavigationMode enumeration. * @param integer $submissionMode (optional) A value from the SubmissionMode enumeration. * @throws \InvalidArgumentException If $navigationMode or $submission is not a value from the NavigationMode/SubmissionMode enumeration. * @see \qtism\runtime\tests\AssessmentItemSession::setItemSessionControl() The setItemSessionControl() method. * @see \qtism\runtime\tests\AssessmentItemSession::setTimeLimits() The setTimeLimits() method. */ public function __construct(IAssessmentItem $assessmentItem, $navigationMode = NavigationMode::LINEAR, $submissionMode = SubmissionMode::INDIVIDUAL) { parent::__construct(); $this->setAssessmentItem($assessmentItem); $this->setItemSessionControl(new ItemSessionControl()); $this->setNavigationMode($navigationMode); $this->setSubmissionMode($submissionMode); // -- Create the built-in response variables. $this->setVariable(new ResponseVariable('numAttempts', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(0))); $this->setVariable(new ResponseVariable('duration', Cardinality::SINGLE, BaseType::DURATION, new QtiDuration('PT0S'))); // -- Create the built-in outcome variables. $this->setVariable(new OutcomeVariable('completionStatus', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier(self::COMPLETION_STATUS_NOT_ATTEMPTED))); // -- Create item specific outcome, response and template variables. foreach ($assessmentItem->getOutcomeDeclarations() as $outcomeDeclaration) { $outcomeVariable = OutcomeVariable::createFromDataModel($outcomeDeclaration); $this->setVariable($outcomeVariable); } foreach ($this->getAssessmentItem()->getResponseDeclarations() as $responseDeclaration) { $responseVariable = ResponseVariable::createFromDataModel($responseDeclaration); $this->setVariable($responseVariable); } foreach ($assessmentItem->getTemplateDeclarations() as $templateDeclaration) { $templateVariable = TemplateVariable::createFromDataModel($templateDeclaration); $this->setVariable($templateVariable); } // -- Perform choice shuffling for interactions by creating the Shuffling States for this item session. $shufflingStates = new ShufflingCollection(); foreach ($assessmentItem->getShufflings() as $shuffling) { $shufflingStates[] = $shuffling->shuffle(); } $this->setShufflingStates($shufflingStates); }
/** * Create a new AssessmentTestSession object. * * @param AssessmentTest $assessmentTest The AssessmentTest object which represents the assessmenTest the context belongs to. * @param AbstractSessionManager $sessionManager The manager to be used to create new AssessmentItemSession objects. * @param Route $route The sequence of items that has to be taken for the session. */ public function __construct(AssessmentTest $assessmentTest, AbstractSessionManager $sessionManager, Route $route) { parent::__construct(); $this->setAssessmentTest($assessmentTest); $this->setSessionManager($sessionManager); $this->setRoute($route); $this->setAssessmentItemSessionStore(new AssessmentItemSessionStore()); $this->setLastOccurenceUpdate(new SplObjectStorage()); $this->setPendingResponseStore(new PendingResponseStore()); $durationStore = new DurationStore(); $this->setDurationStore($durationStore); // Take the outcomeDeclaration objects of the global scope. // Instantiate them with their defaults. foreach ($this->getAssessmentTest()->getOutcomeDeclarations() as $globalOutcome) { $variable = OutcomeVariable::createFromDataModel($globalOutcome); $variable->applyDefaultValue(); $this->setVariable($variable); } $this->setSessionId('no_session_id'); $this->setState(AssessmentTestSessionState::INITIAL); }
/** * Create a new AssessmentItemSession object. * * * Unless provided in the $variables array, the built-in response/outcome variables 'numAttempts', 'duration' and * 'completionStatus' will be created and set to an appropriate default value automatically. * * * The AssessmentItemSession object is set up with a default ItemSessionControl object. If you want a specific ItemSessionControl object to rule the session, use the setItemSessionControl() method. * * @param IAssessmentItem $assessmentItem The description of the item that the session handles. * @param AbstractSessionManager $sessionManager * @param integer $navigationMode The current navigation mode. Default is LINEAR. * @param integer $submissionMode The current submission mode. Default is INDIVIDUAL. * @throws InvalidArgumentException If $navigationMode is not a value from the NavigationMode enumeration. */ public function __construct(IAssessmentItem $assessmentItem, AbstractSessionManager $sessionManager, $navigationMode = NavigationMode::LINEAR, $submissionMode = SubmissionMode::INDIVIDUAL) { parent::__construct(); $this->setAssessmentItem($assessmentItem); $this->setNavigationMode($navigationMode); $this->setSubmissionMode($submissionMode); $this->setItemSessionControl(new ItemSessionControl()); $this->setSessionManager($sessionManager); // -- Create the built-in response variables. $this->setVariable(new ResponseVariable('numAttempts', Cardinality::SINGLE, BaseType::INTEGER, new Integer(0))); $this->setVariable(new ResponseVariable('duration', Cardinality::SINGLE, BaseType::DURATION, new Duration('PT0S'))); // -- Create the built-in outcome variables. $this->setVariable(new OutcomeVariable('completionStatus', Cardinality::SINGLE, BaseType::IDENTIFIER, new Identifier(self::COMPLETION_STATUS_NOT_ATTEMPTED))); }