Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: Add question object base and array object (WIP)
- Loading branch information
1 parent
ef407bf
commit db0df44
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
application/core/questions/ArrayQuestionObject/ArrayQuestionObject.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
Yii::import('application.core.questions.QuestionObjectBase', true); | ||
|
||
class ArrayQuestionObject extends QuestionObjectBase | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
abstract class QuestionObjectBase | ||
{ | ||
/** | ||
* Specification for this array is in top of qanda helper. | ||
* @var array | ||
* @todo Rename to a more descriptive name | ||
*/ | ||
private $ia; | ||
|
||
/** | ||
* List of attributes is in questionHelper. | ||
* @var array | ||
*/ | ||
private $questionAttributes; | ||
|
||
/** | ||
* @var Question | ||
*/ | ||
private $questionModel; | ||
|
||
/** | ||
* Data used to create fieldmap | ||
* @var array | ||
*/ | ||
private $data; | ||
|
||
/** | ||
* @var TestQuestionObject | ||
*/ | ||
static private $instance = null; | ||
|
||
/** | ||
* @return TestQuestionObject | ||
*/ | ||
public static function getInstance() | ||
{ | ||
$inheritedClassName = get_called_class(); // Late static binding | ||
if (empty(self::$instance)) | ||
{ | ||
self::$instance = new $inheritedClassName(); | ||
} | ||
|
||
return self::$instance; | ||
} | ||
|
||
/** | ||
* Set data needed to create the fieldmap | ||
* @param array $data | ||
* @return void | ||
*/ | ||
public function setData(array $data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* Called from qanda_helper. | ||
* @param array $ia | ||
* @return void | ||
*/ | ||
public function setIa(array $ia) | ||
{ | ||
$this->ia = $ia; | ||
} | ||
} |