Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobasco99 committed Jun 26, 2024
1 parent f247519 commit 732dcda
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/etc/texts.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ changeAnswerExplanationDE = \nUm eine Antwort zu aendern kannst du deine Nachric
changeAnswerExplanationButtonDE = , oder erneut auf einen Button klickst.
firstDE = \tUm eine zweite Umfrage zu starten musst du alle Fragen der ersten Umfrage beantwortet haben.
resultsGetSavedDE = \nDeine Antworten werden kontinuierlich gespeichert.
completedSurveyDE = Du hast die Umfrage vollstaendig beantwortet.
completedSurveyDE = Du hast die Umfrage vollständig beantwortet.
changedAnswerDE = Deine Antwort wurde erfolgreich geaendert.
surveyDoneStringDE = Du hast die Umfrage vollstaendig beantwortet.
surveyDoneStringDE = Du hast die Umfrage vollständig beantwortet.
firstEditDE = Wenn du Antworten zu dieser Umfrage aendern mochtest, mache dies bitte bevor du die naechste Umfrage startest.
welcomeStringDE = {hello}Schreibe mir eine Nachricht im Chat und ich werde die Umfrage "{title}" mit dir durchfuehren. Es gibt {questionsInSurvey} Fragen die du beantworten kannst. {welcomeText} \n\nHier sind ein paar Hinweise:\n
skipTextDE = Diese Frage wurde von dir uebersprungen, du kannst sie jetzt beantworten oder erneut skippen: \n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,11 @@ private Response AskNextQuestion(String surveyDoneString, boolean firstMessage){
}
this.lastquestion = nextId;

System.out.println("check requirements...");

