Wiki

Clone wiki

ExperimentTool / C3 FAQ

Frequently asked questions

#Useful Tips & Tools

#Q: What to do if errors occur after importing the code from SourceTree into Eclipse

A: There are two possible reasons for the errors: Whether the version of JRE System Library or the version of the Java compiler is not correct.

  • For the JRE System Library check this path:

FAQ11.PNG

Right click on the folder -> Properties -> Java Build Path -> Libraries

Here you will see the version of JRE System Library which is in use at the moment. If it is not JavaSE-1.7 or later, you shall do the following:

Select currently using JRE System Library -> Click on "Edit" -> Select JavaSE-1.7 -> Finish -> OK

  • For the Java compiler check this path:

FAQ12.PNG

Right click on the folder -> Properties -> Java compiler -> select “Enable project specific settings” -> change “compiler compliance level” into 1.6 or later


#Q: I did everything correct, but as soon as I start my session, the experiment comes to an end.

A: In order to fix the problem, the experimenter could do the following checks:

Step 1: Initialization of lists - Null pointer exceptions could be thrown wherever your lists weren't initialized correctly, and you try to access them.

For example, adding the following 3 in the Institution's constructor for a specific experiment:

#!java

                trustees = new ArrayList <Subject>();
                trustors = new ArrayList <Subject>();
                remainingTrustors = new ArrayList <Subject>();

Please make sure you always initialize a list before using it.

Step 2: For a given screen - if there are no input boxes/buttons, you might need to show the screen with a time limit, using the following line:

#!java

showScreenWithDeadLine(one, TrustGameResult.class, parameterx, 5000L);

Step 3: PLEASE make sure you send the corresponding ParamObject type for each screen. For instance, for DefaultWaitingScreen, it expects the basic ParamObject, and it will always fail when you type cast. So please go through your code, to see if you are always passing the right ParamObject type (as expected in that screen) as parameter for showScreen.

Step 4: Due to null values for screen elements, the screen might not be properly constructed, and the experiment might just go through till the end. Make sure that, all values to populate a screen, are being passed correctly, and are not null. Screens which are trying to display null values, should be handled accordingly, or these use cases need to be explicitly checked.


#Q: How to manage a quiz?

A:

  • How to implement a quiz:

Your own version of Quiz should extend QuizScreen.

  • How to add a quiz:

Right click on Session -> Add Quiz -> Insert the qualified name for ScreenID like this:

Quiz0.PNG

Quiz.PNG

  • How to remove a quiz:

Right click on Quiz and Remove

  • How to click through the quiz when unable to see a button:

Since the screens are designed for the lab computers, they sometimes cannot be completely shown on individual computers. In case like this, just use the button “Enter” on your keyboard to move on.


#Q: When trying to run the session, an error occurs on the console. What could be the problem?

A: This is the issue for the first error log.

While starting your server, you need to provide the path to the java.policy file (usually somewhere in the Implementation folder).

The argument which have to consign to the VM is:

-Djava.security.manager

-Djava.security.policy=/"personal path"/java.policy

Error start server Pfad.png

Some IDE's /OS'es are not able to pick up this file automatically, and hence needs it as a parameter.


#Q: When I was to run the experiment in the lab, I was unable to run the server through Eclipse, since the database still has access on the data. The exception might look like this: “Internal Exception: org.h2.jdbc.JdbcSQLException: Datenbank wird wahrscheinlich bereits benutzt: "Locked by another process". Mögliche Lösungen: alle Verbindungen schliessen; Server Modus verwenden Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-176] Error Code: 90020”

A: There is a little H2 symbol on the right-bottom side of the computer display. Right-click on it and select “Exit” to close the database.

Bild1.png Bild2.png


#Q: I would like to show my client screens on full screen mode.

A: In order to do this, open the system.properties file located in \Exp_Implementation\main\resources\META-INF, and set the property "debugMode=false".


#Q: I would like to connect my clients to a server over a LAN.

A: In order to do this, open the system.properties file located in \Exp_Implementation\main\resources\META-INF, and set the property "server" to the IP address that the clients need to connect to.


#Q: How to update a parameter in the client screen?

A: In case you want to update the data on specific parts of the current screen, this can be done by calling the updateParamObject(clientId, parameter) method, from your Experiment’s Institution class

Step 1: Call the updateParamObject(clientId, parameter) method in your Institution class of the server package. Here, you can pass the specific client id, and the parameters to be updated on their respective screen.

For example:

#!java

updateParamObject(individual.getIdClient(),parameterRequester);

Or more detailed, in the processMessage() method:

