Skip to content

Commit bd59b2d

Browse files
task
1 parent 121b7da commit bd59b2d

File tree

5 files changed

+254
-198
lines changed

5 files changed

+254
-198
lines changed

experimentresources/stimuli/rorschachset01/rorschach.txt

Lines changed: 0 additions & 181 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
P1 IMAGE¦P2 IMAGE¦MATCHER, 1=P1, 2=P2, B=BOTH ¦BUTTONS DISPLAYED ¦CORRECT ANSWER
2+
r04.png ¦r04.png ¦B¦S,D¦S
3+
r15.png ¦r15.png ¦B¦S,D¦S
4+
r21.png ¦r21.png ¦B¦S,D¦S
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package diet.server.ConversationController;
7+
8+
import diet.server.Conversation;
9+
import diet.server.ConversationController.ui.CustomDialog;
10+
import diet.server.Participant;
11+
import diet.task.CustomizableReferentialTask.CustomizableReferentialTask;
12+
import diet.task.CustomizableReferentialTask.CustomizableReferentialTaskSettings;
13+
import diet.tg.TelegramMessageFromClient;
14+
import diet.tg.TelegramParticipant;
15+
import java.util.Hashtable;
16+
import java.util.Vector;
17+
import org.telegram.telegrambots.meta.api.objects.CallbackQuery;
18+
import org.telegram.telegrambots.meta.api.objects.Message;
19+
20+
/**
21+
*
22+
* @author LX1C
23+
*/
24+
public class Telegram_Dyadic_Customizable_ReferentialTask_Automatic_Start extends TelegramController{
25+
26+
27+
CustomizableReferentialTaskSettings crts = new CustomizableReferentialTaskSettings(this,true, null, null );
28+
//CustomizableReferentialTask crt = new CustomizableReferentialTask(this, crts);
29+
// CustomizableReferentialTask crt = new CustomizableReferentialTask(this, 5000,true);
30+
// Participant pDirector;
31+
// Participant pMatcher;
32+
33+
34+
public Telegram_Dyadic_Customizable_ReferentialTask_Automatic_Start(Conversation c) {
35+
super(c);
36+
}
37+
38+
public Telegram_Dyadic_Customizable_ReferentialTask_Automatic_Start(Conversation c, long istypingtimeout) {
39+
super(c, istypingtimeout);
40+
}
41+
42+
43+
public Vector<TelegramParticipant> vQueued = new Vector();
44+
Hashtable htTasks = new Hashtable();
45+
public Vector<CustomizableReferentialTask> experimentalTasks = new Vector();
46+
47+
48+
49+
public void startParticipants(TelegramParticipant tp1, TelegramParticipant tp2){
50+
pp.createNewSubdialogue(tp1,tp2);
51+
CustomizableReferentialTask crt = new CustomizableReferentialTask(this, crts);
52+
c.telegram_sendInstructionToParticipant_MonospaceFont(tp1, "Please start!");
53+
c.telegram_sendInstructionToParticipant_MonospaceFont(tp2, "Please start!");
54+
crt.startTask(tp1, tp2);
55+
this.htTasks.put(tp1, crt);
56+
this.htTasks.put(tp2, crt);
57+
this.experimentalTasks.add(crt);
58+
}
59+
60+
61+
62+
63+
64+
public void telegram_participantJoinedConversation(TelegramParticipant p) {
65+
vQueued.add(p);
66+
Conversation.printWSln("Main", "Participant "+p.getUsername()+ " logged in. There are now "+this.vQueued.size()+ " participants waiting for a partner");
67+
this.checkIfCanStart();
68+
}
69+
70+
71+
@Override
72+
public void telegram_participantReJoinedConversation(TelegramParticipant p) {
73+
vQueued.add(p);
74+
Conversation.printWSln("Main", "Participant "+p.getUsername()+ " relogged in. There are now "+this.vQueued.size()+ " participants waiting for a partner");
75+
this.checkIfCanStart();
76+
}
77+
78+
79+
80+
public void checkIfCanStart(){
81+
if (this.vQueued.size()>1){
82+
TelegramParticipant tpA = this.vQueued.elementAt(0);
83+
TelegramParticipant tpB = this.vQueued.elementAt(1);
84+
this.startParticipants(tpA, tpB);
85+
this.vQueued.remove(tpA);
86+
this.vQueued.remove(tpB);
87+
}
88+
}
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
@Override
101+
public void telegram_processTelegramMessageFromClient(TelegramParticipant sender, TelegramMessageFromClient tmfc) {
102+
CustomizableReferentialTask crt = (CustomizableReferentialTask) this.htTasks.get(sender);
103+
if(crt ==null){
104+
c.saveErrorLog("Error! Cannot find the Referential task for the participant "+sender.getParticipantID()+ " this is probably because the experiment hasn`t started yet!");
105+
return;
106+
}
107+
108+
109+
110+
if(tmfc.u.hasMessage() && tmfc.u.getMessage().hasText()){
111+
112+
String text=tmfc.u.getMessage().getText();
113+
crt.processChatText(sender, text);
114+
if(!text.startsWith("/")){
115+
c.telegram_relayMessageTextToOtherParticipants(sender, tmfc);
116+
}
117+
118+
119+
120+
}
121+
if(this.relayPhotos && tmfc.u.hasMessage()&& tmfc.u.getMessage().hasPhoto()){
122+
//Need to block sending of images
123+
Conversation.printWSln("Main", "One of the participants tried to send an image! This was blocked by the server.");
124+
// c.telegram_relayMessagePhotoToOtherParticipants_By_File_ID(sender, tmfc);
125+
}
126+
127+
if(tmfc.u.hasCallbackQuery()){
128+
CallbackQuery cbq = tmfc.u.getCallbackQuery();
129+
Message m =cbq.getMessage();
130+
String callbackData = cbq.getData();
131+
System.err.println("callbackdata: "+callbackData);
132+
133+
crt.telegram_processButtonPress(sender, tmfc.u);
134+
135+
//c.telegram_respondToCallback(sender, tmfc.u, "THIS IS THE RESPONSE");
136+
137+
138+
// String[][] nb = new String[][]{ {"a","b"}, {"c","d","e"} };
139+
140+
//c.telegram_sendEditMessageReplyMarkup(sender, tmfc.u,nb);
141+
142+
}
143+
144+
145+
146+
}
147+
148+
149+
150+
151+
152+
153+
154+
155+
156+
157+
public static boolean showcCONGUI() {
158+
return true;
159+
}
160+
161+
}

0 commit comments

Comments
 (0)