// checking if requirements to ask next questions are met
if(!this.currentSurvey.getQuestionByQid(nextId, this.language).isRelevant(this)){
// requirement is not met, so skipping question
System.out.println("check done...");
if(isSurveyDone()){
System.out.println("done...");
return surveyDone(surveyDoneString);
}
nextId = this.unaskedQuestions.get(0);
Expand All @@ -392,7 +389,6 @@ private Response AskNextQuestion(String surveyDoneString, boolean firstMessage){
if(!answerOptions.isEmpty())
response.put("interactiveElements", answerOptions);
response.put("channel", channel);
//response.put("closeContext", false);
} else {
response.put("text", messageText);
}
Expand Down Expand Up @@ -445,7 +441,6 @@ private void handleRestful(boolean firstMessage, JSONObject response, String nex
if(!answerOptions.isEmpty())
response.put("interactiveElements", answerOptions);
response.put("channel", channel);
//response.put("closeContext", false);
} else {
response.put("text", skipText + messageText);
}
Expand Down Expand Up @@ -688,7 +683,6 @@ public Response participantNewlyContacted(String beginningText){
// Participant has not started the survey yet
this.participantcontacted = true;
SurveyHandlerServiceQueries.updateParticipantInDB(this, this.currentSurvey.database);
//todo: change beginning Text
response.put("message", beginningText);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
return Response.ok().entity(response).build();
Expand Down Expand Up @@ -1372,7 +1366,6 @@ public Response calcNextResponse(String intent, String message, String buttonInt
}

if(!skipped){
System.out.println("not skipped");
if(intent.equals(buttonIntent)){
System.out.println("button answer recognized");
res = newButtonAnswer(newAnswer, lastQuestion, token, message, surveyDoneString, submitButton);
Expand Down Expand Up @@ -1418,7 +1411,6 @@ else if(res != null){
return res;
}
}
System.out.println("Calculating next question...");
// Calculate next question to ask
res = surveyDone(surveyDoneString);
if(res != null){
Expand Down Expand Up @@ -1773,7 +1765,6 @@ public Response newTextAnswer(Answer newAnswer, Question lastQuestion, String me

// Check if it is a text answer for button questions in rocket chat
if(lastQuestion.isBlocksQuestion() && (SurveyHandlerService.messenger.equals(Messenger.ROCKETCHAT) || SurveyHandlerService.messenger.equals(Messenger.RESTFUL))){
System.out.println("handle rc");
return handleRocketChat(newAnswer, lastQuestion, message, response, check, messageId, messageTs);
}

Expand Down Expand Up @@ -1810,10 +1801,11 @@ public Response newTextAnswer(Answer newAnswer, Question lastQuestion, String me
String option = answerOptionForComment();
if(option != null){
if(this.languageIsGerman()){
response.put("text", "Bitte schreibe einen Kommentar fuer die ausgewaehlte Option: \"" + option + "\"");
response.put("message", "Bitte schreibe einen Kommentar für die ausgewählte Option: \"" + option + "\"");
} else{
response.put("text", "Please add a comment to your chosen option: \"" + option + "\"");
response.put("message", "Please add a comment to your chosen option: \"" + option + "\"");
}
response.put("channel", channel);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
return Response.ok().entity(response).build();
} else{
Expand All @@ -1831,33 +1823,34 @@ public Response newTextAnswer(Answer newAnswer, Question lastQuestion, String me
else{
return Response.serverError().build();
}


} else{

if(lastQuestion.getType().equals(Question.qType.SINGLECHOICECOMMENT.toString()) && this.currentSubquestionAnswers.isEmpty()){
// single choice comment requires selcted answer before comment
if(this.languageIsGerman()){
response.put("text", "Bitte waehle erst eine Antwortmoeglichkeit aus und sende dann deinen Kommentar.");
response.put("message", "Bitte waehle erst eine Antwortmoeglichkeit aus und sende dann deinen Kommentar.");
} else{
response.put("text", "Please select an answer first, then resend your comment.");
response.put("message", "Please select an answer first, then resend your comment.");
}
response.put("channel", channel);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
return Response.ok().entity(response).build();
}
if(lastQuestion.getType().equals(Question.qType.MULTIPLECHOICEWITHCOMMENT.toString()) && this.currentSubquestionAnswers.isEmpty()){
// single choice comment requires selcted answer before comment
if(this.languageIsGerman()){
response.put("text", "Bitte waehle erst Antwortmoeglichkeiten aus, du wirst dann nach jeweils einen Kommentar gefragt.");
response.put("message", "Bitte waehle erst Antwortmoeglichkeiten aus, du wirst dann nach jeweils einen Kommentar gefragt.");
} else{
response.put("text", "Please select options first, then you will be asked to write your comments");
response.put("message", "Please select options first, then you will be asked to write your comments");
}
response.put("channel", channel);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
return Response.ok().entity(response).build();
}

if(!lastQuestion.answerIsPlausible(message, check)){
response.put("text", lastQuestion.reasonAnswerNotPlausible());
response.put("message", lastQuestion.reasonAnswerNotPlausible());
response.put("channel", channel);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
return Response.ok().entity(response).build();
}
Expand Down Expand Up @@ -2156,7 +2149,7 @@ public Response surveyDone(String surveyDoneString){
System.out.println("questions left unasked: " + this.unaskedQuestions.size() + " skipped left: " + this.skippedQuestions.size());
JSONObject response = new JSONObject();
// Check if survey is completed
if (this.unaskedQuestions.size() == 0 && this.skippedQuestions.size() == 0){
if (isSurveyDone()){
// No questions remaining, survey done.
this.completedsurvey = true;
SurveyHandlerServiceQueries.updateParticipantInDB(this, this.currentSurvey.database);
Expand All @@ -2171,7 +2164,7 @@ public Response surveyDone(String surveyDoneString){
response.put("interactiveElements", interactiveElements);
response.put("channel", channel);
response.put("closeContext", true);
response.put("message", surveyDoneString); //+ currParticipant.getEmail() + currParticipant.getUnaskedQuestions() + currParticipant.getSkippedQuestions()
response.put("message", surveyDoneString);
return Response.ok().entity(response).build();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2145,13 +2145,14 @@ public Response sendResultsToLimesurvey(@FormDataParam("channel") String channel
}
}
catch(Exception e){
System.out.println("exception after firstsurvey lime");
System.out.println("Exception occured in sendResultsToLimesurvey try block.");
e.printStackTrace();
response.put("message", "Something went wrong in sendResultsBackToLimesurvey try block.");
response.put("channel", channel);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
return Response.ok().entity(response).build();
}
System.out.println("Passed back results to LimeSurvey.");
response.put("message", "Passed back results to LimeSurvey.");
response.put("channel", channel);
Context.get().monitorEvent(MonitoringEvent.RESPONSE_SENDING.toString());
Expand Down

0 comments on commit 732dcda

Please sign in to comment.