diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:07:19 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:19:12 +0200 |
| commit | a3da1483a9e689846179159355badfec8073dbec (patch) | |
| tree | 770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /lib/models/eTask/Assignment.php | |
current code from svn, revision 62608
Diffstat (limited to 'lib/models/eTask/Assignment.php')
| -rw-r--r-- | lib/models/eTask/Assignment.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/models/eTask/Assignment.php b/lib/models/eTask/Assignment.php new file mode 100644 index 0000000..6320684 --- /dev/null +++ b/lib/models/eTask/Assignment.php @@ -0,0 +1,66 @@ +<?php + +namespace eTask; + +/** + * eTask conforming assignment definition. + * + * @property int id database column + * @property int test_id database column + * @property string range_type database column + * @property string range_id database column + * @property string type database column + * @property string start database column + * @property string end database column + * @property int active database column + * @property string options database column + * @property eTask\Test test belongs_to etask\Test + * @property SimpleORMapCollection attempts has_many etask\Attempt + * @property SimpleORMapCollection ranges has_many etask\AssignmentRange + * @property SimpleORMapCollection responses has_many etask\Response + * @property JSONArrayobject options serialized database column + */ +class Assignment extends \SimpleORMap +{ + use ConfigureTrait; + + /** + * @see SimpleORMap::configure + */ + protected static function configure($config = []) + { + $config['db_table'] = 'etask_assignments'; + + $config['relationTypes'] = self::configureClassNames($config); + + $config['belongs_to']['test'] = [ + 'class_name' => $config['relationTypes']['Test'], + 'foreign_key' => 'test_id' + ]; + + $config['has_many']['attempts'] = [ + 'class_name' => $config['relationTypes']['Attempt'], + 'assoc_foreign_key' => 'assignment_id', + 'on_delete' => 'delete', + 'on_store' => 'store' + ]; + + $config['has_many']['ranges'] = [ + 'class_name' => $config['relationTypes']['AssignmentRange'], + 'assoc_foreign_key' => 'assignment_id', + 'on_delete' => 'delete', + 'on_store' => 'store' + ]; + + $config['has_many']['responses'] = [ + 'class_name' => $config['relationTypes']['Response'], + 'assoc_foreign_key' => 'assignment_id', + 'on_delete' => 'delete', + 'on_store' => 'store' + ]; + + $config['serialized_fields']['options'] = 'JSONArrayObject'; + + parent::configure($config); + } +} |
