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/Attempt.php | |
current code from svn, revision 62608
Diffstat (limited to 'lib/models/eTask/Attempt.php')
| -rw-r--r-- | lib/models/eTask/Attempt.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/models/eTask/Attempt.php b/lib/models/eTask/Attempt.php new file mode 100644 index 0000000..f4a6cbe --- /dev/null +++ b/lib/models/eTask/Attempt.php @@ -0,0 +1,58 @@ +<?php +namespace eTask; + +/** + * eTask conforming assignment attempt definition. + * + * @property int id database column + * @property int assignment_id database column + * @property string user_id database column + * @property string start database column + * @property string end database column + * @property string options database column + * @property eTask\Assignment assignment belongs_to etask\Assignment + * @property JSONArrayobject options serialized database column + */ +class Attempt extends \SimpleORMap implements \PrivacyObject +{ + use ConfigureTrait; + + /** + * @see SimpleORMap::configure + */ + protected static function configure($config = []) + { + $config['db_table'] = 'etask_assignment_attempts'; + + $config['relationTypes'] = self::configureClassNames($config); + + $config['belongs_to']['assignment'] = [ + 'class_name' => $config['relationTypes']['Assignment'], + 'foreign_key' => 'assignment_id' + ]; + + $config['serialized_fields']['options'] = 'JSONArrayObject'; + + parent::configure($config); + } + + /** + * Export available data of a given user into a storage object + * (an instance of the StoredUserData class) for that user. + * + * @param StoredUserData $storage object to store data into + */ + public static function exportUserData(\StoredUserData $storage) + { + $sorm = self::findBySQL("user_id = ?", [$storage->user_id]); + if ($sorm) { + $field_data = []; + foreach ($sorm as $row) { + $field_data[] = $row->toRawArray(); + } + if ($field_data) { + $storage->addTabularData(_('eTask Zuweisungen'), 'etask_assignment_attempts', $field_data); + } + } + } +} |