#!java  
    @Override
    public void processMessage(ClientResponseMessage msg) throws Exception {

        String msgClientId = msg.getClientId();

        if (msg.getParameters() instanceof StrategicInteractionParamObject) {
            StrategicInteractionParamObject parameterRequester = msg
                    .getParameters();

            if (parameterRequester.getThisRole() != null
                    && parameterRequester.getThisRole().equals("Player A")) {
                // update table for player 2
                for (int i = 0; i < memberships.size(); i++) {
                    Membership membership = (Membership) memberships.get(i);
                    individual = membership.getSubject();
                    if (membership.getRole().equals("Player B")
                            && parameterRequester.getOtherPlayerTotalPoints() != 0) {
                        parameterRequester.setThisRole("Player B");
                        if (this.getCurrentTreatment().getName().equals("COOP")) {
                            updateParamObject(individual.getIdClient(),
                                    parameterRequester);
                        } else if (this.getCurrentTreatment().getName()
                                .equals("COMP")) {
                            updateParamObject(individual.getIdClient(),
                                    parameterRequester);
                        }
                    }
                }
            } else if (parameterRequester.getThisRole() != null
                    && parameterRequester.getThisRole().equals("Player B")) {
                // update table for player 2
                for (int i = 0; i < memberships.size(); i++) {
                    Membership membership = (Membership) memberships.get(i);
                    individual = membership.getSubject();
                    if (membership.getRole().equals("Player A")
                            && parameterRequester.getOtherPlayerTotalPoints() != 0) {
                        parameterRequester.setThisRole("Player A");
                        if (this.getCurrentTreatment().getName().equals("COOP")) {
                            updateParamObject(individual.getIdClient(),
                                    parameterRequester);
                        } else if (this.getCurrentTreatment().getName()
                                .equals("COMP")) {
                            updateParamObject(individual.getIdClient(),
                                    parameterRequester);
                        }
                    }
                }
            }
        } else if (msg.getParameters() instanceof BooleanParamObject) {

            synchronized (_syncRound) {
                if (!_responsesReceived.contains(msgClientId)) {
                    _responsesReceived.add(msgClientId);
                }

                individual.setPayoff(individual.getPayoff()+ BusinessFacadeFactory.getInstance().getTotalPoints());
                boolean isLastInGroup = _responsesReceived.size() == memberships
                        .size();
                if (isLastInGroup) {
                    _responsesReceived.clear();
                    BusinessFacadeFactory.getInstance().setTimerStarted(false);
                    endPeriod();
                } else {

                    showScreen(msgClientId, DefaultWaitingScreen.class,
                            new DefaultWaitingScreen.ParamObject());
                }

            }

        }

    }

Step 2: Then on the screen, you can define exactly what needs to be changed on the screen, as soon as the update message is received (i.e., which values are to be shown or updated on which UI elements, for instance), by overriding this method in your experiment’s screen class: processParamObjectUpdate (IScreenParamObject)

#!java

 @Override
       public void processParamObjectUpdate(IScreenParamObject paramObject) {
       // add your program logic here
        }

For example:

#!java

@Override
    public void processParamObjectUpdate(IScreenParamObject paramObject) {
        if (paramObject instanceof StrategicInteractionParamObject) {
            StrategicInteractionParamObject castObject = (StrategicInteractionParamObject) paramObject;

            System.out.println("before score update "
                    + BusinessFacadeFactory.getInstance().getTotalPoints());
            BusinessFacadeFactory.getInstance().setTotalPoints(
                    castObject.getOtherPlayerTotalPoints());
            System.out.println("score updated "
                    + BusinessFacadeFactory.getInstance().getTotalPoints());

            updateTable(castObject);
            updateLbl(castObject);
        }

    }

#Q: How to identify clients in the institution?

A: Here is an example implementation:

Use the client id by accessing the Membership list. The global variable "memberships" contains list of all client ids registered for that institution.

#!java

for (Membership membership : memberships) {
  String clientId=  membership.getSubject().getClientId();
}

#Q: How do I build a screen in brownie?

A: For painting screens in brownie, it might be useful installing this plugin: https://eclipse.org/windowbuilder/. With this, you can drag and drop UI elements, and very easily build a screen, fix the layout, etc. (basically have fun with UI)


#Q: How do I create a survey?

A: Use online-tool “LimeSurvey” for creating surveys: https://www.limesurvey.org/


#Q: How do I debug?

A: For better code understanding you could use the Eclipse Debugger. Here is a tutorial on Youtube for you to get started: https://www.youtube.com/watch?v=9gAjIQc4bPU


#Q: How to reset the counter in a given table of the database? A: Enter your h2 db console, and type the command below and run:

ALTER TABLE <table_name> ALTER COLUMN <column_name> RESTART WITH 1


#Q: What do I do when I face a Socket permission denied exception?

java.net.SocketPermission "connect,resolve"

In the event that link goes stale the resolution is to find the java.policy file in the JAVA_HOME\lib\security directory, access the file with a text editor and add the following at the bottom of the existing 'grant' section 'permission java.net.SocketPermission "xxx.xxx.xxx.xxx:port", "connect, accept";'.

Updated