Commit 246af718 by Tuomas Riihimäki

Finaaliversio INS XII

1 parent d8052db3
......@@ -13,6 +13,7 @@ import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
......@@ -44,6 +45,7 @@ public class Poll extends GenericEventChild implements Serializable {
@Column(name = "description", nullable = true)
private String description;
@OrderBy("sort")
@OneToMany(mappedBy = "poll", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<PollQuestion> questions = new ArrayList<PollQuestion>();
......
......@@ -30,6 +30,9 @@ public class PollQuestion extends GenericEventChild {
private static final long serialVersionUID = 821112669474215823L;
private static final Integer COLS = 40;
private Integer characters = 200;
@JoinColumns({
@JoinColumn(name = "poll_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
......@@ -39,7 +42,6 @@ public class PollQuestion extends GenericEventChild {
@OneToMany(mappedBy = "question", cascade = CascadeType.ALL)
private List<PossibleAnswer> answers = new ArrayList<PossibleAnswer>();
@Lob
private String question;
@Column(nullable = false)
......@@ -101,4 +103,27 @@ public class PollQuestion extends GenericEventChild {
this.answers = answers;
}
public void setCharacters(Integer characters) {
this.characters = characters;
}
public Integer getCharacters() {
return characters;
}
public boolean isTextfield() {
if (characters > COLS) {
return true;
}
return false;
}
public int getCols() {
return COLS;
}
public int getRows() {
return this.getCharacters() / COLS;
}
}
......@@ -100,6 +100,26 @@ public class Product extends GenericEventChild {
}
public BigDecimal getSoldCash() {
BigDecimal tot = BigDecimal.ZERO;
for (AccountEvent ac : this.getAccountEvents()) {
if (ac.isCash()) {
tot = tot.add(ac.getQuantity());
}
}
return tot;
}
public BigDecimal getSoldBill() {
BigDecimal tot = BigDecimal.ZERO;
for (AccountEvent ac : this.getAccountEvents()) {
if (!ac.isCash()) {
tot = tot.add(ac.getQuantity());
}
}
return tot;
}
public String getName() {
return name;
}
......
......@@ -10,16 +10,8 @@
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/insomnia1/sidebartemplate.xhtml">
<ui:param name="rendered" value="#{sessionHandler.isLoggedIn()}" />
<ui:param name="rendered" value="false" />
<ui:define name="sidebarcontent">
<ul>
<li><h:link outcome="/user/sendPicture" value="#{i18n['user.sendPicture']}"/></li>
<li><h:link outcome="/user/changePassword" value="#{i18n['user.changePassword']}"/></li>
<li><h:link outcome="/user/accountEvents" value="#{i18n['user.accountEvents']}"/></li>
<li><h:link outcome="/place/myGroups" value="#{i18n['user.myGroups']}"/></li>
<li><h:link outcome="/place/insertToken" value="#{i18n['user.insertToken']}"/></li>
</ul>
</ui:define>
</ui:composition>
......
......@@ -6,17 +6,23 @@
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.poll.start" />
<ui:param name="thispage" value="page.poll.answer" />
<ui:define name="content">
<h:messages />
<h1>#{pollView.poll.name}</h1>
<p>#{pollView.poll.description}</p>
<h:form id="answerForm">
<h:dataTable border="0" id="questions" value="#{pollView.currentPage}" var="question">
<h:column>
<h:outputText value="#{question.question.question}" />
</h:column>
<h:column>
<h:inputTextarea id="freecell" cols="50" rows="7" value="#{question.textAnswer.answerText}" rendered="#{question.freeText}" />
<h:inputText id="freecell" size="#{question.question.characters}" value="#{question.textAnswer.answerText }"
rendered="#{question.freeText and !question.question.textfield}" />
<h:inputTextarea id="freecellarea" cols="#{question.question.cols}" rows="#{question.question.rows}"
value="#{question.textAnswer.answerText}" rendered="#{question.freeText and question.question.textfield}" />
<h:selectOneRadio id="selectone" layout="pageDirection" converter="#{pollAnswerConverter}"
rendered="#{!question.freeText and question.question.choices eq 1}" value="#{question.oneSelected}">
<f:selectItems var="ans" itemLabel="#{ans.choice.answer}" value="#{question.answers}" />
......
......@@ -6,16 +6,13 @@
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.eventorg.list" />
<ui:param name="thispage" value="page.poll.start" />
<ui:define name="content">
<h1>Kyselyt</h1>
#{pollView.initPollList()}
<h:form>
<h:dataTable border="1" id="maps" value="#{pollView.polls}" var="poll">
<h:dataTable border="0" id="maps" value="#{pollView.polls}" var="poll">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['poll.name']}" />
</f:facet>
<h:outputText value="#{poll.name}" />
</h:column>
......
......@@ -6,12 +6,14 @@
xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.eventorg.list" />
<ui:param name="thispage" value="page.poll.answered" />
<ui:define name="content">
<h1>Kiitoksia vastauksistasi</h1>
<p>Nähdään ensi vuonna uudestaan.</p>
<h1>Vastauksesi on tallennettu onnistuneesti!</h1>
<p>Kiitos ja nähdään ensi vuonna uudestaan!</p>
</ui:define>
</ui:composition>
</h:body>
......
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface>
......@@ -15,8 +12,7 @@
<composite:implementation>
<h:form>
<h:dataTable border="1" id="product" value="#{productView.products}"
var="product">
<h:dataTable border="1" id="product" value="#{productView.products}" var="product">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.name']}" />
......@@ -31,10 +27,24 @@
</h:column>
<h:column>
<h:commandButton action="#{productView.edit()}"
value="#{i18n['product.edit']}" />
<h:commandButton action="#{productView.edit()}" value="#{i18n['product.edit']}" />
</h:column>
<h:column>
<f:facet name="header">
Käteinen
</f:facet>
<h:outputText value="#{product.soldCash}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
Laskutettu
</f:facet>
<h:outputText value="#{product.soldBill}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:outputText>
</h:column>
</h:dataTable>
</h:form>
......
......@@ -31,6 +31,8 @@ public class PollView extends GenericView {
private Integer thisPage = 1;
private Poll poll;
private static final Logger logger = LoggerFactory.getLogger(PollView.class);
public void initPollList() {
......@@ -50,9 +52,9 @@ public class PollView extends GenericView {
public String beginPoll() {
thisPage = 1;
Poll poll = polls.getRowData();
setPoll(polls.getRowData());
pages = new HashMap<Integer, List<QuestionWrapper>>();
for (PollQuestion q : poll.getQuestions()) {
for (PollQuestion q : getPoll().getQuestions()) {
if (!pages.containsKey(q.getPage())) {
pages.put(q.getPage(), new LinkedList<QuestionWrapper>());
}
......@@ -63,12 +65,13 @@ public class PollView extends GenericView {
public String savePoll() {
if (validate(this)) {
pollBean.createAnswers(createAnswers());
}
pages = null;
polls = null;
setPoll(null);
return "/poll/thankYou";
}
......@@ -100,6 +103,14 @@ public class PollView extends GenericView {
}
public void setPoll(Poll poll) {
this.poll = poll;
}
public Poll getPoll() {
return poll;
}
public class QuestionWrapper {
private PollQuestion question;
......
......@@ -132,24 +132,79 @@ public class TestDataView {
end.add(Calendar.MONTH, 1);
poll.setEnd(end);
createTextQuestion(poll, "Palautetta järjestäjille");
createTextQuestion(poll, 10, "Millainen oli yleinen fiilis tapahtumassa?");
createTextQuestion(poll, 20, "Mitä pidit tapahtuman kilpailuista?");
createTextQuestion(poll, 30, "Mitä mieltä olit tapahtuman kilpailujen aikataulusta ja oliko neljäpäiväinen tapahtuma hyvä juttu?");
createTextQuestion(poll, 40, "Muu palaute tapahtumasta:");
createTextQuestion(poll, "Mikä InsomniaGamessa oli parasta?");
createTextQuestion(poll, "Mikä InsomniaGamessa oli huonointa?");
createTextQuestion(poll, "Miten olisit halunnut saada tietoa InsomniaGameen liittyvistä tehtävistä?");
createTextQuestion(poll, "Palautteesi InsomniaGamen järjestäjille:");
createTextQuestion(poll, 60, "Mikä InsomniaGamessa oli parasta?");
createTextQuestion(poll, 70, "Mikä InsomniaGamessa oli huonointa?");
createTextQuestion(poll, 80, "Miten olisit halunnut saada tietoa InsomniaGameen liittyvistä tehtävistä?");
createTextQuestion(poll, 90, "Palautteesi InsomniaGamen järjestäjille:");
pollbean.createPoll(poll);
Poll poll2 = new Poll(ev, "Gallup");
Calendar end2 = Calendar.getInstance();
end2.add(Calendar.MONTH, 1);
poll2.setEnd(end);
createTextQuestion(poll2, 10, "Syntymävuotesi?", 8);
createMulticoice(poll2, 50, "Omistatko älypuhelimen?", "En", "Kyllä", "Olen hankkimassa seuraavaksi älypuhelmen");
createMulticoice(poll2, 60, "Miten usein pelaat mobiilipelejä?", "En pelaa mobiilipelejä", "Olen joskus kokeillut ", "Pelaan lähes viikottain", "Pelaan lähes päivittäin");
createMulticoice(poll2, 70, "Miten usein pelaat pelikonsolilla tai tietokoneella?", "En pelaa", "Pelaan harvoin", "Pelaan kerran, pari viikossa", "Pelaan päivittäin");
createMulticoice(poll2, 80, "Oletko kokeillut opetuspelejä? Esimerkiksi nettiselaimella tai kännykällä?", "En ole kokeillut", "Olen kokeillut", "Käytän usein");
createTextQuestion(poll2, 90, "Millaisen opetuspelin kokisit sekä hyödyllisenä että hauskana?");
createMulticoice(poll2, 95, "Kokisitko roolipeleistä tutut kokemuspisteet ja kokemustasojen tavoittelun motivaatiota kasvattanava asiana oppimispeleissä?", "Kyllä", "Ei");
createMulticoice(poll2, 100, "Oletko käyttänyt sijaintitietoon perustuvia palveluja, kuten Google Latitude tai Foursquare?", "En ole kokeillut", "Olen kokeillut", "Käytän usein");
createTextQuestion(poll2, 110, "Millaisia käyttötapoja näkisit sijaintitietoon perustuvilla peleillä tai palveluilla oppimiskäytössä?");
createMulticoice(poll2, 120, "Käytätkö sosiaalisen median palveluita, kuten Facebookia tai IRC-Galleriaa?", "En ole kokeillut", "Olen kokeillut", "Käytän usein");
createTextQuestion(poll2, 130, "Millaisia käyttötapoja näkisit sosiaalisen mediaan perustuvilla palveluilla oppimiskäytössä?");
createTextQuestion(poll2, 140, "Olet ehkä kuullut termin \"pilvipalvelut\". Miltä kuulostaisi ajatus siitä että pelikonsoli ei fyysisesti olisikaan kotonasi, vaan pelien sisältö tulisi suoraan verkkopalvelusta?");
pollbean.createPoll(poll2);
return null;
}
private void createTextQuestion(Poll poll, String question) {
private void createMulticoice(Poll poll2, Integer sort, String question, String... answers) {
PollQuestion pollq = new PollQuestion(poll2, question);
pollq.setSort(sort);
poll2.getQuestions().add(pollq);
Integer anssort = 10;
for (String ans : answers) {
PossibleAnswer pans = new PossibleAnswer(pollq, ans);
pans.setSort(anssort);
pollq.getAnswers().add(pans);
anssort += 10;
}
}
private PollQuestion createTextQuestion(Poll poll, int sort, String string, int chars) {
PollQuestion ret = createTextQuestion(poll, sort, string);
ret.setCharacters(chars);
return ret;
}
private PollQuestion createTextQuestion(Poll poll, int sort, String question) {
PollQuestion q1 = new PollQuestion(poll, question);
q1.setSort(sort);
poll.getQuestions().add(q1);
PossibleAnswer vapaa = new PossibleAnswer(q1, "");
vapaa.setTextanswer(true);
q1.getAnswers().add(vapaa);
return q1;
}
}
......@@ -102,3 +102,8 @@ page.game.list.header=Insomnia Game
page.poll.start.pagegroup=poll
page.poll.start.header=Kysely
page.poll.answer.pagegroup=poll
page.poll.answer.header=Kysely
page.poll.answered.pagegroup=poll
page.poll.answered.header=Kiitos vastauksestasi
......@@ -69,7 +69,7 @@ role.edit.save=Tallenna
topmenu.game=Insomnia Game
topmenu.poll=Kysely
topmenu.poll=Kyselyt
game.gamepoints=Insomnia Game pisteet:
......@@ -319,7 +319,8 @@ reader.tag=Tag
reader.user=Kyttj
# Validationmessages
poll.save=Lhet vastauksesi
poll.answer=Vastaa kyselyyn
javax.validation.constraints.AssertFalse.message=must be false
javax.validation.constraints.AssertTrue.message=must be true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!