Skip to content

Commit 4cb70a7

Browse files
committed
Changes to add new test functionality with export
1 parent 108f8cc commit 4cb70a7

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

src/main/java/de/imi/mopat/controller/SurveyController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ public String showQuestionnaireScheduled(
11861186
@ResponseBody
11871187
public void finishQuestionnaire(
11881188
@RequestParam(value = "questionnaireId", required = true) final Long questionnaireId,
1189+
@RequestParam(value = "performExportTest", required = false, defaultValue = "false") final Boolean performExportTest,
11891190
@RequestBody final EncounterDTO encounterDTO) {
11901191
if (!encounterDTO.getIsTest()) {
11911192

src/main/webapp/WEB-INF/bundle/list.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@
146146
>
147147
</i>
148148
</a>
149+
<th:block sec:authorize="hasRole('ROLE_ADMIN')">
150+
<a
151+
class="link"
152+
th:href="@{/mobile/survey/test(id=${item.id},performExportTest=${true})}"
153+
th:if="${item.isPublished == false && item.getBundleQuestionnaires().isEmpty() == false}"
154+
>
155+
<i
156+
class="bi-play-fill"
157+
th:title="${messages.get(#locale, 'bundle.button.test', 'Test Bundle')}"
158+
>
159+
</i>
160+
</a>
161+
</th:block>
149162
<a
150163
th:if="${item.isPublished == true && item.isModifiable() == true}"
151164
class="link"
@@ -201,7 +214,14 @@
201214
th:href="@{fill?id=__${item.id}__}"
202215
th:text="${messages.get(#locale, 'bundle.button.edit', 'Edit')}"
203216
></a>
204-
217+
<th:block sec:authorize="hasRole('ROLE_ADMIN')">
218+
<a
219+
th:if="${item.isPublished == false && item.getBundleQuestionnaires().isEmpty() == false}"
220+
class="link"
221+
th:href="@{/mobile/survey/test(id=${item.id},performExportTest=${true})}"
222+
th:text="${messages.get(#locale, 'bundle.button.test', 'Test Bundle')}"
223+
></a>
224+
</th:block>
205225
<a
206226
th:if="${item.isPublished == true && item.isModifiable() == true}"
207227
class="link"

src/main/webapp/WEB-INF/mobile/survey/bundleTest.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
name="bundleId"
2020
th:value="${encounter?.getBundle()?.getId()}"
2121
/>
22+
<input
23+
type="hidden"
24+
name="performExportTest"
25+
th:value="${performExportTest}"
26+
/>
2227
<addVar
2328
layout:replace="~{helper/var :: add(
2429
key='hasActiveQuestionnaire',

src/main/webapp/WEB-INF/mobile/survey/questionnaire.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@
218218
var defaultLanguage =
219219
/*[[${configurationDao?.defaultLanguage != null} ? ${configurationDao.defaultLanguage} : 'en_GB']]*/ "en_GB";
220220

221+
/*[- Get the performExportTest flag. Variable is used in survey.js -]*/
222+
var performExportTest =
223+
/*[[${performExportTest != null ? performExportTest : false}]]*/ false;
224+
225+
221226
/*[- Merge the JSON String into the Encounter object, and perform a deep copy (first parameter). -]*/
222227
var encounter = $.extend(
223228
true,

src/main/webapp/js/mobile/survey/survey.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ function getIncompleteQuestionsCountFromQuestionnaire(questionnaire) {
934934
* to redirect to the start page. If it is <code>false</code>, nothing will happen.
935935
*/
936936
function postEncounter(encounter, finalSubmit) {
937-
if (encounter.isTest === true) {
937+
if (encounter.isTest === true && performExportTest === true) {
938938
if (finalSubmit) {
939939
var data = ["bundle"];
940940
$.ajax({
@@ -1059,7 +1059,7 @@ function exportEncounter(encounter, questionnaireId) {
10591059
}
10601060

10611061
$.ajax({
1062-
url: "finishQuestionnaire?questionnaireId=" + questionnaireId,
1062+
url: "finishQuestionnaire?questionnaireId=" + questionnaireId + "&performExportTest="+performExportTest,
10631063
type: "POST",
10641064
contentType: "application/json; charset=utf-8",
10651065
// Exclude the bundle object

0 commit comments

Comments
 (0)