Skip to content
Snippets Groups Projects
Commit 750bdee2 authored by Daniel Vogel's avatar Daniel Vogel
Browse files

Merge branch 'master' of github.com:thm-projects/arsnova-backend into public_pool

parents 3d575316 4590d8b0
No related merge requests found
......@@ -102,6 +102,9 @@ public class ConfigurationController extends AbstractController {
@Value("${question.answer-option-limit:8}")
private String answerOptionLimit;
@Value("${upload.filesize_b:}")
private String maxUploadFilesize;
@Value("${question.parse-answer-option-formatting:false}")
private String parseAnswerOptionFormatting;
......@@ -183,6 +186,9 @@ public class ConfigurationController extends AbstractController {
if (!"".equals(demoSessionKey)) {
config.put("demoSessionKey", demoSessionKey);
}
if (!"".equals(maxUploadFilesize)) {
config.put("maxUploadFilesize", maxUploadFilesize);
}
config.put("answerOptionLimit", Integer.valueOf(answerOptionLimit));
config.put("parseAnswerOptionFormatting", Boolean.valueOf(parseAnswerOptionFormatting));
......
......@@ -28,8 +28,14 @@ import com.fourspaces.couchdb.View;
public class NovaView extends View {
public enum StaleMode {
NONE, OK, UPDATE_AFTER
}
protected String keys;
protected StaleMode stale = StaleMode.NONE;
public NovaView(final String fullname) {
super(fullname);
}
......@@ -89,6 +95,10 @@ public class NovaView extends View {
this.keys = toJsonArray(keys.toArray(new String[keys.size()]));
}
public void setStale(StaleMode stale) {
this.stale = stale;
}
@Override
public String getQueryString() {
final String tempQuery = super.getQueryString();
......@@ -102,6 +112,16 @@ public class NovaView extends View {
}
query.append("keys=" + keys);
}
if (stale != null && stale != StaleMode.NONE) {
if (query.length() > 0) {
query.append("&");
}
if (stale == StaleMode.OK) {
query.append("stale=ok");
} else if (stale == StaleMode.UPDATE_AFTER) {
query.append("stale=update_after");
}
}
if (query.length() == 0) {
return null;
......
......@@ -410,8 +410,15 @@ public class QuestionService implements IQuestionService, ApplicationEventPublis
} else if (question.getPiRound() < 1 || question.getPiRound() > 2) {
question.setPiRound(oldQuestion.getPiRound() > 0 ? oldQuestion.getPiRound() : 1);
}
final Question result = databaseDao.updateQuestion(question);
return databaseDao.updateQuestion(question);
if(!oldQuestion.isActive() && question.isActive()) {
final NewQuestionEvent event = new NewQuestionEvent(this, result, session);
this.publisher.publishEvent(event);
}
return result;
}
@Override
......
This diff is collapsed.
......@@ -18,8 +18,7 @@
*/
package de.thm.arsnova.dao;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
......@@ -27,6 +26,8 @@ import java.util.Arrays;
import org.junit.Test;
import de.thm.arsnova.dao.NovaView.StaleMode;
public class NovaViewTest {
@Test
......@@ -133,6 +134,21 @@ public class NovaViewTest {
assertEncodedEquals("keys", "[]", v5.getQueryString());
}
@Test
public void shouldSupportStaleViews() {
final NovaView v1 = new NovaView(null);
final NovaView v2 = new NovaView(null);
final NovaView v3 = new NovaView(null);
final NovaView v4 = new NovaView(null);
v1.setStale(StaleMode.NONE);
v2.setStale(StaleMode.OK);
v3.setStale(StaleMode.UPDATE_AFTER);
assertNull(v1.getQueryString());
assertEncodedEquals("stale", "ok", v2.getQueryString());
assertEncodedEquals("stale", "update_after", v3.getQueryString());
assertNull(v4.getQueryString());
}
private void assertEncodedEquals(final String key, final String expected, final String actual) {
try {
assertEquals(key + "=" + URLEncoder.encode(expected, "UTF-8"), actual);
......
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment