19 package org.turro.students.www;
21 import java.util.Date;
22 import org.turro.action.Contacts;
23 import org.turro.auth.Authentication;
24 import org.turro.collections.KeyValueMap;
25 import org.turro.elephant.TemplateControl;
26 import org.turro.elephant.context.Application;
27 import org.turro.entities.EntityCombobox;
28 import org.turro.jpa.Dao;
29 import org.turro.marker.MarkerHelper;
30 import org.turro.plugin.contacts.IContact;
31 import org.turro.students.db.StudentsPU;
32 import org.turro.students.entities.Challenge;
33 import org.turro.students.entities.Response;
34 import org.turro.students.mail.ChallengeChangedNotification;
35 import org.turro.students.mail.NewResponseNotification;
36 import org.turro.zkoss.text.WikiEditor;
37 import org.zkoss.zk.ui.select.annotation.Listen;
38 import org.zkoss.zk.ui.select.annotation.Wire;
39 import org.zkoss.zul.Div;
40 import org.zkoss.zul.Hlayout;
41 import org.zkoss.zul.Html;
50 private String contextPath;
52 @Wire(
"#studentbox")
private Div studentbox;
54 @Wire(
"#students")
private Hlayout students;
57 @Listen(
"onChange=#text")
62 @Listen(
"onClick=#addStudent")
68 @Listen(
"onClick=#save")
71 boolean isNew = response.
getId() ==
null;
72 response = getDao().saveObject(response);
74 if(response.
getId() !=
null && response.
getId() > 0) {
88 @Listen(
"onClick=#cancel")
90 if(response.
getId() !=
null && response.
getId() > 0) {
103 this.contextPath = contextPath;
107 this.response = response;
122 private void checkResponse() {
124 if(response ==
null) {
125 if(kvm !=
null && !kvm.isEmpty() && kvm.containsKey(
"item")) {
126 Long responseId = kvm.get(Long.class,
"item");
128 response = getDao().find(
Response.class, responseId);
132 if(response ==
null) {
133 if(kvm !=
null && !kvm.isEmpty() && kvm.containsKey(
"challenge")) {
134 Challenge challenge =
null;
135 Long challengeId = kvm.get(Long.class,
"challenge");
136 if(challengeId > 0) {
137 challenge = getDao().find(Challenge.class, challengeId);
139 IContact contact = Authentication.getIContact();
140 if(challenge !=
null && (contact.isStudent() || contact.isAdmin())) {
141 response =
new Response();
146 Application.getApplication().sendRedirect(contextPath);
149 Application.getApplication().sendRedirect(contextPath);
154 private void initComponents() {
155 if(response.
getId() !=
null && response.
getId() > 0) {
156 IContact contact = Authentication.getIContact();
157 if(contact.isAdmin() || contact.isStudent()) {
163 Application.getApplication().sendRedirect(contextPath);
169 studentbox.setVisible(
false);
173 private void updateStudents() {
174 students.getChildren().clear();
176 students.appendChild(
new Html(
177 "<div class='ui label'>" +
188 private Dao getDao() {
190 _dao =
new StudentsPU();
static IContact getIContact()
abstract void sendRedirect(String uri)
static Application getApplication()
static KeyValueMap getObfuscatedParameters()
static String setObfuscatedRightNowPars(String parameters)
void setCreation(Date creation)
void setWikiText(String wikiText)
void setChallenge(Challenge challenge)
List< IContact > getStudentList()
void addStudent(IContact contact)
void setContextPath(String contextPath)
void setResponse(Response response)
void setImageFolder(String folder)
void setValue(String value)
void setFileFolder(String folder)
void setReadOnlyRepository(boolean readOnlyRepository)