Skip to content

Commit

Permalink
handle welcome and exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobasco99 committed Jun 25, 2024
1 parent 2d0ef88 commit d16118b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,15 @@ public Response calculateNextAction(String intent, String message, String messag
if (participantDone){
JSONArray interactiveElements = new JSONArray();
JSONObject button = new JSONObject();
button.put("intent", "SurveyFertig");
button.put("intent", "Fertig");
button.put("label", "Ende");
button.put("description", "Ende");
button.put("isFile", false);
interactiveElements.add(button);
response.put("interactiveElements", interactiveElements);
System.out.println("participant done");
response.put("message", completedSurvey);
response.put("closeContext", true);
response.put("channel", channel);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
return Response.ok().entity(response).build();
Expand Down Expand Up @@ -2149,7 +2150,7 @@ public Response surveyDone(String surveyDoneString){
SurveyHandlerServiceQueries.updateParticipantInDB(this, this.currentSurvey.database);
JSONArray interactiveElements = new JSONArray();
JSONObject button = new JSONObject();
button.put("intent", "SurveyFertig");
button.put("intent", "Fertig");
button.put("label", "Ende");
button.put("description", "Ende");
button.put("isFile", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ private static void deleteParticipant(Survey currSurvey, String email) {
value = {@ApiResponse(
code = HttpURLConnection.HTTP_OK,
message = "survey question request handled")})
public Response nextQuestion(@FormDataParam("msg") String msg, @FormDataParam("channel") String channel, @FormDataParam("sbfmUrl") @DefaultValue("default") String sbfmUrl,
public Response nextQuestion(@FormDataParam("msg") String msg, @FormDataParam("channel") String channel, @FormDataParam("sbfmUrl") String sbfmUrl,
@FormDataParam("intent") String intent, @FormDataParam("surveyID") String surveyID, @FormDataParam("Password") String password,
@FormDataParam("NameOfUser") String nameOfUser, @FormDataParam("adminmail") String adminmail){
if(intent == null){
Expand Down Expand Up @@ -1462,6 +1462,13 @@ public Response nextQuestion(@FormDataParam("msg") String msg, @FormDataParam("c
} else if (message.equals("!Start")) {
isStart = true;
}
// check if exit
if (message.equals("!exit") || message.equals("!welcome")){
response.put("message", "Nutze bitte das X im Eingabefeld, um zum Hauptmenü zu gelangen.");
response.put("channel", channel);
response.put("closeContext", true);
return Response.ok().entity(response).build();
}

// check if participant is done with survey
if(currParticipant.isCompletedsurvey()){
Expand All @@ -1470,7 +1477,7 @@ public Response nextQuestion(@FormDataParam("msg") String msg, @FormDataParam("c
// no unfinished survey left
JSONArray interactiveElements = new JSONArray();
JSONObject button = new JSONObject();
button.put("intent", "SurveyFertig");
button.put("intent", "Fertig");
button.put("label", "Ende");
button.put("description", "Ende");
button.put("isFile", false);
Expand Down

0 comments on commit d16118b

Please sign in to comment.