[virtualcommons-svn] commit/foraging: alllee: minor cleanup to facilitator, fixes issue 10 and fixi
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2011-09-01 21:36:43
|
1 new changeset in foraging: http://bitbucket.org/virtualcommons/foraging/changeset/5b4a1cadfd82/ changeset: 5b4a1cadfd82 user: alllee date: 2011-09-01 23:37:13 summary: minor cleanup to facilitator, fixes issue 10 and fixing an off-by-one bug in getNumberOfCorrectAnswers affected #: 5 files (709 bytes) --- a/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Thu Sep 01 14:21:01 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/ChatPanel.java Thu Sep 01 14:37:13 2011 -0700 @@ -54,6 +54,8 @@ private ForagingClient client; + private boolean inRoundChat = false; + public ChatPanel(ForagingClient client) { this.client = client; this.clientId = client.getId(); @@ -86,12 +88,6 @@ } } }); - final JButton sendButton = new JButton("Send"); - sendButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - sendMessage(); - } - }); JPanel targetHandlePanel = new JPanel(); targetHandlePanel.setLayout(new BoxLayout(targetHandlePanel, BoxLayout.LINE_AXIS)); targetHandleLabel = new JLabel("everyone"); @@ -102,7 +98,6 @@ add(targetHandlePanel, BorderLayout.NORTH); add(chatField, BorderLayout.CENTER); -// add(sendButton, BorderLayout.SOUTH); setChatFieldFocus(); } @@ -116,8 +111,13 @@ if (message == null || "".equals(message) || targetIdentifier == null) { return; } - client.transmit(new ChatRequest(clientId, message, targetIdentifier)); - chatField.requestFocusInWindow(); + client.transmit(new ChatRequest(clientId, message, targetIdentifier)); + if (inRoundChat) { + getParent().requestFocusInWindow(); + } + else { + chatField.requestFocusInWindow(); + } chatField.setText(""); } @@ -276,7 +276,8 @@ } } - public void initialize() { + public void initialize(boolean inRoundChat) { + this.inRoundChat = inRoundChat; if (HANDLES != null) { displayMessage("System message", " --- Round ended --- "); return; --- a/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Thu Sep 01 14:21:01 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java Thu Sep 01 14:37:13 2011 -0700 @@ -575,7 +575,7 @@ update(configuration.getRoundDuration().getTimeLeft()); if (configuration.isInRoundChatEnabled()) { ChatPanel chatPanel = getChatPanel(); - chatPanel.initialize(); + chatPanel.initialize(true); Dimension chatPanelSize = new Dimension(250, getPanel().getSize().height); chatPanel.setPreferredSize(chatPanelSize); // FIXME: switch to different layout manager @@ -641,13 +641,13 @@ "<ul>" + "<li>Tokens collected: %d</li>" + "<li>Income: $%3.2f</li>" + - "<li>Quiz questions answered correctly: %d (%3.2f)</li>" + + "<li>Quiz questions answered correctly: %d (adds $%3.2f to your total)</li>" + "</ul>", event.getCurrentTokens(), getIncome(event.getCurrentTokens()), correctQuizAnswers, quizReward) ); double showUpPayment = dataModel.getRoundConfiguration().getParentConfiguration().getShowUpPayment(); instructionsBuilder.append(String.format("Your <b>total income</b> so far (including a $%3.2f bonus for showing up) is : $%3.2f<hr>", - showUpPayment, dataModel.getTotalIncome() + showUpPayment)); + showUpPayment, dataModel.getTotalIncome() + showUpPayment + quizReward)); if (event.isLastRound()) { for (String trustGameLog : event.getTrustGameLog()) { @@ -798,7 +798,7 @@ SwingUtilities.invokeLater(new Runnable() { public void run() { ChatPanel chatPanel = getChatPanel(); - chatPanel.initialize(); + chatPanel.initialize(false); showPanel(CHAT_PANEL_NAME); startChatTimer(); } --- a/src/main/java/edu/asu/commons/foraging/event/QuizResponseEvent.java Thu Sep 01 14:21:01 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/event/QuizResponseEvent.java Thu Sep 01 14:37:13 2011 -0700 @@ -44,7 +44,8 @@ } public int getNumberOfCorrectAnswers() { - int correctAnswers = responses.size() - incorrectAnswers.size(); + // FIXME: kludgy - responses is always off by one as it also contains the input submit button. + int correctAnswers = (responses.size() - 1) - incorrectAnswers.size(); if (correctAnswers < 0) { // FIXME: replace with proper logging? System.err.println("Somehow the number of responses was less than the number of incorrect answers: " --- a/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Thu Sep 01 14:21:01 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/facilitator/FacilitatorWindow.java Thu Sep 01 14:37:13 2011 -0700 @@ -59,10 +59,6 @@ private int viewSpacing = 50; - private JMenuItem startExperimentMenuItem; - - private JMenuItem stopExperimentMenuItem; - private JMenuItem showInstructionsMenuItem; private JMenuItem startRoundMenuItem; @@ -113,8 +109,6 @@ showInstructionsMenuItem.setEnabled(false); startRoundMenuItem.setEnabled(false); stopRoundMenuItem.setEnabled(true); - startExperimentMenuItem.setEnabled(false); - stopExperimentMenuItem.setEnabled(true); // initViewPanel(); // repaint(); } @@ -305,8 +299,6 @@ } public void updateMenuItems() { - startExperimentMenuItem.setEnabled(true); - stopExperimentMenuItem.setEnabled(false); startRoundMenuItem.setEnabled(false); showInstructionsMenuItem.setEnabled(false); } @@ -387,8 +379,6 @@ loadExperimentMenuItem.setEnabled(true); //Disable all other menus - startExperimentMenuItem.setEnabled(false); - stopExperimentMenuItem.setEnabled(false); startRoundMenuItem.setEnabled(false); stopRoundMenuItem.setEnabled(false); } --- a/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Thu Sep 01 14:21:01 2011 -0700 +++ b/src/main/java/edu/asu/commons/foraging/server/ForagingServer.java Thu Sep 01 14:37:13 2011 -0700 @@ -298,6 +298,7 @@ addEventProcessor(new EventTypeProcessor<QuizResponseEvent>(QuizResponseEvent.class) { public void handle(final QuizResponseEvent event) { + logger.debug("Received quiz response: " + event); numberOfSubmittedQuizzes++; transmit(new QuizCompletedEvent(facilitatorId)); ClientData clientData = clients.get(event.getId()); 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. |