[virtualcommons-svn] commit/foraging: 2 new changesets
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2012-02-29 22:38:27
|
2 new commits in foraging: https://bitbucket.org/virtualcommons/foraging/changeset/364783961ebf/ changeset: 364783961ebf user: alllee date: 2012-02-29 23:36:30 summary: fixing infinite loop bug when facilitator disconnects no longer using processNominations to deal with an imposed strategy. It should all happen client side as soon as they click submit. affected #: 1 file diff -r 4351f342ae091ac9bd56251f309c75ee67a3fa4d -r 364783961ebf5cb6fcb66667a8e49e5ca3c71a63 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 @@ -13,6 +13,7 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; +import java.util.logging.Level; import edu.asu.commons.event.BeginRoundRequest; import edu.asu.commons.event.ChatEvent; @@ -259,7 +260,12 @@ public void handle(DisconnectionRequest event) { synchronized (clients) { Identifier id = event.getId(); - sendFacilitatorMessage("Received DisconnectionRequest, removing " + id + " from clients " + clients.keySet(), event.getException()); + if (id.equals(getFacilitatorId())) { + getLogger().log(Level.SEVERE, "Disconnecting facilitator.", event.getException()); + } + else { + sendFacilitatorMessage("Received DisconnectionRequest, removing " + id + " from clients " + clients.keySet(), event.getException()); + } clients.remove(id); serverDataModel.removeClient(id); } @@ -404,12 +410,13 @@ // calculate votes Map<Strategy, Integer> votingResults = group.generateVotingResults(imposedStrategyEnabled); List<Strategy> selectedRules = group.getSelectedRules(); - for (Identifier id : group.getClientIdentifiers()) { - sendFacilitatorMessage(String.format( - "%s selected [%s] from all rules %s (imposed? %s)", - group, selectedRules, votingResults, imposedStrategyEnabled)); - - transmit(new RuleSelectedUpdateEvent(id, selectedRules, votingResults)); + sendFacilitatorMessage(String.format( + "%s selected [%s] from all rules %s (imposed? %s)", + group, selectedRules, votingResults, imposedStrategyEnabled)); + if (! imposedStrategyEnabled) { + for (Identifier id : group.getClientIdentifiers()) { + transmit(new RuleSelectedUpdateEvent(id, selectedRules, votingResults)); + } } store(new RuleSelectedUpdateEvent(getFacilitatorId(), selectedRules, votingResults)); } https://bitbucket.org/virtualcommons/foraging/changeset/d5cbf4f5202e/ changeset: d5cbf4f5202e user: alllee date: 2012-02-29 23:38:17 summary: bugfixes for imposed strategy condition - submit button now goes on to the next page - reusing VotingForm, could also just use the instructions panel as well, would probably be cleaner. - turning submitted-vote-instructions into an actual StringTemplate in server.xml affected #: 5 files diff -r 364783961ebf5cb6fcb66667a8e49e5ca3c71a63 -r d5cbf4f5202e68ef393a27522752ce044631a1fc src/main/java/edu/asu/commons/foraging/client/ForagingClient.java --- a/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java +++ b/src/main/java/edu/asu/commons/foraging/client/ForagingClient.java @@ -448,7 +448,9 @@ } public void sendRuleVoteRequest(ForagingStrategy selectedRule) { - transmit(new RuleVoteRequest(getId(), selectedRule)); + if (selectedRule != null) { + transmit(new RuleVoteRequest(getId(), selectedRule)); + } getGameWindow2D().strategyNominationSubmitted(); } diff -r 364783961ebf5cb6fcb66667a8e49e5ca3c71a63 -r d5cbf4f5202e68ef393a27522752ce044631a1fc 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 @@ -722,7 +722,7 @@ } public String getSubmittedVoteInstructions() { - return getProperty("submitted-vote-instructions", "<h1>Submitted</h1><hr><p>Your nomination has been recorded. The final results of the nomination will be shown once all the nominations in your group have been received.</p>"); + return render(getProperty("submitted-vote-instructions")); } public String generateVotingResults(List<Strategy> selectedRules, Map<Strategy, Integer> nominations) { diff -r 364783961ebf5cb6fcb66667a8e49e5ca3c71a63 -r d5cbf4f5202e68ef393a27522752ce044631a1fc src/main/java/edu/asu/commons/foraging/ui/VotingForm.java --- a/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java +++ b/src/main/java/edu/asu/commons/foraging/ui/VotingForm.java @@ -77,7 +77,11 @@ horizontalGroup.addGroup(horizontalButtonParallelGroup); GroupLayout.SequentialGroup verticalGroup = groupLayout.createSequentialGroup(); - String rightColumnHeader = votingResults.isEmpty() ? "Select" : "Nominations"; + boolean imposedStrategyEnabled = client.getCurrentRoundConfiguration().isImposedStrategyEnabled(); + // XXX: this is certainly what Rawlins was warning against + String rightColumnHeader = votingResults.isEmpty() + ? (imposedStrategyEnabled) ? "" : "Select" + : "Nominations"; JLabel rightHeaderLabel = new JLabel(rightColumnHeader); rightHeaderLabel.setFont(UserInterfaceUtils.DEFAULT_BOLD_FONT); horizontalButtonParallelGroup.addComponent(rightHeaderLabel); @@ -88,23 +92,23 @@ verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(strategyHeaderLabel).addGap(20).addComponent(rightHeaderLabel)); Dimension labelDimension = new Dimension(800, 100); - boolean imposedStrategyEnabled = client.getCurrentRoundConfiguration().isImposedStrategyEnabled(); + for (ForagingStrategy strategy: strategies) { JLabel ruleLabel = new JLabel("<html>" + strategy.getDescription() + "</html>"); ruleLabel.setFont(UserInterfaceUtils.DEFAULT_PLAIN_FONT); ruleLabel.setMaximumSize(labelDimension); horizontalLabelParallelGroup.addComponent(ruleLabel); JComponent component = null; - if (votingResults.isEmpty()) { + if (imposedStrategyEnabled) { + component = new JLabel(""); + } + else if (votingResults.isEmpty()) { JRadioButton radioButton = new JRadioButton(); radioButton.setActionCommand(strategy.name()); buttonGroup.add(radioButton); component = radioButton; - horizontalButtonParallelGroup.addComponent(radioButton); - verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleLabel).addComponent(radioButton)); - } - else if (imposedStrategyEnabled) { - component = new JLabel(""); +// horizontalButtonParallelGroup.addComponent(radioButton); +// verticalGroup.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(ruleLabel).addComponent(radioButton)); } else { Integer numberOfVotes = votingResults.get(strategy); @@ -129,6 +133,10 @@ JButton submitButton = new JButton("Submit"); submitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + if (client.getCurrentRoundConfiguration().isImposedStrategyEnabled()) { + client.sendRuleVoteRequest(null); + return; + } ButtonModel model = buttonGroup.getSelection(); if (model == null) { JOptionPane.showMessageDialog(VotingForm.this, "Please select a strategy."); diff -r 364783961ebf5cb6fcb66667a8e49e5ca3c71a63 -r d5cbf4f5202e68ef393a27522752ce044631a1fc src/main/resources/configuration/iu/2011/imposed-punish/server.xml --- a/src/main/resources/configuration/iu/2011/imposed-punish/server.xml +++ b/src/main/resources/configuration/iu/2011/imposed-punish/server.xml @@ -261,14 +261,6 @@ </entry><entry key='voting-results'><![CDATA[ - {if (self.imposedStrategyEnabled)} - <h1>The Assigned Strategy</h1> - <hr> - <p>Your group is being assigned the following strategy. All other members in your group are being notified of the same strategy.</p> - <ul> - <li><b>{first(selectedRules)}</b></li> - </ul> - {else} <h1>Nomination Results</h1><hr><table border=3 cellspacing=3 cellpadding=3> @@ -283,7 +275,6 @@ <p><b>NOTE:</b> There was a tie and the selected strategy listed here was randomly selected as the winner.</p> {endif} <p><b> {first(selectedRules)} </b></p> - {endif} <h2>Implementation</h2><hr><p> @@ -397,5 +388,34 @@ </p> ]]></entry> +<entry key='submitted-vote-instructions'> + <![CDATA[ + {if (self.imposedStrategyEnabled)} + <h1>The Assigned Strategy</h1> + <hr> + <p>Your group is being assigned the following strategy. All other members in your group are being notified of the same strategy.</p> + <ul> + <li><b>{first(selectedRules)}</b></li> + </ul> + <h2>Implementation</h2> + <hr> + <p> + Neither the computer, nor the experimenter will intervene to implement the + strategy. + </p> + <p><b>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> + + {else} + <h1>Submitted</h1> + <hr> + <p>Your nomination has been recorded. The final + results of the nomination will be shown once all the nominations in your + group have been received. + </p> + {endif} + ]]> +</entry></properties> diff -r 364783961ebf5cb6fcb66667a8e49e5ca3c71a63 -r d5cbf4f5202e68ef393a27522752ce044631a1fc src/main/resources/configuration/iu/2011/imposed/server.xml --- a/src/main/resources/configuration/iu/2011/imposed/server.xml +++ b/src/main/resources/configuration/iu/2011/imposed/server.xml @@ -261,14 +261,6 @@ </entry><entry key='voting-results'><![CDATA[ - {if (self.imposedStrategyEnabled)} - <h1>The Assigned Strategy</h1> - <hr> - <p>Your group is being assigned the following strategy. All other members in your group are being notified of the same strategy.</p> - <ul> - <li><b>{first(selectedRules)}</b></li> - </ul> - {else} <h1>Nomination Results</h1><hr><table border=3 cellspacing=3 cellpadding=3> @@ -283,7 +275,6 @@ <p><b>NOTE:</b> There was a tie and the selected strategy listed here was randomly selected as the winner.</p> {endif} <p><b> {first(selectedRules)} </b></p> - {endif} <h2>Implementation</h2><hr><p> @@ -399,4 +390,33 @@ </p> ]]></entry> +<entry key='submitted-vote-instructions'> + <![CDATA[ + {if (self.imposedStrategyEnabled)} + <h1>The Assigned Strategy</h1> + <hr> + <p>Your group is being assigned the following strategy. All other members in your group are being notified of the same strategy.</p> + <ul> + <li><b>{first(selectedRules)}</b></li> + </ul> + <h2>Implementation</h2> + <hr> + <p> + Neither the computer, nor the experimenter will intervene to implement the + strategy. + </p> + <p><b>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> + + {else} + <h1>Submitted</h1> + <hr> + <p>Your nomination has been recorded. The final + results of the nomination will be shown once all the nominations in your + group have been received. + </p> + {endif} + ]]> +</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. |