diff options
| author | Rasmus Fuhse <fuhse@data-quest.de> | 2022-12-16 13:13:32 +0000 |
|---|---|---|
| committer | Rasmus Fuhse <fuhse@data-quest.de> | 2022-12-16 13:13:32 +0000 |
| commit | 653fcaba5a06b8098f9bdb98c051c35a567a4513 (patch) | |
| tree | 4c0cb47566019bbab09401b7287ef188322239b5 /lib/models/Questionnaire.php | |
| parent | f127f0fb49c0f687f80588e0e1008e95be37d6ce (diff) | |
Resolve "Evaluationen mit Fragebögen"
Closes #703
Merge request studip/studip!363
Diffstat (limited to 'lib/models/Questionnaire.php')
| -rw-r--r-- | lib/models/Questionnaire.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/models/Questionnaire.php b/lib/models/Questionnaire.php index cd18082..f221ca1 100644 --- a/lib/models/Questionnaire.php +++ b/lib/models/Questionnaire.php @@ -8,6 +8,7 @@ class Questionnaire extends SimpleORMap implements PrivacyObject $config['has_many']['questions'] = [ 'class_name' => QuestionnaireQuestion::class, + 'order_by' => 'ORDER BY position ASC', 'on_delete' => 'delete', 'on_store' => 'store' ]; @@ -214,7 +215,8 @@ class Questionnaire extends SimpleORMap implements PrivacyObject } return $this['resultvisibility'] === "always" || $this->isEditable() - || ($this['resultvisibility'] === "afterending" && $this->isStopped()); + || ($this['resultvisibility'] === "afterending" && $this->isStopped()) + || ($this['resultvisibility'] === 'afterparticipation' && $this->isAnswered()); } /** @@ -236,4 +238,29 @@ class Questionnaire extends SimpleORMap implements PrivacyObject } } } + + /** + * Returns all data as an array that could be stored as JSON. + * @return array + */ + public function exportAsFile() + { + $data = [ + 'questionnaire' => [ + 'title' => $this['title'], + 'anonymous' => $this['anonymous'], + 'resultvisibility' => $this['resultvisibility'], + 'editanswers' => $this['editanswers'] + ], + 'questions_data' => [] + ]; + foreach ($this->questions as $question) { + $data['questions_data'][] = [ + 'questiontype' => $question['questiontype'], + 'internal_name' => $question['internal_name'], + 'questiondata' => $question['questiondata']->getArrayCopy() + ]; + } + return $data; + } } |
