Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20171117.sql
===================================================================
diff -u -r00c630a99ddb827c772bd0fc0d8d903cc0079f7e -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20171117.sql (.../patch20171117.sql) (revision 00c630a99ddb827c772bd0fc0d8d903cc0079f7e)
+++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20171117.sql (.../patch20171117.sql) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -9,6 +9,8 @@
poll_id BIGINT(20) NOT NULL AUTO_INCREMENT
, kumalive_id BIGINT(20) NOT NULL
, name VARCHAR(250)
+ , votes_released TINYINT(1) DEFAULT 0
+ , voters_released TINYINT(1) DEFAULT 0
, start_date DATETIME NOT NULL
, finish_date DATETIME
, PRIMARY KEY (poll_id)
Index: lams_learning/conf/hibernate/mappings/org/lamsfoundation/lams/learning/kumalive/KumalivePoll.hbm.xml
===================================================================
diff -u -redcf26c6dbd1e4ff36858d876e908774abb7910d -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/conf/hibernate/mappings/org/lamsfoundation/lams/learning/kumalive/KumalivePoll.hbm.xml (.../KumalivePoll.hbm.xml) (revision edcf26c6dbd1e4ff36858d876e908774abb7910d)
+++ lams_learning/conf/hibernate/mappings/org/lamsfoundation/lams/learning/kumalive/KumalivePoll.hbm.xml (.../KumalivePoll.hbm.xml) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -13,6 +13,20 @@
+
+
+
+
> voters = new ArrayList>();
private final JSONArray votersJSON = new JSONArray();
private boolean finished = false;
- private boolean votesShown = false;
- private boolean votersShown = false;
+ private boolean votesReleased = false;
+ private boolean votersReleased = false;
private KumalivePollDTO(Long pollId) {
this.pollId = pollId;
@@ -211,6 +211,9 @@
case "votePoll":
votePoll(requestJSON, session);
break;
+ case "releasePollResults":
+ releasePollResults(requestJSON, session);
+ break;
case "finishPoll":
finishPoll(requestJSON, session);
break;
@@ -408,10 +411,10 @@
boolean voted = participant.vote != null && kumalive.poll.pollId != null
&& participant.vote.pollId.equals(kumalive.poll.pollId);
// put them in response only if teacher released them and user voted
- if (!kumalive.poll.votesShown || (!voted && !kumalive.poll.finished)) {
+ if (!kumalive.poll.votesReleased || (!voted && !kumalive.poll.finished)) {
learnerPollJSON.remove("votes");
}
- if (!kumalive.poll.votersShown || (!voted && !kumalive.poll.finished)) {
+ if (!kumalive.poll.votersReleased || (!voted && !kumalive.poll.finished)) {
learnerPollJSON.remove("voters");
}
if (voted) {
@@ -674,6 +677,39 @@
}
/**
+ * Allow learners to see votes and/or voters
+ */
+ private void releasePollResults(JSONObject requestJSON, Session websocket) throws IOException, JSONException {
+ Integer organisationId = Integer
+ .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_ORGANISATION_ID).get(0));
+
+ User user = getUser(websocket);
+ Integer userId = user.getUserId();
+
+ if (!KumaliveWebsocketServer.getSecurityService().hasOrgRole(organisationId, userId,
+ new String[] { Role.GROUP_MANAGER, Role.MONITOR }, "kumalive poll release results", false)) {
+ String warning = "User " + userId + " is not a monitor of organisation " + organisationId;
+ logger.warn(warning);
+ return;
+ }
+
+ KumaliveDTO kumalive = kumalives.get(organisationId);
+ kumalive.poll.votersReleased |= requestJSON.optBoolean("votersReleased", false);
+ kumalive.poll.votesReleased |= kumalive.poll.votersReleased || requestJSON.optBoolean("votesReleased", false);
+ KumaliveWebsocketServer.getKumaliveService().releasePollResults(kumalive.poll.pollId,
+ kumalive.poll.votesReleased, kumalive.poll.votersReleased);
+ kumalive.poll.pollJSON.put("votesReleased", kumalive.poll.votesReleased);
+ kumalive.poll.pollJSON.put("votersReleased", kumalive.poll.votersReleased);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Teacher " + userId + " released votes/voters ( " + kumalive.poll.votesReleased + "/"
+ + kumalive.poll.votersReleased + ") of poll " + kumalive.poll.pollId + " in Kumalive "
+ + kumalive.id);
+ }
+ sendRefresh(kumalive);
+ }
+
+ /**
* Tell learners that the teacher started a poll
*/
private void finishPoll(JSONObject requestJSON, Session websocket) throws IOException, JSONException {
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/model/KumalivePoll.java
===================================================================
diff -u -redcf26c6dbd1e4ff36858d876e908774abb7910d -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/model/KumalivePoll.java (.../KumalivePoll.java) (revision edcf26c6dbd1e4ff36858d876e908774abb7910d)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/model/KumalivePoll.java (.../KumalivePoll.java) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -34,6 +34,8 @@
private Long pollId;
private Kumalive kumalive;
private String name;
+ private Boolean votesReleased;
+ private Boolean votersReleased;
private Date startDate;
private Date finishDate;
private Set answers;
@@ -72,6 +74,22 @@
this.name = name;
}
+ public Boolean getVotesReleased() {
+ return votesReleased;
+ }
+
+ public void setVotesReleased(Boolean votesReleased) {
+ this.votesReleased = votesReleased;
+ }
+
+ public Boolean getVotersReleased() {
+ return votersReleased;
+ }
+
+ public void setVotersReleased(Boolean votersReleased) {
+ this.votersReleased = votersReleased;
+ }
+
public Date getStartDate() {
return startDate;
}
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/service/IKumaliveService.java
===================================================================
diff -u -r00c630a99ddb827c772bd0fc0d8d903cc0079f7e -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/service/IKumaliveService.java (.../IKumaliveService.java) (revision 00c630a99ddb827c772bd0fc0d8d903cc0079f7e)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/service/IKumaliveService.java (.../IKumaliveService.java) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -68,4 +68,6 @@
void finishPoll(Long pollId) throws JSONException;
void saveVote(Long answerId, Integer userId);
+
+ void releasePollResults(Long pollId, boolean votesReleased, boolean votersReleased);
}
\ No newline at end of file
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/service/KumaliveService.java
===================================================================
diff -u -r00c630a99ddb827c772bd0fc0d8d903cc0079f7e -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/service/KumaliveService.java (.../KumaliveService.java) (revision 00c630a99ddb827c772bd0fc0d8d903cc0079f7e)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/kumalive/service/KumaliveService.java (.../KumaliveService.java) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -595,6 +595,17 @@
}
/**
+ * Set whether learners can see vote results and voters' names
+ */
+ @Override
+ public void releasePollResults(Long pollId, boolean votesReleased, boolean votersReleased) {
+ KumalivePoll poll = (KumalivePoll) kumaliveDAO.find(KumalivePoll.class, pollId);
+ poll.setVotesReleased(votesReleased || votersReleased);
+ poll.setVotersReleased(votersReleased);
+ kumaliveDAO.update(poll);
+ }
+
+ /**
* Finishes a poll, i.e. prevents learners from voting
*/
@Override
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml
===================================================================
diff -u -r5b60c76a61d420733e2c4c96513249cb9a65a484 -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision 5b60c76a61d420733e2c4c96513249cb9a65a484)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -100,6 +100,7 @@
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
Index: lams_learning/web/css/kumalive.scss
===================================================================
diff -u -r713741e9ab4f79f0d97486155f1f3e351b3c460d -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/web/css/kumalive.scss (.../kumalive.scss) (revision 713741e9ab4f79f0d97486155f1f3e351b3c460d)
+++ lams_learning/web/css/kumalive.scss (.../kumalive.scss) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -59,7 +59,7 @@
display: none;
}
-#pollSetupButtons {
+#pollSetupButtons, #pollSetup h3 {
text-align: center;
}
Index: lams_learning/web/includes/javascript/kumalive.js
===================================================================
diff -u -r713741e9ab4f79f0d97486155f1f3e351b3c460d -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/web/includes/javascript/kumalive.js (.../kumalive.js) (revision 713741e9ab4f79f0d97486155f1f3e351b3c460d)
+++ lams_learning/web/includes/javascript/kumalive.js (.../kumalive.js) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -185,6 +185,8 @@
});
$('#pollSetupCancelButton').click(setupPollCancel);
$('#pollSetupStartButton').click(startPoll);
+ $('#pollRunReleaseVotesButton').click(releaseVotes);
+ $('#pollRunReleaseVotersButton').click(releaseVoters);
$('#pollRunFinishButton').click(finishPoll);
$('#pollRunCloseButton').click(closePoll);
$('#finishButton').click(finish).show();
@@ -337,7 +339,7 @@
$('#pollCell').hide();
$('#actionCell .pollButton').prop('disabled', false);
- $('#learnersCell .learner .badge').remove();
+ $('#learnersCell .learner .badge, #pollCell .pollVoters').remove();
}
return;
}
@@ -756,6 +758,16 @@
// extra options for teacher
if (roleTeacher) {
+ if (poll.votesReleased)
+ $('#pollRunReleaseVotesButton').hide();
+ else {
+ $('#pollRunReleaseVotesButton').show();
+ }
+ if (poll.votersReleased)
+ $('#pollRunReleaseVotersButton').hide();
+ else {
+ $('#pollRunReleaseVotersButton').show();
+ }
if (poll.finished) {
$('#pollRunCloseButton').show();
} else {
@@ -876,6 +888,34 @@
}
/**
+ * Tell server that votes were released
+ */
+function releaseVotes() {
+ if (!confirm(LABELS.POLL_RELEASE_VOTES_CONFIRM)){
+ return;
+ }
+ kumaliveWebsocket.send(JSON.stringify({
+ 'type' : 'releasePollResults',
+ 'votesReleased' : true
+ }));
+ $('#pollRunReleaseVotesButton').hide();
+}
+
+/**
+ * Tell server that voters were released
+ */
+function releaseVoters() {
+ if (!confirm(LABELS.POLL_RELEASE_VOTERS_CONFIRM)){
+ return;
+ }
+ kumaliveWebsocket.send(JSON.stringify({
+ 'type' : 'releasePollResults',
+ 'votersReleased' : true
+ }));
+ $('#pollRunReleaseVotesButton, #pollRunReleaseVotersButton').hide();
+}
+
+/**
* Prevent learners from voting
*/
function finishPoll() {
Index: lams_learning/web/kumalive/kumalive.jsp
===================================================================
diff -u -r713741e9ab4f79f0d97486155f1f3e351b3c460d -rc32fc3365594b9d572ea07094f580218cf952c93
--- lams_learning/web/kumalive/kumalive.jsp (.../kumalive.jsp) (revision 713741e9ab4f79f0d97486155f1f3e351b3c460d)
+++ lams_learning/web/kumalive/kumalive.jsp (.../kumalive.jsp) (revision c32fc3365594b9d572ea07094f580218cf952c93)
@@ -40,7 +40,11 @@
SPEAK_FINISH : '',
- POLL_FINISH_CONFIRM : decoderDiv.html('').text()
+ POLL_FINISH_CONFIRM : decoderDiv.html('').text(),
+
+ POLL_RELEASE_VOTES_CONFIRM : decoderDiv.html('').text(),
+
+ POLL_RELEASE_VOTERS_CONFIRM : decoderDiv.html('').text()
};
@@ -74,7 +78,7 @@
-
+
@@ -96,6 +100,7 @@