[virtualcommons-svn] commit/foraging: 2 new changesets
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2012-01-28 08:25:26
|
2 new commits in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/a690c3cae37d/ changeset: a690c3cae37d user: alllee date: 2012-01-28 08:22:58 summary: adding model object for ForagingNomination to render in StringTemplate properly affected #: 1 file diff -r f0dde60eb1da8e56456d2ae95c05980b9b13a5f8 -r a690c3cae37da929965e6292ebcee82431189312 src/main/java/edu/asu/commons/foraging/rules/iu/ForagingNomination.java --- /dev/null +++ b/src/main/java/edu/asu/commons/foraging/rules/iu/ForagingNomination.java @@ -0,0 +1,23 @@ +package edu.asu.commons.foraging.rules.iu; + +public class ForagingNomination { + + private final ForagingStrategy strategy; + private final Integer nominations; + private final boolean selectedStrategy; + public ForagingNomination(ForagingStrategy strategy, Integer nominations, boolean selectedStrategy) { + this.strategy = strategy; + this.nominations = nominations; + this.selectedStrategy = selectedStrategy; + } + public ForagingStrategy getStrategy() { + return strategy; + } + public Integer getNominations() { + return nominations; + } + public boolean isSelectedStrategy() { + return selectedStrategy; + } + +} https://bitbucket.org/virtualcommons/foraging/changeset/c3edd5171f5d/ changeset: c3edd5171f5d user: alllee date: 2012-01-28 09:25:05 summary: using ForagingStrategyNomination model object to properly render the voting results template and using ClientReadyEvent in lieu of specialized SurveyCompletedEvents. affected #: 9 files diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/RoundConfiguration.java @@ -2,6 +2,7 @@ import java.awt.Dimension; import java.text.NumberFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -20,6 +21,7 @@ import edu.asu.commons.foraging.model.ResourceDispenser; import edu.asu.commons.foraging.model.ServerDataModel; import edu.asu.commons.foraging.rules.iu.ForagingStrategy; +import edu.asu.commons.foraging.rules.iu.ForagingStrategyNomination; import edu.asu.commons.net.Identifier; import edu.asu.commons.util.Duration; @@ -558,7 +560,7 @@ } public String getInitialVotingInstructions() { - return createStringTemplate(getProperty("initial-voting-instructions", getParentConfiguration().getInitialVotingInstructions())).render(); + return createStringTemplate(getProperty("initial-voting-instructions")).render(); } public List<ForagingStrategy> getForagingRules() { @@ -725,7 +727,11 @@ } public String generateVotingResults(List<ForagingStrategy> selectedRules, Map<ForagingStrategy, Integer> nominations) { - TreeMap<ForagingStrategy, Integer> sortedNominations = new TreeMap<ForagingStrategy, Integer>(nominations); + List<ForagingStrategyNomination> sortedNominations = new ArrayList<ForagingStrategyNomination>(); + for (Map.Entry<ForagingStrategy, Integer> entry: new TreeMap<ForagingStrategy, Integer>(nominations).entrySet()) { + ForagingStrategy strategy = entry.getKey(); + sortedNominations.add(new ForagingStrategyNomination(strategy, entry.getValue(), strategy.equals(selectedRules.get(0)))); + } setSelectedRules(selectedRules); ST template = createStringTemplate(getVotingResultsTemplate()); template.add("nominations", sortedNominations); diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java --- a/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java +++ b/src/main/java/edu/asu/commons/foraging/conf/ServerConfiguration.java @@ -1,7 +1,6 @@ package edu.asu.commons.foraging.conf; import java.text.NumberFormat; -import java.util.Locale; import org.stringtemplate.v4.ST; @@ -156,4 +155,8 @@ return assistant.getIntProperty("server-sleep-interval", 50); } + public String getWaitingRoomInstructions() { + return assistant.getProperty("waiting-room-instructions"); + } + } diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/java/edu/asu/commons/foraging/model/ForagingDataModel.java --- a/src/main/java/edu/asu/commons/foraging/model/ForagingDataModel.java +++ b/src/main/java/edu/asu/commons/foraging/model/ForagingDataModel.java @@ -45,6 +45,13 @@ public int getBoardHeight() { return boardHeight; } + + public ServerConfiguration getExperimentConfiguration() { + if (roundConfiguration != null) { + return roundConfiguration.getParentConfiguration(); + } + return null; + } public RoundConfiguration getRoundConfiguration() { return roundConfiguration; diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/java/edu/asu/commons/foraging/rules/iu/ForagingNomination.java --- a/src/main/java/edu/asu/commons/foraging/rules/iu/ForagingNomination.java +++ /dev/null @@ -1,23 +0,0 @@ -package edu.asu.commons.foraging.rules.iu; - -public class ForagingNomination { - - private final ForagingStrategy strategy; - private final Integer nominations; - private final boolean selectedStrategy; - public ForagingNomination(ForagingStrategy strategy, Integer nominations, boolean selectedStrategy) { - this.strategy = strategy; - this.nominations = nominations; - this.selectedStrategy = selectedStrategy; - } - public ForagingStrategy getStrategy() { - return strategy; - } - public Integer getNominations() { - return nominations; - } - public boolean isSelectedStrategy() { - return selectedStrategy; - } - -} diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/java/edu/asu/commons/foraging/rules/iu/ForagingStrategyNomination.java --- /dev/null +++ b/src/main/java/edu/asu/commons/foraging/rules/iu/ForagingStrategyNomination.java @@ -0,0 +1,23 @@ +package edu.asu.commons.foraging.rules.iu; + +public class ForagingStrategyNomination { + + private final ForagingStrategy strategy; + private final Integer nominations; + private final boolean selected; + public ForagingStrategyNomination(ForagingStrategy strategy, Integer nominations, boolean selected) { + this.strategy = strategy; + this.nominations = nominations; + this.selected = selected; + } + public ForagingStrategy getStrategy() { + return strategy; + } + public Integer getNominations() { + return nominations; + } + public boolean isSelected() { + return selected; + } + +} diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/java/edu/asu/commons/foraging/server/ForagingServer.java --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java @@ -22,6 +22,7 @@ import edu.asu.commons.event.ChatEvent; import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.ClientMessageEvent; +import edu.asu.commons.event.ClientReadyEvent; import edu.asu.commons.event.EndRoundRequest; import edu.asu.commons.event.EventTypeProcessor; import edu.asu.commons.event.FacilitatorMessageEvent; @@ -64,7 +65,6 @@ import edu.asu.commons.foraging.event.RuleSelectedUpdateEvent; import edu.asu.commons.foraging.event.RuleVoteRequest; import edu.asu.commons.foraging.event.SanctionAppliedEvent; -import edu.asu.commons.foraging.event.SurveyCompletedEvent; import edu.asu.commons.foraging.event.SurveyIdSubmissionRequest; import edu.asu.commons.foraging.event.SynchronizeClientEvent; import edu.asu.commons.foraging.event.TrustGameResultsFacilitatorEvent; @@ -301,18 +301,16 @@ } } }); - addEventProcessor(new EventTypeProcessor<SurveyCompletedEvent>(SurveyCompletedEvent.class) { - private int submittedSurveys = 0; + addEventProcessor(new EventTypeProcessor<ClientReadyEvent>(ClientReadyEvent.class) { + private int readyClients = 0; @Override - public void handle(SurveyCompletedEvent event) { - if (getCurrentRoundConfiguration().isExternalSurveyEnabled()) { - submittedSurveys++; - sendFacilitatorMessage(String.format("Received %d of %d surveys: %s", submittedSurveys, clients.size(), event)); - if (submittedSurveys >= clients.size()) { - sendFacilitatorMessage("All surveys have been reported as completed, ready to continue."); - submittedSurveys = 0; - } - } + public void handle(ClientReadyEvent event) { + readyClients++; + sendFacilitatorMessage(String.format("%d of %d clients are ready: %s", readyClients, clients.size(), event)); + if (readyClients >= clients.size()) { + sendFacilitatorMessage("All clients are ready to move on."); + readyClients = 0; + } } }); diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java --- a/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java +++ b/src/main/java/edu/asu/commons/foraging/ui/GameWindow2D.java @@ -41,6 +41,7 @@ import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; +import edu.asu.commons.event.ClientReadyEvent; import edu.asu.commons.event.Event; import edu.asu.commons.event.EventChannel; import edu.asu.commons.foraging.client.ClientDataModel; @@ -53,7 +54,6 @@ import edu.asu.commons.foraging.event.QuizResponseEvent; import edu.asu.commons.foraging.event.RealTimeSanctionRequest; import edu.asu.commons.foraging.event.ResetTokenDistributionRequest; -import edu.asu.commons.foraging.event.SurveyCompletedEvent; import edu.asu.commons.foraging.event.TrustGameResultsClientEvent; import edu.asu.commons.foraging.model.ClientData; import edu.asu.commons.foraging.model.Direction; @@ -190,17 +190,18 @@ } } - private ActionListener createSurveyFinishedListener() { + private ActionListener createClientReadyListener(final String confirmationMessage) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int selectedOption = JOptionPane.showConfirmDialog(getPanel(), - dataModel.getRoundConfiguration().getSurveyConfirmationMessage(), - "Confirm survey completion", JOptionPane.YES_NO_OPTION); + confirmationMessage, + "Continue?", JOptionPane.YES_NO_OPTION); switch (selectedOption) { case JOptionPane.YES_OPTION: - showInstructions(); - client.transmit(new SurveyCompletedEvent(client.getId())); + setInstructions(dataModel.getExperimentConfiguration().getWaitingRoomInstructions()); + showInstructionsPanel(); + client.transmit(new ClientReadyEvent(client.getId(), confirmationMessage)); instructionsEditorPane.setActionListener(null); break; default: @@ -731,6 +732,8 @@ public void showInitialVotingInstructions() { SwingUtilities.invokeLater(new Runnable() { public void run() { +// instructionsEditorPane.setActionListener(null); +// instructionsEditorPane.setActionListener(createClientReadyListener("Are you ready to submit your nominations?")); setInstructions(dataModel.getRoundConfiguration().getInitialVotingInstructions()); showInstructionsPanel(); } @@ -779,7 +782,7 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { instructionsEditorPane.setActionListener(null); - instructionsEditorPane.setActionListener(createSurveyFinishedListener()); + instructionsEditorPane.setActionListener(createClientReadyListener(dataModel.getRoundConfiguration().getSurveyConfirmationMessage())); setInstructions(dataModel.getRoundConfiguration().getSurveyInstructions(dataModel.getId())); showInstructionsPanel(); } diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/resources/configuration/iu/2011/vote-punish/round4.xml --- a/src/main/resources/configuration/iu/2011/vote-punish/round4.xml +++ b/src/main/resources/configuration/iu/2011/vote-punish/round4.xml @@ -65,43 +65,6 @@ </entry> -<entry key='initial-voting-instructions'> - <![CDATA[ -<h1>Important New Instructions!</h1> -<h2>Strategies for managing how players collect tokens for the rest of the experiment</h2> -<hr> -<p> -In a moment, you will have the option to implement one of five strategies for how you -and the three other people in your group collect tokens for the rest of the -experiment. -</p> - -<h2>Procedure for Deciding the Strategy</h2> -<hr> -<p> - Each of the {self.clientsPerGroup} people in your group can nominate one of the five - potential strategies. The single strategy that receives the most nominations - wins. -</p> -<p> - <b>If there is a tie</b>, one of the tied options will be selected at random by - the computer. Each of the tied strategies will have an equal chance of being - selected. -</p> - -<h2>Implementation</h2> -<hr> - <p>Neither the computer nor the experimenter will intervene to implement the - strategy. - </p> - - <p> - <b>Do you have any questions?</b> If you have any questions at this time, - raise your hand and someone will come over to your station and answer it. - </p> - ]]> -</entry> - <entry key='voting-instructions'><![CDATA[ diff -r a690c3cae37da929965e6292ebcee82431189312 -r c3edd5171f5d267af8e18e6451e94fdc36c9e88f src/main/resources/configuration/iu/2011/vote-punish/server.xml --- a/src/main/resources/configuration/iu/2011/vote-punish/server.xml +++ b/src/main/resources/configuration/iu/2011/vote-punish/server.xml @@ -263,8 +263,8 @@ <hr><table border=3 cellspacing=3 cellpadding=3><tr><th>Strategy</th><th>Nominations</th></tr> - {nominations.keys: { rule | - <tr bgcolor="#{if (rule.equals(first(selectedRules)))}FFFFCC{else}CCCCCC{endif}"><td>{rule}</td><td>{nominations.(rule)}</td></tr> + {nominations: { strategyNomination | + <tr bgcolor="#{if (strategyNomination.selected)}FFFFCC{else}CCCCCC{endif}"><td>{strategyNomination.strategy}</td><td>{strategyNomination.nominations}</td></tr> }} </table><h1>Selected Strategy</h1> @@ -275,4 +275,52 @@ <p><b> {first(selectedRules)} </b></p> ]]></entry> +<entry key='initial-voting-instructions'> + <![CDATA[ +<h1>Important New Instructions!</h1> +<h2>Strategies for managing how players collect tokens for the rest of the experiment</h2> +<hr> +<p> +In a moment, you will have the option to implement one of five strategies for how you +and the three other people in your group collect tokens for the rest of the +experiment. +</p> + +<h2>Procedure for Deciding the Strategy</h2> +<hr> +<p> + Each of the {self.clientsPerGroup} people in your group can nominate one of the five + potential strategies. The single strategy that receives the most nominations + wins. +</p> +<p> + <b>If there is a tie</b>, one of the tied options will be selected at random by + the computer. Each of the tied strategies will have an equal chance of being + selected. +</p> + +<h2>Implementation</h2> +<hr> + <p>Neither the computer nor the experimenter will intervene to implement the + strategy. + </p> + + <p> + <b>Do you have any questions?</b> If you have any questions at this time, + raise your hand and someone will come over to your station and answer it. + Otherwise, please click the continue button below. + </p> + <form> + <input type="submit" value="Continue" name="continue"> + </form> + ]]> +</entry> +<entry key='waiting-room-instructions'> +<![CDATA[ +<h1>Waiting Room</h1> +<hr> +<p>Please wait while the rest of the participants to complete their tasks.</p> +]]> +</entry> + </properties> Repository URL: https://bitbucket.org/virtualcommons/foraging/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |