Project

General

Profile

Bug #10435 » quizzQuestionsNew_jsp.java

Sebastien Vuillet, 01/24/2019 12:01 PM

 
1
/*
2
 * Generated by the Jasper component of Apache Tomcat
3
 * Version: WildFly Full 14.0.1.Final (WildFly Core 6.0.2.Final) - 2.0.13.Final
4
 * Generated at: 2019-01-23 11:17:20 UTC
5
 * Note: The last modified time of this file was set to
6
 *       the last modified time of the source file after
7
 *       generation to assist with modification tracking.
8
 */
9
package org.apache.jsp.quizz.jsp;
10

    
11
import javax.servlet.*;
12
import javax.servlet.http.*;
13
import javax.servlet.jsp.*;
14
import org.silverpeas.core.util.StringUtil;
15
import org.silverpeas.core.util.WebEncodeHelper;
16
import org.silverpeas.core.util.file.FileUploadUtil;
17
import org.silverpeas.core.util.URLUtil;
18
import org.silverpeas.core.util.MultiSilverpeasBundle;
19
import org.silverpeas.core.admin.user.model.UserDetail;
20
import org.silverpeas.core.admin.component.model.ComponentInstLight;
21
import org.silverpeas.components.quizz.QuizzException;
22
import org.silverpeas.components.quizz.QuestionForm;
23
import org.silverpeas.components.quizz.QuestionHelper;
24
import org.silverpeas.core.util.file.FileServerUtils;
25
import org.silverpeas.core.web.util.viewgenerator.html.GraphicElementFactory;
26
import org.silverpeas.core.web.util.viewgenerator.html.board.Board;
27
import org.silverpeas.core.util.ResourceLocator;
28
import org.silverpeas.core.questioncontainer.score.model.ScoreDetail;
29
import org.silverpeas.core.questioncontainer.question.model.Question;
30
import org.silverpeas.core.questioncontainer.container.model.QuestionContainerHeader;
31
import org.silverpeas.core.questioncontainer.container.model.QuestionContainerDetail;
32
import org.silverpeas.core.questioncontainer.result.model.QuestionResult;
33
import org.silverpeas.core.web.util.viewgenerator.html.window.Window;
34
import org.silverpeas.core.web.util.viewgenerator.html.browsebars.BrowseBar;
35
import org.silverpeas.core.web.util.viewgenerator.html.frame.Frame;
36
import org.silverpeas.core.web.util.viewgenerator.html.buttons.Button;
37
import org.silverpeas.core.web.util.viewgenerator.html.buttonpanes.ButtonPane;
38
import org.silverpeas.core.web.util.viewgenerator.html.iconpanes.IconPane;
39
import org.silverpeas.core.web.util.viewgenerator.html.icons.Icon;
40
import org.silverpeas.core.web.util.viewgenerator.html.Encode;
41
import org.silverpeas.core.util.file.FileRepositoryManager;
42
import org.silverpeas.core.questioncontainer.answer.model.Answer;
43
import org.silverpeas.core.util.SettingBundle;
44
import org.silverpeas.core.web.util.viewgenerator.html.tabs.TabbedPane;
45
import org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayPane;
46
import org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayColumn;
47
import java.util.Collection;
48
import java.util.Iterator;
49
import org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayLine;
50
import org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayCellText;
51
import org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayCellLink;
52
import java.util.Date;
53
import java.util.List;
54
import java.util.Vector;
55
import java.util.Map;
56
import java.util.HashMap;
57
import java.io.IOException;
58
import org.apache.commons.fileupload.FileItem;
59
import org.silverpeas.components.quizz.control.QuizzSessionController;
60
import org.silverpeas.core.util.DateUtil;
61
import org.silverpeas.core.util.LocalizationBundle;
62
import java.util.ArrayList;
63
import org.silverpeas.core.web.util.viewgenerator.html.operationpanes.OperationPane;
64
import org.silverpeas.core.persistence.jdbc.DBUtil;
65
import org.silverpeas.core.web.util.viewgenerator.html.GraphicElementFactory;
66
import org.silverpeas.core.web.util.viewgenerator.html.board.Board;
67
import org.silverpeas.core.web.util.viewgenerator.html.buttons.Button;
68
import org.silverpeas.core.web.util.viewgenerator.html.operationpanes.OperationPane;
69
import org.silverpeas.core.web.util.viewgenerator.html.frame.Frame;
70
import org.silverpeas.core.web.util.viewgenerator.html.window.Window;
71
import org.silverpeas.core.util.WebEncodeHelper;
72

    
73
public final class quizzQuestionsNew_jsp extends org.apache.jasper.runtime.HttpJspBase
74
    implements org.apache.jasper.runtime.JspSourceDependent,
75
                 org.apache.jasper.runtime.JspSourceImports {
76

    
77

    
78
//Display the quizz header
79
String displayQuizzHeader(QuizzSessionController quizzScc, QuestionContainerHeader quizzHeader, MultiSilverpeasBundle resources, GraphicElementFactory gef) {
80
  String title = quizzHeader.getTitle();
81
  String description = quizzHeader.getDescription();
82
  String comment = quizzHeader.getComment();
83

    
84
  Board board = gef.getBoard();
85
  String r = "";
86
  r += board.printBefore();
87
  r += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" width=\"100%\">";
88
  r += "<tr><td>";
89
  r += "<span class=\"titreFenetre\">"+WebEncodeHelper.javaStringToHtmlString(title)+"</span>";
90
  r += "<blockquote>";
91
  r += "<span class=\"sousTitreFenetre\">"+WebEncodeHelper.javaStringToHtmlParagraphe(description)+"</span>";
92
  if (StringUtil.isDefined(comment)) {
93
    r += "<br><br><span class=txttitrecol>"+resources.getString("QuizzNotice")+"</span>&nbsp;&nbsp;";
94
    r += WebEncodeHelper.javaStringToHtmlParagraphe(comment)+"";
95
  }
96
  r += "</blockquote>";
97
  r += "</td></tr></table>";
98
  r += board.printAfter();
99
  return r;
100
}
101

    
102
String displayQuizz(QuestionContainerDetail quizz, GraphicElementFactory gef, String m_context, QuizzSessionController quizzScc, MultiSilverpeasBundle resources, SettingBundle settings, JspWriter out) throws QuizzException {
103
  String r = "";
104
  Question question = null;
105
  Collection<Answer> answers = null;
106
	try{
107
		if (quizz != null) {
108
			QuestionContainerHeader quizzHeader = quizz.getHeader();
109
			Collection<Question> questions = quizz.getQuestions();
110
			//Display the quizz header
111
			r += displayQuizzHeader(quizzScc, quizzHeader, resources, gef);
112

    
113
			//Display the questions
114
			r += "<form name=\"quizz\" Action=\"quizzQuestionsNew.jsp\" Method=\"Post\">";
115
			r += "<input type=\"hidden\" name=\"Action\">";
116
			r += "<input type=\"hidden\" name=\"NbQuestions\" value=\""+questions.size()+"\">";
117
			r += "<input type=\"hidden\" name=\"QuizzId\" value=\""+quizzHeader.getPK().getId()+"\">";
118

    
119
			Iterator<Question> itQ = questions.iterator();
120
			int i = 1;
121
			while (itQ.hasNext()) {
122
				  question = (Question) itQ.next();
123
				  r += displayQuestion(quizzScc, question, i, m_context, settings, gef, resources);
124
				  i++;
125

    
126
			}
127
		} else {
128
			r += "<table><tr><td>"+resources.getString("QuizzUnavailable")+"</td></tr>";
129
		}
130
	} catch (Exception e){
131
		throw new QuizzException ("quizzQuestionNew_JSP.displayQuizz",QuizzException.WARNING,"Quizz.EX_CANNOT_DISPLAY_QUIZZ",e);
132
	}
133

    
134
  return r;
135
}
136

    
137
List<String> displayQuestions(QuestionContainerDetail quizz, int roundId,GraphicElementFactory gef, String m_context,QuizzSessionController quizzScc, MultiSilverpeasBundle resources, SettingBundle settings, Frame frame, JspWriter out) throws QuizzException {
138
  String r = "";
139
  String s = "";
140
  Question question = null;
141
  List<String> displayQuestions = new ArrayList<String>();
142
	try{
143
		if (quizz != null) {
144
			QuestionContainerHeader quizzHeader = quizz.getHeader();
145
			int nbQuestionsPerPage = quizzHeader.getNbQuestionsPerPage();
146
			int end = nbQuestionsPerPage * roundId;
147
			int begin = end - nbQuestionsPerPage;
148
			Collection<Question> questions = quizz.getQuestions();
149
			int nbQuestions = 0;
150
			if (end <= questions.size()) {
151
				nbQuestions = nbQuestionsPerPage;
152
			} else {
153
				nbQuestions = questions.size() % nbQuestionsPerPage;
154
      }
155
			r += displayQuizzHeader(quizzScc, quizzHeader, resources, gef);
156

    
157
			//Display the questions
158
			r += "<form name=\"quizz\" Action=\"quizzQuestionsNew.jsp\" Method=\"Post\">";
159
			r += "<input type=\"hidden\" name=\"Action\">";
160
			r += "<input type=\"hidden\" name=\"RoundId\">";
161
			r += "<input type=\"hidden\" name=\"NbQuestions\" value=\""+nbQuestions+"\">";
162
			r += "<input type=\"hidden\" name=\"QuizzId\" value=\""+quizzHeader.getPK().getId()+"\">";
163
			Iterator<Question> itQ = questions.iterator();
164
			int i = 1;
165
			int j = 1;
166
			while (itQ.hasNext()) {
167
				  question = (Question) itQ.next();
168
				  if ((i > begin) && (i <= end)) {
169
					  r += displayQuestion(quizzScc, question, j, m_context, settings, gef, resources);
170
					  j++;
171
				  }
172
				  i++;
173
			}
174
			s += "<table width=\"98%\" border=\"0\" cellspacing=\"2\" cellpadding=\"5\">";
175
			s += "<tr><td nowrap>";
176
			s += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" width=\"100%\">";
177
			s += "<tr><td>";
178

    
179
			Button cancelButton = null;
180
			Button voteButton = null;
181
			if ((begin <= 0) && (end < questions.size())) {
182
				  voteButton = (Button) gef.getFormButton(resources.getString("GML.validate"), "javascript:onClick=sendVote('"+(roundId+1)+"')", false);
183
				  s += "<tr><td align=\"center\"><table><tr><td class=intfdcolor51 align=center>"+voteButton.print()+"</td></tr></table></td></tr>";
184
			} else if (end >= questions.size()) {
185
				  voteButton = (Button) gef.getFormButton(resources.getString("GML.validate"), "javascript:onClick=sendVote('end')", false);
186
				  s += "<tr><td align=\"center\"><table><tr><td class=intfdcolor51 align=center>"+voteButton.print()+"</td></tr></table></td></tr>";
187
			} else {
188
				  voteButton = (Button) gef.getFormButton(resources.getString("GML.validate"), "javascript:onClick=sendVote('"+(roundId+1)+"')", false);
189
				  s += "<tr><td align=\"center\"><table><tr><td class=intfdcolor51 align=center>"+voteButton.print()+"</td></tr></table></td></tr>";
190
			}
191
			 s += "</table>";
192
			 s += "</td></tr>";
193
			 s += "</table>";
194
			 s += "</form>";
195
		} else {
196
			r += "<table><tr><td>"+resources.getString("QuizzUnavailable")+"</td></tr></table>";
197
		}
198
		displayQuestions.add(r);
199
		displayQuestions.add(s);
200
	} catch (Exception e){
201
		throw new QuizzException ("quizzQuestionNew_JSP.displayQuestion",QuizzException.WARNING,"Quizz.EX_CANNOT_DISPLAY_QUESTIONS",e);
202
	}
203

    
204
  return displayQuestions;
205
}
206

    
207
String displayQuestion(QuizzSessionController quizzScc, Question question, int i, String m_context, SettingBundle settings, GraphicElementFactory gef, MultiSilverpeasBundle resources) {
208
  Collection<Answer> answers = question.getAnswers();
209
  Board board = gef.getBoard();
210
  String r = "";
211
  r += "<br>";
212
  r += board.printBefore();
213
  r += "<table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">";
214
  r += "<tr><td nowrap>";
215
  r += "<span class=txtlibform>&nbsp;<b>&#149;</b>&nbsp;"+ WebEncodeHelper.javaStringToHtmlString(question.getLabel())+"&nbsp;</span>";
216
  r += " - "+question.getNbPointsMax()+" pts</td>";
217
  r += "<td nowrap align=\"right\">";
218
  r += "<input type=\"hidden\" name=\"cluePenalty_"+i+"\" value=\"0\">";
219

    
220
  if (question.getClue() != null && !question.getClue().equals(""))
221
	{
222
			r += "<a href=\"#\" onClick=\"view_clue("+i+","+question.getFatherId()+","+question.getPK().getId()+","+question.getCluePenalty()+")\">"+resources.getString("QuizzSeeClue")+"</a>";
223
			r += " (" + resources.getString("QuizzPenalty") + "=" + question.getCluePenalty() + " pts)";
224
	}
225
	else
226
		r += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
227
  r += "</table>";
228
  r += board.printAfter();
229
  r += "<br>";
230
  r += board.printBefore();
231
  r += "<table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" >";
232

    
233
  if (question.isOpen()) {
234
        Iterator<Answer> itA = answers.iterator();
235
        while (itA.hasNext()) {
236
            Answer answer = (Answer) itA.next();
237
            String inputValue = answer.getPK().getId()+","+question.getPK().getId();
238
            r += "<input type=\"hidden\" name=\"answer_"+i+"\" value=\""+inputValue+"\">";
239
            r += "<tr><td colspan=\"2\"><textarea name=\"openedAnswer_"+i+"\" cols=\"20\" rows=\"3\"></textarea></td></tr>";
240
        }
241
  }
242
  else
243
  {
244
  	String style = question.getStyle();
245
  	if (style.equals("list"))
246
  	{
247
  		// liste d�roulante
248
       	String selectedStr = "";
249

    
250
          r += "<tr><td><select id=\"answer_"+i+"\" name=\"answer_"+i+"\" >";
251

    
252
          Iterator<Answer> itA = answers.iterator();
253
        while (itA.hasNext())
254
        {
255
        	Answer answer = (Answer) itA.next();
256
        	String inputValue = answer.getPK().getId()+","+question.getPK().getId();
257
              r += "<option value=\""+inputValue+"\" "+selectedStr+">"+ WebEncodeHelper.javaStringToHtmlString(answer.getLabel())+"</option>";
258
        }
259
        r += "</td></tr>";
260
  	}
261
  	else
262
   	{
263
        String inputType = "radio";
264
        if (style.equals("checkbox"))
265
        	inputType = "checkbox";
266
          Iterator<Answer> itA = answers.iterator();
267
          int isOpened = 0;
268
          while (itA.hasNext())
269
          {
270
              Answer answer = (Answer) itA.next();
271
              r += "<tr><td colspan=\"2\"><table width=\"98%\"><tr>";
272
              String inputValue = answer.getPK().getId()+","+question.getPK().getId();
273

    
274
              // traitement de l'affichage des images
275
              if (answer.getImage() == null)
276
	      {
277
            	    r += "<td align=\"left\">&nbsp;</td>";
278
	      }
279
	      else
280
	      {
281
		      	String imageUrl = answer.getImage();
282
		        String url = "";
283
		        if (imageUrl.startsWith("/"))
284
		        {
285
		        	url = imageUrl+"&Size=266x150";
286
		        }
287
		        else
288
		        {
289
		        	url = FileServerUtils.getUrl(answer.getPK().getComponentName(), answer.getImage(), answer.getImage(), "image/gif", settings.getString("imagesSubDirectory"));
290
		        }
291
		        r += "<td width=\"50%\"><img src=\""+url+"\" align=\"left\"></td>";
292
	      }
293
              if (answer.isOpened()) {
294
                  isOpened = 1;
295
                  r += "<td align=\"left\" width=\"1%\">";
296
                  r += "<input type=\""+inputType+"\" name=\"answer_"+i+"\" value=\""+inputValue+"\"></td>";
297
                  r += "<td align=\"left\">"+WebEncodeHelper.javaStringToHtmlString(answer.getLabel())+"";
298
                  r += "<input type=\"text\" size=\"20\" name=\"openedAnswer_"+i+"\"></td></tr>";
299
                  r += "<tr><td colspan=2><br></td></tr></table></td></tr>";
300
              } else {
301
                  r += "<td align=\"left\" width=\"1%\">";
302
                  r += "<input type=\""+inputType+"\" name=\"answer_"+i+"\" value=\""+inputValue+"\"></td>";
303
                  r += "<td width=\"100%\">"+WebEncodeHelper.javaStringToHtmlString(answer.getLabel())+"</td>";
304
              }
305
              r += "</tr></table></td></tr>";
306
          }
307
  	}
308
  }
309
  r += "</table>";
310
  r += board.printAfter();
311
  return r;
312
}
313

    
314

    
315
List<String> displayQuestionResult(QuestionContainerDetail quizz, Question question, int i, String m_context, SettingBundle settings, QuizzSessionController quizzScc, boolean solutionAllowed, MultiSilverpeasBundle resources) {
316

    
317
  Collection<Answer> answers = question.getAnswers();
318
  Collection<QuestionResult> questionResults = question.getQuestionResults();
319
  List<String> displayQuestionResult = new ArrayList<String>();
320
  String r = "";
321
  // User answers
322
  int questionUserScore = 0;
323
  Iterator<QuestionResult> itB = questionResults.iterator();
324
  List<String> qrUser = new ArrayList<String>();
325
  try {
326
		while (itB.hasNext()) {
327
			QuestionResult questionResult = (QuestionResult) itB.next();
328
			questionUserScore += questionResult.getNbPoints();
329
			if (question.isOpen()) {
330
				qrUser.add(questionResult.getOpenedAnswer());
331
			} else {
332
				qrUser.add(questionResult.getAnswerPK().getId());
333
			}
334
		}
335
		if (question.getNbPointsMax() < questionUserScore) {
336
			questionUserScore = question.getNbPointsMax();
337
		} else if (question.getNbPointsMin() > questionUserScore) {
338
			questionUserScore = question.getNbPointsMin();
339
		}
340
		r = "<br><table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr align=center><td><table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" class=\"contourintfdcolor\" width=\"100%\">";
341
		r += "<tr><td nowrap width=\"41%\"><span class=txtlibform>&nbsp;<b>&#149</b>&nbsp;"+Encode.javaStringToHtmlString(question.getLabel())+"&nbsp;</span></td>";
342
		r += "<td class=\"quizzscore\" width=25% align=\"center\">"+resources.getString("ScoreLib")+" : "+questionUserScore+"/"+question.getNbPointsMax()+" pts</td>";
343
		r += "<td align=\"center\" nowrap>";
344
		r += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
345
		r += "</td></tr>";
346
		if (question.isOpen()) {
347
			Iterator<Answer> itA = answers.iterator();
348
			while (itA.hasNext()) {
349
				Answer answer = (Answer) itA.next();
350
				String inputValue = answer.getPK().getId()+","+question.getPK().getId();
351
				r += "<input type=\"hidden\" name=\"answer_"+i+"\" value=\""+inputValue+"\">";
352
				if (solutionAllowed) {
353
					r += "<tr><td><textarea disabled name=\"openedAnswer_"+i+"\" cols=\"40\" rows=\"3\">"+qrUser.get(0)+"</textarea></td>";
354
					r += "&nbsp;&nbsp;<td><textarea disabled name=\"openedAnswer_"+i+"\" cols=\"40\" rows=\"3\">"+answer.getLabel()+"</textarea></td></tr>";
355
				}
356
				else
357
					r += "<tr><td colspan=\"2\"><textarea disabled name=\"openedAnswer_"+i+"\" cols=\"40\" rows=\"3\">"+qrUser.get(0)+"</textarea></td></tr>";
358
			}
359
		} else {
360
			String style = question.getStyle();
361

    
362
			// on est dans le cas de l'affichage,
363
			// alors on pr�sente les listes d�roulante sous forme de bouton radio
364
			// pour faire apparaitre le choix de l'utilisateur et les commentaires
365
			String inputType = "radio";
366
			//if (question.isQCM())
367
			if (style.equals("checkbox"))
368
                  inputType = "checkbox";
369
			Iterator<Answer> itA = answers.iterator();
370
			int isOpened = 0;
371
			while (itA.hasNext()) {
372
				Answer answer = (Answer) itA.next();
373
				String inputStatus = "";
374
				r += "<tr><td colspan=\"3\"><table><tr>";
375
				String inputValue = answer.getPK().getId()+","+question.getPK().getId();
376

    
377
				// traitement de l'affichage des images
378
                  if (answer.getImage() == null)
379
			      {
380
                	  r += "<td width=50>&nbsp;</td>";
381
			      }
382
			      else
383
			      {
384
				      	String imageUrl = answer.getImage();
385
				        String url = "";
386
				        if (imageUrl.startsWith("/"))
387
				        {
388
				        	url = imageUrl+"&Size=266x150";
389
				        }
390
				        else
391
				        {
392
				        	url = FileServerUtils.getUrl(answer.getPK().getComponentName(), answer.getImage(), answer.getImage(), "image/gif", settings.getString("imagesSubDirectory"));
393
				        }
394
				        r += "<td><img src=\""+url+"\" align=\"left\"></td>";
395
			      }
396

    
397
				if (answer.isOpened()) {
398
					isOpened = 1;
399
					r += "<td width=\"40px\" align=\"center\"><input disabled type=\""+inputType+"\" name=\"answer_"+i+"\" value=\""+inputValue+"\"></td><td align=\"left\">";
400
					if (answer.isSolution() && solutionAllowed)
401
						r += "<b class=textePetitBoldVert>"+WebEncodeHelper.javaStringToHtmlString(answer.getLabel())+"</b>";
402
					else
403
						r += WebEncodeHelper.javaStringToHtmlString(answer.getLabel());
404
					r += "<BR><input disabled type=\"text\" size=\"20\" name=\"openedAnswer_"+i+"\"></td></tr>";
405
				} else {
406
					inputStatus = "";
407
					if (qrUser!=null){
408
						for (int cpt=0; cpt<qrUser.size(); cpt++){
409
							if (qrUser.get(cpt).equals(answer.getPK().getId())) {
410
								inputStatus = "checked";
411
							}
412
						}
413
					}
414
					r += "<td width=\"40px\" align=\"center\"><input disabled type=\""+inputType+"\" name=\"answer_"+i+"\" value=\""+inputValue+"\" "+inputStatus+"></td><td align=\"left\">";
415
					if (answer.isSolution() && solutionAllowed)
416
						r += "<b class=textePetitBoldVert>"+WebEncodeHelper.javaStringToHtmlString(answer.getLabel())+"</b><BR>";
417
					else
418
						r += WebEncodeHelper.javaStringToHtmlString(answer.getLabel())+"<BR>";
419
					r += "</td>";
420
					if (solutionAllowed){
421
   						r += "</tr><tr>";
422
						r += "<td align=\"left\" colspan=3>";
423
						r += "<b>"+WebEncodeHelper.javaStringToHtmlParagraphe(answer.getComment())+"</b></td>";
424
					}
425
				}
426
				r += "</tr></table></td></tr>";
427
			}
428
		}
429
		r += "</table></td></tr></table>";
430
	} catch (NumberFormatException e) {
431
	}
432
	displayQuestionResult.add(r);
433
	displayQuestionResult.add(Integer.toString(questionUserScore));
434
	displayQuestionResult.add(Integer.toString(question.getNbPointsMax()));
435

    
436
	return displayQuestionResult;
437
}
438

    
439
String displayQuizzHeaderPreview(QuizzSessionController quizzScc, QuestionContainerHeader quizzHeader, MultiSilverpeasBundle resources, GraphicElementFactory gef) {
440
  Board board = gef.getBoard();
441
	String title = WebEncodeHelper.javaStringToHtmlString(quizzHeader.getTitle());
442
  String description = WebEncodeHelper.javaStringToHtmlParagraphe(quizzHeader.getDescription());
443
  String comment = WebEncodeHelper.javaStringToHtmlParagraphe(quizzHeader.getComment());
444
  String r = "";
445
  r += board.printBefore();
446
  r += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" width=\"98%\">";
447
  r += "<tr><td>";
448
  r += "<span class=\"TitreFenetre\">"+title+"</span>";
449
  r += "<blockquote>";
450
  r += "<span class=\"sousTitreFenetre\">"+description+"</span>";
451
  if (comment != null) {
452
    r += "<br><br><span class=txttitrecol>"+comment+"</span>";
453
  }
454
  r += "</blockquote>";
455
  r += "</td></tr></table>";
456
  r += board.printAfter();
457

    
458
  return r;
459
}
460

    
461

    
462

    
463
String displayQuizzPreview(QuestionContainerDetail quizz, GraphicElementFactory gef, String m_context,QuizzSessionController quizzScc, MultiSilverpeasBundle resources, SettingBundle settings) throws QuizzException {
464
  String r = "";
465
  Question question = null;
466
  try{
467
		if (quizz != null) {
468
			QuestionContainerHeader quizzHeader = quizz.getHeader();
469
			Collection<Question> questions = quizz.getQuestions();
470

    
471
			//Display the quizz header
472
			r += displayQuizzHeaderPreview(quizzScc, quizzHeader,resources, gef);
473

    
474
			//Display the questions
475
			r += "<form name=\"quizz\" Action=\"SubmitQuizz\" Method=\"Post\">";
476
			Iterator<Question> itQ = questions.iterator();
477
			int i = 1;
478
			while (itQ.hasNext()) {
479
				  question = (Question) itQ.next();
480
				  r += displayQuestionPreview(question, i, m_context, quizzScc,settings, gef, resources);
481
				  i++;
482
			}
483
			r += "</form>";
484

    
485
		} else {
486
			r += "<table><tr><td>"+resources.getString("QuizzUnavailable")+"</td></tr></table>";
487
		}
488
	} catch(Exception e){
489
		throw new QuizzException ("quizzQuestionNew_JSP.displayQuizzPreview",QuizzException.WARNING,"Quizz.EX_CANNOT_DISPLAY_QUIZZPREVIEW",e);
490
	}
491

    
492
	return r;
493
}
494

    
495

    
496
String displayQuestionPreview(Question question, int i, String m_context, QuizzSessionController quizzScc,SettingBundle settings, GraphicElementFactory gef, MultiSilverpeasBundle resources) {
497
        Collection<Answer> answers = question.getAnswers();
498
        Board board = gef.getBoard();
499
        String r = "<br>";
500
        r += board.printBefore();
501
        r += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\"><tr><td nowrap><span class=\"txtlibform\">&nbsp;<b>&#149;</b>&nbsp;"+Encode.javaStringToHtmlString(question.getLabel())+"&nbsp;</span>";
502
        r += " - "+question.getNbPointsMax()+" pts</td>";
503
        r += "<td align=\"right\" nowrap>";
504
        if ((question.getClue() != null)&&(!question.getClue().equals("")))
505
        {
506
          r += "<a href=\"#\" onClick=\"view_cluePreview('"+i+"')\">"+resources.getString("QuizzSeeClue")+"</a>";
507
          r += " (" + resources.getString("QuizzPenalty") + "=" + question.getCluePenalty() + " pts)";
508
        }
509
        else
510
          r += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
511
        r += "</td></tr></table>";
512
        r += "</table><br>";
513
        r += board.printBefore();
514
        r += "<table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" >";
515

    
516
        String style = question.getStyle();
517
        if (style.equals("list"))
518
		{
519
        	r += "<tr><td colspan=\"2\">";
520
            r += "<select id=\"answers\" name=\"answers\" >";
521

    
522
        	Iterator<Answer> itA = answers.iterator();
523
        	while (itA.hasNext())
524
	        {
525
	            Answer answer = (Answer) itA.next();
526
	           	r += "<option name=\"answer_"+i+"\" value=\"\">"+WebEncodeHelper.javaStringToHtmlString(answer.getLabel())+"</option>";
527
	        }
528

    
529
         	r += "</td></tr>";
530
		}
531
		else
532
		{
533
	        String inputType = "radio";
534
	        if (style.equals("checkbox"))
535
	        	inputType = "checkbox";
536
	        Iterator<Answer> itA = answers.iterator();
537
	        while (itA.hasNext())
538
	        {
539
	            Answer answer = (Answer) itA.next();
540
	            r += "<tr><td colspan=\"2\"><table width=\"98%\"><tr>";
541

    
542
	            // traitement de l'affichage des images
543
	            if (answer.getImage() == null)
544
			      {
545
	            	r += "<td align=\"left\">&nbsp;</td>";
546
			      }
547
			      else
548
			      {
549
				      	String imageUrl = answer.getImage();
550
				        String url = "";
551
				        if (imageUrl.startsWith("/"))
552
				        {
553
				        	url = imageUrl+"&Size=266x150";
554
				        }
555
				        else
556
				        {
557
				        	url = FileServerUtils.getUrl(quizzScc.getComponentId(), answer.getImage(), answer.getImage(), "image/gif", settings.getString("imagesSubDirectory"));
558
				        }
559
				        r += "<td width=\"50%\"><img src=\""+url+"\" align=\"left\"></td>";
560
			      }
561
	            r += "<td width=\"40px\" align=\"center\"><input type=\""+inputType+"\" name=\"answer_"+i+"\"></td><td align=\"left\" width=\"100%\">"+Encode.javaStringToHtmlString(answer.getLabel())+"<BR>";
562
	            r += "</tr></table>";
563
	        }
564
		}
565
        r += board.printAfter();
566
        r += board.printAfter();
567
        return r;
568
}
569

    
570
String displayQuizzResult(QuestionContainerDetail quizz, GraphicElementFactory gef, String m_context,QuizzSessionController quizzScc, MultiSilverpeasBundle resources, SettingBundle settings, int nb_user_votes) throws QuizzException {
571
        String r = "";
572
        List<String> function = null;
573
        int quizzUserScore = 0;
574
        int quizzScoreMax = 0;
575

    
576
        Question question = null;
577
        Collection answers = null;
578
        try{
579
			if (quizz != null) {
580
				QuestionContainerHeader quizzHeader = quizz.getHeader();
581
				//Display the quizz header
582
				r += displayQuizzHeader(quizzScc, quizzHeader, resources, gef);
583

    
584
				boolean solutionAllowed = false;
585
				if (nb_user_votes >= quizzHeader.getNbParticipationsBeforeSolution())
586
				  solutionAllowed = true;
587

    
588
				Collection<Question> questions = quizz.getQuestions();
589
				//Display the quizz header
590
				String quizzId = quizzHeader.getPK().getId();
591
				String title = quizzHeader.getTitle();
592

    
593
				//Display the questions
594
				r += "<form name=\"quizz\" Action=\"quizzQuestionsNew.jsp\" Method=\"Post\">";
595
				r += "<input type=\"hidden\" name=\"Action\">";
596
				r += "<input type=\"hidden\" name=\"QuizzId\" value=\""+quizzHeader.getPK().getId()+"\">";
597
				Iterator<Question> itQ = questions.iterator();
598
				int i = 1;
599
				while (itQ.hasNext()) {
600
					  question = (Question) itQ.next();
601
					  function = displayQuestionResult(quizz, question, i, m_context, settings, quizzScc, solutionAllowed, resources);
602
					  r += function.get(0);
603
					  quizzUserScore += new Integer((String) function.get(1)).intValue();
604
					  quizzScoreMax += new Integer((String) function.get(2)).intValue();
605
					  i++;
606
				}
607

    
608
				//Score total:
609
				float winRate=((new Float(quizzUserScore).floatValue())/(new Float(quizzScoreMax).floatValue()))*100;
610
				String winRateImg="tableProf_4.gif";
611
				String winRate1 = settings.getString("winRate1");
612
				String winRate2 = settings.getString("winRate2");
613
				String winRate3 = settings.getString("winRate3");
614
				String winRate4 = settings.getString("winRate4");
615
				String winRateImg1 = settings.getString("winRateImg1");
616
				String winRateImg2 = settings.getString("winRateImg2");
617
				String winRateImg3 = settings.getString("winRateImg3");
618
				String winRateImg4 = settings.getString("winRateImg4");
619

    
620
				if (winRate<=new Integer(winRate1).intValue()) {
621
				  winRateImg=winRateImg1;
622
				} else if (winRate<=new Integer(winRate2).intValue()) {
623
				  winRateImg=winRateImg2;
624
			  } else if (winRate<=new Integer(winRate3).intValue()) {
625
			    winRateImg=winRateImg3;
626
        } else if (winRate<=new Integer(winRate4).intValue()) {
627
          winRateImg=winRateImg4;
628
        }
629

    
630
				r += "<table width=100% border=0 cellspacing=0 cellpadding=5><tr><td width=50% align=right valign=top class=\"txtnav\">"+resources.getString("TotalScoreLib")+" :</td>";
631
				r += "<td width=\"50%\"><table border=0 cellspacing=0 cellpadding=0><tr>";
632
				r += "<td rowspan=3><img src=\"icons/tableProf_1.gif\" width=7 height=70></td><td><img src=\"icons/tableProf_2.gif\" width=34 height=6></td>";
633
				r += "<td rowspan=3><img src=\"icons/"+winRateImg+"\" width=79 height=70></td></tr>";
634
				r += "<tr><td height=42 bgcolor=#387B80><span class=\"titreFenetre2\">"+quizzUserScore+"<br><img src=\"icons/1pxBlanc.gif\" width=30 height=1><br>"+quizzScoreMax+"</span></td></tr>";
635
				r += "<tr><td><img src=\"icons/tableProf_3.gif\" width=34 height=22></td></tr></table></td></tr></table><br>";
636
			} else {
637
		        r += "<table><tr><td>"+resources.getString("QuizzUnavailable")+"</td></tr>";
638
			}
639
		}catch( Exception e){
640
			throw new QuizzException ("quizzQuestionNew_JSP.displayQuizzResult",QuizzException.WARNING,"Quizz.EX_CANNOT_DISPLAY_RESULT",e);
641
		}
642

    
643
		return r;
644
}
645

    
646
  String displayQuizzResultAdmin(QuestionContainerDetail quizz, GraphicElementFactory gef, String m_context,QuizzSessionController quizzScc, MultiSilverpeasBundle resources, SettingBundle settings, int nb_user_votes) throws QuizzException {
647
        String r = "";
648
        List<String> function = null;
649
        int quizzUserScore = 0;
650
        int quizzScoreMax = 0;
651

    
652
        Question question = null;
653
        Collection answers = null;
654
		try{
655
			if (quizz != null) {
656
				QuestionContainerHeader quizzHeader = quizz.getHeader();
657
				r += displayQuizzHeader(quizzScc,quizzHeader,resources, gef);
658
				boolean solutionAllowed = true;
659
				Collection<Question> questions = quizz.getQuestions();
660
				String quizzId = quizzHeader.getPK().getId();
661
				String title = quizzHeader.getTitle();
662
				r += "<form name=\"quizz\">";
663
				r += "<input type=\"hidden\" name=\"Action\">";
664
				r += "<input type=\"hidden\" name=\"QuizzId\" value=\""+quizzHeader.getPK().getId()+"\">";
665
				Iterator<Question> itQ = questions.iterator();
666
				int i = 1;
667
				while (itQ.hasNext()) {
668
					  question = (Question) itQ.next();
669
					  function = displayQuestionResult(quizz, question, i, m_context, settings, quizzScc, solutionAllowed, resources);
670
					  r += function.get(0);
671
					  quizzUserScore += new Integer((String) function.get(1)).intValue();
672
					  quizzScoreMax += new Integer((String) function.get(2)).intValue();
673
					  i++;
674
				}
675
					float winRate=((new Float(quizzUserScore).floatValue())/(new Float(quizzScoreMax).floatValue()))*100;
676
				String winRateImg="tableProf_4.gif";
677
				String winRate1 = settings.getString("winRate1");
678
				String winRate2 = settings.getString("winRate2");
679
				String winRate3 = settings.getString("winRate3");
680
				String winRate4 = settings.getString("winRate4");
681
				String winRateImg1 = settings.getString("winRateImg1");
682
				String winRateImg2 = settings.getString("winRateImg2");
683
				String winRateImg3 = settings.getString("winRateImg3");
684
				String winRateImg4 = settings.getString("winRateImg4");
685

    
686
				if (winRate<=new Integer(winRate1).intValue())
687
					winRateImg=winRateImg1;
688
				else if (winRate<=new Integer(winRate2).intValue())
689
					winRateImg=winRateImg2;
690
				else if (winRate<=new Integer(winRate3).intValue())
691
					winRateImg=winRateImg3;
692
				else if (winRate<=new Integer(winRate4).intValue())
693
					winRateImg=winRateImg4;
694

    
695
				r += "<table width=100% border=0 cellspacing=0 cellpadding=5><tr><td width=50% align=right valign=top class=\"txtnav\">"+resources.getString("TotalScoreLib")+" :</td>";
696
				r += "<td width=\"50%\"><table border=0 cellspacing=0 cellpadding=0><tr>";
697
				r += "<td rowspan=3><img src=\"icons/tableProf_1.gif\" width=7 height=70></td><td><img src=\"icons/tableProf_2.gif\" width=34 height=6></td>";
698
				r += "<td rowspan=3><img src=\"icons/"+winRateImg+"\" width=79 height=70></td></tr>";
699
				r += "<tr><td height=42 bgcolor=#387B80><span class=\"titreFenetre2\">"+quizzUserScore+"<br><img src=\"icons/1pxBlanc.gif\" width=30 height=1><br>"+quizzScoreMax+"</span></td></tr>";
700
				r += "<tr><td><img src=\"icons/tableProf_3.gif\" width=34 height=22></td></tr></table></td></tr></table><br>";
701
			} else {
702
				r += "<table><tr><td>"+resources.getString("QuizzUnavailable")+"</td></tr>";
703
			}
704
		} catch(Exception e){
705
			throw new QuizzException ("quizzQuestionNew_JSP.displayQuizzResultAdmin",QuizzException.WARNING,"Quizz.EX_CANNOT_DISPLAY_RESULT",e);
706
		}
707

    
708
		return r;
709
}
710

    
711

    
712
  private static final javax.servlet.jsp.JspFactory _jspxFactory =
713
          javax.servlet.jsp.JspFactory.getDefaultFactory();
714

    
715
  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
716

    
717
  static {
718
    _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(1);
719
    _jspx_dependants.put("/quizz/jsp/checkQuizz.jsp", Long.valueOf(1548241817000L));
720
  }
721

    
722
  private static final java.util.Set<java.lang.String> _jspx_imports_packages;
723

    
724
  private static final java.util.Set<java.lang.String> _jspx_imports_classes;
725

    
726
  static {
727
    _jspx_imports_packages = new java.util.HashSet<>();
728
    _jspx_imports_packages.add("javax.servlet");
729
    _jspx_imports_packages.add("javax.servlet.http");
730
    _jspx_imports_packages.add("javax.servlet.jsp");
731
    _jspx_imports_classes = new java.util.HashSet<>();
732
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.Encode");
733
    _jspx_imports_classes.add("org.silverpeas.components.quizz.QuestionForm");
734
    _jspx_imports_classes.add("java.util.Date");
735
    _jspx_imports_classes.add("org.silverpeas.core.util.MultiSilverpeasBundle");
736
    _jspx_imports_classes.add("org.silverpeas.core.persistence.jdbc.DBUtil");
737
    _jspx_imports_classes.add("org.silverpeas.core.util.StringUtil");
738
    _jspx_imports_classes.add("org.silverpeas.core.util.URLUtil");
739
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.board.Board");
740
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.window.Window");
741
    _jspx_imports_classes.add("org.silverpeas.core.admin.user.model.UserDetail");
742
    _jspx_imports_classes.add("java.util.Vector");
743
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.tabs.TabbedPane");
744
    _jspx_imports_classes.add("java.util.Map");
745
    _jspx_imports_classes.add("org.silverpeas.components.quizz.QuizzException");
746
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayCellLink");
747
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.operationpanes.OperationPane");
748
    _jspx_imports_classes.add("java.util.Collection");
749
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.GraphicElementFactory");
750
    _jspx_imports_classes.add("org.silverpeas.core.questioncontainer.container.model.QuestionContainerHeader");
751
    _jspx_imports_classes.add("org.silverpeas.core.admin.component.model.ComponentInstLight");
752
    _jspx_imports_classes.add("java.util.List");
753
    _jspx_imports_classes.add("org.silverpeas.core.questioncontainer.result.model.QuestionResult");
754
    _jspx_imports_classes.add("org.silverpeas.core.util.DateUtil");
755
    _jspx_imports_classes.add("org.silverpeas.core.questioncontainer.answer.model.Answer");
756
    _jspx_imports_classes.add("org.silverpeas.core.util.WebEncodeHelper");
757
    _jspx_imports_classes.add("org.silverpeas.core.util.SettingBundle");
758
    _jspx_imports_classes.add("org.silverpeas.core.questioncontainer.question.model.Question");
759
    _jspx_imports_classes.add("java.util.HashMap");
760
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.iconpanes.IconPane");
761
    _jspx_imports_classes.add("org.silverpeas.core.questioncontainer.score.model.ScoreDetail");
762
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayLine");
763
    _jspx_imports_classes.add("java.util.ArrayList");
764
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.buttonpanes.ButtonPane");
765
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayCellText");
766
    _jspx_imports_classes.add("org.silverpeas.core.util.ResourceLocator");
767
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayColumn");
768
    _jspx_imports_classes.add("org.silverpeas.core.questioncontainer.container.model.QuestionContainerDetail");
769
    _jspx_imports_classes.add("org.silverpeas.core.util.file.FileServerUtils");
770
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.buttons.Button");
771
    _jspx_imports_classes.add("org.silverpeas.core.util.file.FileUploadUtil");
772
    _jspx_imports_classes.add("java.util.Iterator");
773
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.arraypanes.ArrayPane");
774
    _jspx_imports_classes.add("org.silverpeas.core.util.file.FileRepositoryManager");
775
    _jspx_imports_classes.add("org.apache.commons.fileupload.FileItem");
776
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.icons.Icon");
777
    _jspx_imports_classes.add("java.io.IOException");
778
    _jspx_imports_classes.add("org.silverpeas.core.util.LocalizationBundle");
779
    _jspx_imports_classes.add("org.silverpeas.components.quizz.control.QuizzSessionController");
780
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.frame.Frame");
781
    _jspx_imports_classes.add("org.silverpeas.components.quizz.QuestionHelper");
782
    _jspx_imports_classes.add("org.silverpeas.core.web.util.viewgenerator.html.browsebars.BrowseBar");
783
  }
784

    
785
  private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fview_005flooknfeel_0026_005fwithFieldsetStyle_005fwithCheckFormScript_005fnobody;
786

    
787
  private javax.el.ExpressionFactory _el_expressionfactory;
788
  private org.apache.tomcat.InstanceManager _jsp_instancemanager;
789

    
790
  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
791
    return _jspx_dependants;
792
  }
793

    
794
  public java.util.Set<java.lang.String> getPackageImports() {
795
    return _jspx_imports_packages;
796
  }
797

    
798
  public java.util.Set<java.lang.String> getClassImports() {
799
    return _jspx_imports_classes;
800
  }
801

    
802
  public void _jspInit() {
803
    _005fjspx_005ftagPool_005fview_005flooknfeel_0026_005fwithFieldsetStyle_005fwithCheckFormScript_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
804
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
805
    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
806
  }
807

    
808
  public void _jspDestroy() {
809
    _005fjspx_005ftagPool_005fview_005flooknfeel_0026_005fwithFieldsetStyle_005fwithCheckFormScript_005fnobody.release();
810
  }
811

    
812
  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
813
        throws java.io.IOException, javax.servlet.ServletException {
814

    
815
final java.lang.String _jspx_method = request.getMethod();
816
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method) && !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
817
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JBWEB004248: JSPs only permit GET POST or HEAD");
818
return;
819
}
820

    
821
    final javax.servlet.jsp.PageContext pageContext;
822
    javax.servlet.http.HttpSession session = null;
823
    final javax.servlet.ServletContext application;
824
    final javax.servlet.ServletConfig config;
825
    javax.servlet.jsp.JspWriter out = null;
826
    final java.lang.Object page = this;
827
    javax.servlet.jsp.JspWriter _jspx_out = null;
828
    javax.servlet.jsp.PageContext _jspx_page_context = null;
829

    
830

    
831
    try {
832
      response.setContentType("text/html; charset=UTF-8");
833
      response.addHeader("X-Powered-By", "JSP/2.3");
834
      pageContext = _jspxFactory.getPageContext(this, request, response,
835
      			"../../admin/jsp/errorpage.jsp", true, 16384, true);
836
      _jspx_page_context = pageContext;
837
      application = pageContext.getServletContext();
838
      config = pageContext.getServletConfig();
839
      session = pageContext.getSession();
840
      out = pageContext.getOut();
841
      _jspx_out = out;
842

    
843
      out.write('\n');
844
      out.write('\n');
845
      out.write('\n');
846

    
847
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
848
response.setHeader("Pragma","no-cache"); //HTTP 1.0
849
response.setDateHeader ("Expires",-1); //prevents caching at the proxy server
850

    
851
      out.write('\n');
852
      out.write('\n');
853
      org.silverpeas.core.questioncontainer.container.model.QuestionContainerDetail quizzUnderConstruction = null;
854
      synchronized (session) {
855
        quizzUnderConstruction = (org.silverpeas.core.questioncontainer.container.model.QuestionContainerDetail) _jspx_page_context.getAttribute("quizzUnderConstruction", javax.servlet.jsp.PageContext.SESSION_SCOPE);
856
        if (quizzUnderConstruction == null){
857
          quizzUnderConstruction = new org.silverpeas.core.questioncontainer.container.model.QuestionContainerDetail();
858
          _jspx_page_context.setAttribute("quizzUnderConstruction", quizzUnderConstruction, javax.servlet.jsp.PageContext.SESSION_SCOPE);
859
        }
860
      }
861
      out.write('\n');
862
      java.util.ArrayList questionsVector = null;
863
      synchronized (session) {
864
        questionsVector = (java.util.ArrayList) _jspx_page_context.getAttribute("questionsVector", javax.servlet.jsp.PageContext.SESSION_SCOPE);
865
        if (questionsVector == null){
866
          questionsVector = new java.util.ArrayList();
867
          _jspx_page_context.setAttribute("questionsVector", questionsVector, javax.servlet.jsp.PageContext.SESSION_SCOPE);
868
        }
869
      }
870
      out.write('\n');
871
      java.util.HashMap questionsResponses = null;
872
      synchronized (session) {
873
        questionsResponses = (java.util.HashMap) _jspx_page_context.getAttribute("questionsResponses", javax.servlet.jsp.PageContext.SESSION_SCOPE);
874
        if (questionsResponses == null){
875
          questionsResponses = new java.util.HashMap();
876
          _jspx_page_context.setAttribute("questionsResponses", questionsResponses, javax.servlet.jsp.PageContext.SESSION_SCOPE);
877
        }
878
      }
879
      out.write('\n');
880
      out.write('\n');
881
      out.write("\n");
882
      out.write("\n");
883
      out.write("\n");
884
      out.write("\n");
885
      out.write("\n");
886
      out.write("\n");
887
      out.write("\n");
888
      out.write("\n");
889
      out.write("\n");
890
      out.write("\n");
891
      out.write("\n");
892
      out.write("\n");
893
      out.write("\n");
894
      out.write("\n");
895
      out.write("\n");
896
      out.write("\n");
897
      out.write("\n");
898
      out.write("\n");
899
      out.write("\n");
900
      out.write("\n");
901
      out.write("\n");
902
      out.write("\n");
903
      out.write("\n");
904
      out.write("\n");
905
      out.write("\n");
906
      out.write("\n");
907
      out.write("\n");
908
      out.write("\n");
909
      out.write("\n");
910
      out.write("\n");
911
      out.write("\n");
912
      out.write("\n");
913
      out.write("\n");
914
      out.write("\n");
915
      out.write("\n");
916
      out.write("\n");
917
      out.write("\n");
918
      out.write("\n");
919
      out.write("\n");
920
      out.write("\n");
921
      out.write("\n");
922
      out.write("\n");
923
      out.write("\n");
924
      out.write("\n");
925
      out.write("\n");
926
      out.write("\n");
927
      out.write("\n");
928
      out.write("\n");
929
      out.write("\n");
930
      out.write("\n");
931
      out.write("\n");
932
      out.write("\n");
933
      out.write("\n");
934
      out.write("\n");
935
      out.write("\n");
936
      out.write("\n");
937
      out.write("\n");
938
      out.write("\n");
939
      out.write("\n");
940

    
941
  GraphicElementFactory gef =
942
      (GraphicElementFactory) session.getAttribute("SessionGraphicElementFactory");
943
  QuizzSessionController quizzScc = (QuizzSessionController) request.getAttribute("quizz");
944
  MultiSilverpeasBundle resources = (MultiSilverpeasBundle) request.getAttribute("resources");
945
  if (quizzScc == null) {
946
    String sessionTimeout =
947
        ResourceLocator.getGeneralSettingBundle().getString("sessionTimeout");
948
    getServletConfig().getServletContext().getRequestDispatcher(sessionTimeout).forward(
949
        request, response);
950
    return;
951
  }
952
  LocalizationBundle surveyResource = ResourceLocator
953
      .getLocalizationBundle("org.silverpeas.survey.multilang.surveyBundle",
954
          quizzScc.getLanguage());
955

    
956
      out.write("\n");
957
      out.write("\n");
958
      out.write("\n");
959
      out.write("\n");
960
      out.write("\n");
961
      out.write("\n");
962
      out.write("\n");
963
      out.write("\n");
964
      out.write("\n");
965
      out.write("\n");
966
      out.write("\n");
967
      out.write("\n");
968
      out.write("\n");
969
      out.write("\n");
970
      out.write("\n");
971
      out.write("\n");
972

    
973
String    profile     = (String) request.getAttribute("Profile");
974

    
975
String m_context = ResourceLocator.getGeneralSettingBundle().getString("ApplicationURL");
976

    
977
String exportSrc = m_context + "/util/icons/export.gif";
978
String copySrc = m_context + "util/icons/copy.gif";
979

    
980
      out.write('\n');
981
      out.write('\n');
982
      out.write('\n');
983
      out.write('\n');
984

    
985

    
986
//Retrieve parameter
987
String action = request.getParameter("Action");
988
String quizzId = request.getParameter("QuizzId");
989
String participationIdSTR =  request.getParameter("ParticipationId");
990
String userId = request.getParameter("UserId");
991
String roundId = request.getParameter("RoundId");
992
String origin = request.getParameter("Page");
993
if (origin==null) origin="";
994
int participationId = 0;
995

    
996
if (roundId == null) {
997
  roundId = "1";
998
}
999

    
1000
if (participationIdSTR != null) {
1001
  session.setAttribute("currentParticipationId", participationIdSTR);
1002
}
1003
SettingBundle settings = quizzScc.getSettings();
1004

    
1005
//Icons
1006
String topicAddSrc = m_context + "/util/icons/folderAdd.gif";
1007
String ligne = m_context + "/util/icons/colorPix/1px.gif";
1008

    
1009
//Html
1010
List<String> html_string = null;
1011

    
1012
QuestionContainerDetail quizz = null;
1013

    
1014
boolean isClosed = false;
1015

    
1016
if (action.equals("PreviewQuizz")) {
1017
      quizz = (QuestionContainerDetail) session.getAttribute("quizzUnderConstruction");
1018
}
1019
else {
1020
	if (quizzId != null && quizzId.length() != 0) {
1021
		quizz = quizzScc.getQuizzDetail(quizzId);
1022
		session.setAttribute("currentQuizz", quizz);
1023
	}
1024
	else
1025
	{
1026
      quizz = (QuestionContainerDetail) session.getAttribute("currentQuizz");
1027
      if (quizz == null) {
1028
          quizz = quizzScc.getQuizzDetail(quizzId);
1029
          session.setAttribute("currentQuizz", quizz);
1030
          roundId = "1";
1031
      }
1032
	}
1033

    
1034
  boolean endDateReached = false;
1035
  if (quizz.getHeader().getEndDate() != null) {
1036
          endDateReached = (quizz.getHeader().getEndDate().compareTo(resources.getDBDate(new Date())) < 0);
1037
  }
1038
  if (endDateReached || quizz.getHeader().isClosed())
1039
        isClosed = true;
1040
  if (action == null) {
1041
          action = "ViewQuizz";
1042
  }
1043
}
1044

    
1045
      out.write("\n");
1046
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
1047
      out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
1048
      out.write("<head>\n");
1049
      out.write("  <title></title>\n");
1050
      if (_jspx_meth_view_005flooknfeel_005f0(_jspx_page_context))
1051
        return;
1052
      out.write("\n");
1053
      out.write("<style type=\"text/css\">\n");
1054
      out.write(".thumbnailPreviewAndActions {\n");
1055
      out.write("  display: none;\n");
1056
      out.write("}\n");
1057
      out.write("</style>\n");
1058
      out.write("<script type=\"text/javascript\">\n");
1059
      out.write("<!--\n");
1060
      out.write("function confirmCancel()\n");
1061
      out.write("{\n");
1062
      out.write("  jQuery.popup.confirm('");
1063
      out.print(resources.getString("ConfirmCancel"));
1064
      out.write("', function() {\n");
1065
      out.write("    self.location = \"Main.jsp\";\n");
1066
      out.write("  });\n");
1067
      out.write("}\n");
1068
      out.write("\n");
1069
      out.write("function update_suggestion(quizz_id)\n");
1070
      out.write("{\n");
1071
      out.write("    errorMsg=\"\";\n");
1072
      out.write("   document.quizz.Action.value=\"UpdateSuggestion\";\n");
1073
      out.write("   if (!isWhitespace(document.quizz.txa_suggestion.value)) {\n");
1074
      out.write("      if (!isValidTextArea(document.quizz.txa_suggestion)) {\n");
1075
      out.write("            errorMsg = \"");
1076
      out.print(resources.getString("GML.ThisFormContains"));
1077
      out.write(' ');
1078
      out.write('1');
1079
      out.write(' ');
1080
      out.print(resources.getString("GML.error"));
1081
      out.write(" : \\n\";\n");
1082
      out.write("            errorMsg += \"  - ");
1083
      out.print(resources.getString("GML.theField"));
1084
      out.write(' ');
1085
      out.write('\'');
1086
      out.print(resources.getString("EducationSuggestion"));
1087
      out.write('\'');
1088
      out.write(' ');
1089
      out.print(resources.getString("MustContainsLessCar"));
1090
      out.write(' ');
1091
      out.print(DBUtil.getTextAreaLength());
1092
      out.write(' ');
1093
      out.print(resources.getString("Caracters"));
1094
      out.write("\\n\";\n");
1095
      out.write("            jQuery.popup.error(errorMsg);\n");
1096
      out.write("            return;\n");
1097
      out.write("      }\n");
1098
      out.write("      else\n");
1099
      out.write("           document.quizz.submit();\n");
1100
      out.write("   }\n");
1101
      out.write("   document.quizz.submit();\n");
1102
      out.write("}\n");
1103
      out.write("function view_cluePreview(question_id)\n");
1104
      out.write("{\n");
1105
      out.write("  largeur = \"600\";\n");
1106
      out.write("  hauteur = \"230\";\n");
1107
      out.write("\n");
1108
      out.write("  SP_openWindow('quizzCluePreview.jsp?question_id='+question_id,'indice',largeur,hauteur,'scrollbars=yes,resizable=yes');\n");
1109
      out.write("}\n");
1110
      out.write("\n");
1111
      out.write("function view_clue(i, quizz_id, question_id, cluePenalty)\n");
1112
      out.write("{\n");
1113
      out.write("  objet = eval(\"document.quizz.cluePenalty_\"+i);\n");
1114
      out.write("  if (objet.value == 0)\n");
1115
      out.write("    objet.value = cluePenalty;\n");
1116
      out.write("  largeur = \"600\";\n");
1117
      out.write("  hauteur = \"230\";\n");
1118
      out.write("\n");
1119
      out.write(" SP_openWindow('quizzClue.jsp?quizz_id='+quizz_id+'&question_id='+question_id,'indice',largeur,hauteur,'scrollbars=yes,resizable=yes');\n");
1120
      out.write("}\n");
1121
      out.write("\n");
1122
      out.write("// PopUp center\n");
1123
      out.write("function SP_openWindow(page,nom,largeur,hauteur,options) {\n");
1124
      out.write("var top=(screen.height-hauteur)/2;\n");
1125
      out.write("var left=(screen.width-largeur)/2;\n");
1126
      out.write("\tif (window.fenetre != null){\n");
1127
      out.write("  \twindow.fenetre.close();}\n");
1128
      out.write("fenetre=window.open(page,nom,\"top=\"+top+\",left=\"+left+\",width=\"+largeur+\",height=\"+hauteur+\",\"+options);\n");
1129
      out.write("return fenetre;\n");
1130
      out.write("}\n");
1131
      out.write("\n");
1132
      out.write("function MM_openBrWindow(theURL,winName,features) { //v2.0\n");
1133
      out.write("  window.open(theURL,winName,features);\n");
1134
      out.write("}\n");
1135
      out.write("\n");
1136
      out.write("function sendVote(roundId) {\n");
1137
      out.write("    if (roundId == \"end\") {\n");
1138
      out.write("          document.quizz.Action.value=\"SendVote\";\n");
1139
      out.write("          document.quizz.submit();\n");
1140
      out.write("    } else {\n");
1141
      out.write("          document.quizz.RoundId.value = roundId;\n");
1142
      out.write("          document.quizz.Action.value=\"RecordQuestionsResponses\";\n");
1143
      out.write("          document.quizz.submit();\n");
1144
      out.write("    }\n");
1145
      out.write("}\n");
1146
      out.write("\n");
1147
      out.write("var exportWindow = window;\n");
1148
      out.write("\n");
1149
      out.write("function Export(url)\n");
1150
      out.write("{\n");
1151
      out.write("  windowName = \"exportWindow\";\n");
1152
      out.write("    larg = \"740\";\n");
1153
      out.write("    haut = \"600\";\n");
1154
      out.write("    windowParams = \"directories=0,menubar=0,toolbar=0,alwaysRaised\";\n");
1155
      out.write("    if (!exportWindow.closed && exportWindow.name == \"exportWindow\")\n");
1156
      out.write("      exportWindow.close();\n");
1157
      out.write("    exportWindow = SP_openWindow(url, windowName, larg, haut, windowParams);\n");
1158
      out.write("}\n");
1159
      out.write("\n");
1160
      out.write("function clipboardCopy(id) {\n");
1161
      out.write("  top.IdleFrame.location.href = '../..");
1162
      out.print(quizzScc.getComponentUrl());
1163
      out.write("copy?Id='+id;\n");
1164
      out.write("}\n");
1165
      out.write("\n");
1166
      out.write("//-->\n");
1167
      out.write("</script>\n");
1168
      out.write("</head>\n");
1169

    
1170

    
1171
if (action.equals("RecordQuestionsResponses")) {
1172
  int nbQuestions = Integer.parseInt(request.getParameter("NbQuestions"));
1173
  int cluePenalty  = 0;
1174
  Map hash = (Map) session.getAttribute("questionsResponses");
1175
  if (hash == null)
1176
        hash = new HashMap();
1177

    
1178
  for (int i = 1; i <= nbQuestions; i++) {
1179
      List v = new ArrayList(5);
1180
      cluePenalty = Integer.parseInt(request.getParameter("cluePenalty_"+i));
1181
      v.add("PC"+cluePenalty);
1182
      String[] selectedAnswers = (String[]) request.getParameterValues("answer_"+i);
1183
      if (selectedAnswers != null) {
1184
        String questionId = selectedAnswers[0].substring(selectedAnswers[0].indexOf(",")+1, selectedAnswers[0].length());
1185
        for (int j = 0; j < selectedAnswers.length; j++) {
1186
              String answerId = selectedAnswers[j].substring(0, selectedAnswers[j].indexOf(","));
1187
              v.add(answerId);
1188
        }
1189
        String openedAnswer = request.getParameter("openedAnswer_"+i);
1190
        v.add("OA"+openedAnswer);
1191
        //if (hash.containsKey(questionId))
1192
        hash.put(questionId, v);
1193
      }
1194
  }
1195
  session.setAttribute("questionsResponses", hash);
1196
  action = "ViewCurrentQuestions";
1197
} else if (action.equals("SendVote")) {
1198
  int nbQuestions = Integer.parseInt(request.getParameter("NbQuestions"));
1199
  int cluePenalty  = 0;
1200
  Map hash = (Map) session.getAttribute("questionsResponses");
1201
  if (hash == null)
1202
      hash = new HashMap();
1203

    
1204
  for (int i = 1; i <= nbQuestions; i++) {
1205
      List v = new ArrayList(5);
1206
      cluePenalty = Integer.parseInt(request.getParameter("cluePenalty_"+i));
1207
      v.add("PC"+cluePenalty);
1208
      String[] selectedAnswers = (String[]) request.getParameterValues("answer_"+i);
1209
      if (selectedAnswers != null) {
1210
        String questionId = selectedAnswers[0].substring(selectedAnswers[0].indexOf(",")+1, selectedAnswers[0].length());
1211
        for (int j = 0; j < selectedAnswers.length; j++) {
1212
              String answerId = selectedAnswers[j].substring(0, selectedAnswers[j].indexOf(","));
1213
              v.add(answerId);
1214
        }
1215
        String openedAnswer = request.getParameter("openedAnswer_"+i);
1216
        v.add("OA"+openedAnswer);
1217
        hash.put(questionId, v);
1218
     }
1219
  }
1220
  quizzScc.recordReply(quizzId, hash);
1221
  action = "ViewResult";
1222
} //End if action = ViewResult
1223

    
1224
if (action.equals("PreviewQuizz")) {
1225
    out.println("<body marginheight=5 marginwidth=5 leftmargin=5 topmargin=5 bgcolor=\"#FFFFFF\">");
1226

    
1227
    Window window = gef.getWindow();
1228
    BrowseBar browseBar = window.getBrowseBar();
1229
    browseBar.setDomainName(quizzScc.getSpaceLabel());
1230
    browseBar.setComponentName(quizzScc.getComponentLabel());
1231
    browseBar.setExtraInformation(resources.getString("quizz.preview"));
1232

    
1233
    out.println(window.printBefore());
1234
    Frame frame = gef.getFrame();
1235
    out.println(frame.printBefore());
1236
    String quizzPart = displayQuizzPreview(quizz, gef, m_context, quizzScc, resources, settings);
1237
    out.println(quizzPart);
1238
    out.println(frame.printMiddle());
1239
    out.println("<table width=\"100%\">");
1240
    Button cancelButton = (Button) gef.getFormButton(resources.getString("GML.cancel"), "javascript:confirmCancel();", false);
1241
    Button voteButton = (Button) gef.getFormButton(resources.getString("GML.validate"), "javascript:onClick=document.quizz.submit();", false);
1242
    out.println("<tr><td align=\"center\"><table><tr align=center><td align=center>"+voteButton.print()+"</td><td align=center>"+cancelButton.print()+"</td></tr></table></td></tr>");
1243
    out.println("</table>");
1244
    out.println("<br><br>"+frame.printAfter());
1245
    out.println(window.printAfter());
1246
}
1247
if (action.equals("ViewQuizz")) {
1248
  out.println("<body bgcolor=\"#FFFFFF\">");
1249
  Window window = gef.getWindow();
1250
  BrowseBar browseBar = window.getBrowseBar();
1251
  browseBar.setDomainName(quizzScc.getSpaceLabel());
1252
  browseBar.setComponentName(quizzScc.getComponentLabel());
1253
  browseBar.setPath("<a href=\"Main.jsp\">"+resources.getString("QuizzList")+"</a>");
1254
  browseBar.setExtraInformation(quizz.getHeader().getTitle());
1255

    
1256
  //operation pane
1257
  OperationPane operationPane = window.getOperationPane();
1258
  operationPane.addOperation(m_context + "/util/icons/quizz_print.gif",resources.getString("GML.print"),"javascript:window.print()");
1259
  if (quizzScc.getNbVoters(quizz.getHeader().getPK().getId())==0||"admin".equals(quizzScc.getHighestSilverpeasUserRole().getName()))
1260
  {
1261
  	operationPane.addLine();
1262
	  operationPane.addOperation(m_context + "/util/icons/quizz_to_edit.gif",resources.getString("QuestionUpdate"),"quizzUpdate.jsp?Action=UpdateQuizzHeader&QuizzId="+quizz.getHeader().getPK().getId());
1263
  }
1264

    
1265
  if (profile.equals("admin")) {
1266
    // export csv
1267
    String url = "ExportCSV?QuizzId=" + quizz.getHeader().getPK().getId();
1268
    operationPane.addOperation(exportSrc, resources.getString("GML.export"), "javaScript:onClick=Export('"+url+"')");
1269
  }
1270

    
1271
  // copier
1272
  operationPane.addOperation(copySrc, resources.getString("GML.copy"), "javaScript:onClick=clipboardCopy('"+quizz.getHeader().getPK().getId()+"')");
1273

    
1274
  out.println(window.printBefore());
1275
  Frame frame = gef.getFrame();
1276
  out.println(frame.printBefore());
1277
  String quizzPart = displayQuizz(quizz,gef, m_context, quizzScc, resources, settings, out);
1278
  out.println(quizzPart);
1279

    
1280
      out.write('\n');
1281
      out.write(' ');
1282
      out.write(' ');
1283
      //  view:pdcClassification
1284
      org.silverpeas.core.web.util.viewgenerator.html.pdc.PdcClassificationTag _jspx_th_view_005fpdcClassification_005f0 = (new org.silverpeas.core.web.util.viewgenerator.html.pdc.PdcClassificationTag());
1285
      _jsp_instancemanager.newInstance(_jspx_th_view_005fpdcClassification_005f0);
1286
      _jspx_th_view_005fpdcClassification_005f0.setJspContext(_jspx_page_context);
1287
      // /quizz/jsp/quizzQuestionsNew.jsp(970,2) name = componentId type = java.lang.String reqTime = true required = true fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null 
1288
      _jspx_th_view_005fpdcClassification_005f0.setComponentId( quizzScc.getComponentId() );
1289
      // /quizz/jsp/quizzQuestionsNew.jsp(970,2) name = contentId type = java.lang.String reqTime = true required = true fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null 
1290
      _jspx_th_view_005fpdcClassification_005f0.setContentId( quizzId );
1291
      _jspx_th_view_005fpdcClassification_005f0.doTag();
1292
      _jsp_instancemanager.destroyInstance(_jspx_th_view_005fpdcClassification_005f0);
1293
      out.write('\n');
1294

    
1295
  out.println(frame.printMiddle());
1296
  out.println(frame.printAfter());
1297
  out.println(window.printAfter());
1298
} //End if action = ViewQuizz
1299
else if (action.equals("ViewCurrentQuestions")) {
1300
  out.println("<body marginheight=5 marginwidth=5 leftmargin=5 topmargin=5 bgcolor=\"#FFFFFF\">");
1301

    
1302
  Window window = gef.getWindow();
1303
  BrowseBar browseBar = window.getBrowseBar();
1304
  browseBar.setDomainName(quizzScc.getSpaceLabel());
1305
  browseBar.setComponentName(quizzScc.getComponentLabel());
1306
  browseBar.setPath("<a href=\"Main.jsp\">" + resources.getString("QuizzList") + "</a>");
1307
  browseBar.setExtraInformation(resources.getString("QuizzParticipate") + " " + quizz.getHeader().getTitle());
1308

    
1309
  //operation pane
1310
  OperationPane operationPane = window.getOperationPane();
1311
  operationPane.addOperation(m_context + "/util/icons/quizz_print.gif",resources.getString("GML.print"),"javascript:window.print()");
1312

    
1313
  out.println(window.printBefore());
1314
  Frame frame = gef.getFrame();
1315
  out.println(frame.printBefore());
1316

    
1317
  html_string = displayQuestions(quizz, Integer.parseInt(roundId), gef, m_context, quizzScc, resources, settings, frame, out);
1318
  out.println(html_string.get(0));
1319
  out.println(frame.printMiddle());
1320
  out.println(html_string.get(1));
1321
  out.println(frame.printAfter());
1322
  out.println(window.printAfter());
1323
}
1324
else if (action.equals("ViewResult")) {
1325
  out.println("<body marginheight=5 marginwidth=5 leftmargin=5 topmargin=5 bgcolor=\"#FFFFFF\">");
1326
  String participation=(String) session.getAttribute("currentParticipationId");
1327
  int nb_user_votes = 0;
1328
  Collection<ScoreDetail> userScores = quizzScc.getUserScoresByFatherId(quizzId);
1329
  if (userScores != null)
1330
  nb_user_votes = userScores.size();
1331

    
1332
  if ((participation!=null)&&(!participation.equals(""))) {
1333
    participationId = Integer.parseInt((String) session.getAttribute("currentParticipationId"));
1334
  } else {
1335
	  participationId=nb_user_votes;
1336
  }
1337

    
1338
  if (userId == null) {
1339
    participationId += 1;
1340
    quizz = quizzScc.getQuestionContainerForCurrentUserByParticipationId(quizzId, participationId);
1341
  }
1342
  else
1343
  {
1344
      quizz = quizzScc.getQuestionContainerByParticipationId(quizzId, userId, participationId);
1345
  }
1346

    
1347
  Window window = gef.getWindow();
1348
  BrowseBar browseBar = window.getBrowseBar();
1349
  browseBar.setDomainName(quizzScc.getSpaceLabel());
1350
  browseBar.setComponentName(quizzScc.getComponentLabel());
1351
  browseBar.setPath("<a href=\"Main.jsp\">"+resources.getString("QuizzList")+"</a>");
1352
  browseBar.setExtraInformation(resources.getString("QuizzSeeResults"));
1353

    
1354
  //operation pane
1355
  OperationPane operationPane = window.getOperationPane();
1356
  operationPane.addOperation(m_context + "/util/icons/quizz_print.gif",resources.getString("GML.print"),"javascript:window.print()");
1357

    
1358
  out.println(window.printBefore());
1359
  Frame frame = gef.getFrame();
1360
  out.println(frame.printBefore());
1361
  String quizzPart = displayQuizzResult(quizz, gef, m_context, quizzScc, resources, settings, nb_user_votes);
1362
  ScoreDetail userScoreDetail = null;
1363
  //Suggestion pedagogique
1364
  if (userId == null) {
1365
    userScoreDetail= quizzScc.getCurrentUserScoreByFatherIdAndParticipationId(quizzId, participationId);
1366
  } else
1367
    userScoreDetail= quizzScc.getUserScoreByFatherIdAndParticipationId(quizzId, userId, participationId);
1368

    
1369
  if ((userScoreDetail.getSuggestion()!=null) && (!userScoreDetail.getSuggestion().equals(""))) {
1370
    quizzPart += "<table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr align=center><td><table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" class=\"contourintfdcolor\" width=\"100%\"><tr><td valign=\"top\"><img src=\"icons/silverProf_SuggPedago.gif\" align=\"left\"><span class=\"txtnav\">";
1371
    quizzPart += resources.getString("EducationSuggestion") + " :</span><br>";
1372
    quizzPart += WebEncodeHelper.javaStringToHtmlString(userScoreDetail.getSuggestion())+"</td></tr></table></td></tr></table>";
1373
  }
1374

    
1375
  out.println(quizzPart);
1376
  out.println(frame.printMiddle());
1377

    
1378
  Button cancelButton = gef.getFormButton(resources.getString("GML.back"), "Main.jsp", false);
1379
  if (origin.equals("1")) {
1380
    cancelButton = gef.getFormButton(resources.getString("GML.cancel"), "quizzResultUser.jsp", false);
1381
  } else if (origin.equals("0")) {
1382
    cancelButton = gef.getFormButton(resources.getString("GML.cancel"), "palmares.jsp?quizz_id="+quizzId, false);
1383
  }
1384
  out.println("<table width=100% border=\"0\">");
1385
  out.println("<tr><td align=\"center\">"+cancelButton.print()+"</td></tr>");
1386
  out.println("</table>");
1387
  out.println(frame.printAfter());
1388
  out.println(window.printAfter());
1389
}
1390
else if (action.equals("ViewResultAdmin")) {
1391
  out.println("<body>");
1392
  String participation= (String) session.getAttribute("currentParticipationId");
1393
  if ((participation!=null)&&(!participation.equals("")))
1394
    participationId = new Integer((String) session.getAttribute("currentParticipationId")).intValue();
1395
  if (userId == null) {
1396
    participationId += 1;
1397
    quizz = quizzScc.getQuestionContainerForCurrentUserByParticipationId(quizzId, participationId);
1398
  } else{
1399
       participationId = new Integer((String) session.getAttribute("currentParticipationId")).intValue();
1400
       quizz = quizzScc.getQuestionContainerByParticipationId(quizzId, userId, participationId);
1401
  }
1402
  int nb_user_votes = 0;
1403
  Collection<ScoreDetail> userScores = quizzScc.getUserScoresByFatherId(quizzId);
1404
  if (userScores != null) {
1405
    nb_user_votes = userScores.size();
1406
  }
1407

    
1408
  Window window = gef.getWindow();
1409
  BrowseBar browseBar = window.getBrowseBar();
1410
  browseBar.setDomainName(quizzScc.getSpaceLabel());
1411
  browseBar.setComponentName(quizzScc.getComponentLabel());
1412
  browseBar.setPath("<a href=\"Main.jsp\">"+resources.getString("QuizzList")+"</a>");
1413
  browseBar.setExtraInformation(resources.getString("QuizzSeeResults"));
1414

    
1415
  //operation pane
1416
  OperationPane operationPane = window.getOperationPane();
1417
  operationPane.addOperation(m_context + "/util/icons/quizz_print.gif",resources.getString("GML.print"),"javascript:window.print()");
1418

    
1419
  out.println(window.printBefore());
1420
  Frame frame = gef.getFrame();
1421
  out.println(frame.printBefore());
1422
  String quizzPart = displayQuizzResultAdmin(quizz, gef, m_context, quizzScc, resources, settings, nb_user_votes);
1423
  ScoreDetail userScoreDetail = null;
1424
  //Suggestion pedagogique
1425
  if (userId == null) {
1426
    userScoreDetail= quizzScc.getCurrentUserScoreByFatherIdAndParticipationId(quizzId, participationId);
1427
  } else {
1428
    userScoreDetail= quizzScc.getUserScoreByFatherIdAndParticipationId(quizzId, userId, participationId);
1429
  }
1430

    
1431
  quizzPart += "<table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr align=center><td><table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" class=\"contourintfdcolor\" width=\"100%\"><tr><td valign=\"top\"><img src=\"icons/silverProf_SuggPedago.gif\" align=\"left\"><span class=\"txtnav\">";
1432
  quizzPart += resources.getString("EducationSuggestion") + " :</span><br>";
1433
  quizzPart += "<textarea name=\"txa_suggestion\" cols=\"120\" rows=\"4\">";
1434
  if (userScoreDetail.getSuggestion()!=null) {
1435
    quizzPart += userScoreDetail.getSuggestion();
1436
  }
1437
  quizzPart += "</textarea>";
1438
  quizzPart += "</td></tr></table></td></tr></table>";
1439
  quizzPart += "<input type=\"hidden\" name=\"UserId\" value=\""+userId+"\">";
1440
  quizzPart += "<input type=\"hidden\" name=\"Page\" value=\""+origin+"\">";
1441

    
1442
  out.println(quizzPart);
1443
  out.println(frame.printMiddle());
1444
  Button cancelButton= gef.getFormButton(resources.getString("GML.back"), "quizzAdmin.jsp", false);
1445
  if (origin.equals("1")) {
1446
    cancelButton = gef.getFormButton(resources.getString("GML.cancel"), "quizzResultAdmin.jsp", false);
1447
  } else if (origin.equals("0")) {
1448
    cancelButton = gef.getFormButton(resources.getString("GML.cancel"), "palmaresAdmin.jsp?quizz_id="+quizzId, false);
1449
  }
1450
  Button voteButton = gef.getFormButton(resources.getString("QuestionUpdate"), "javascript:update_suggestion("+quizz.getHeader().getPK().getId()+")", false);
1451
  out.println("<table width=100% border=\"0\">");
1452
  out.println("<tr><td align=\"center\"><table><tr><td align=center>"+voteButton.print()+"</td><td align=center>"+cancelButton.print()+"</td></tr></table></td></tr>");
1453
  out.println("</table>");
1454
  out.println(frame.printAfter());
1455
  out.println(window.printAfter());
1456
}
1457
else if (action.equals("UpdateSuggestion")) {
1458
  String suggestion = request.getParameter("txa_suggestion");
1459
  participationId = new Integer((String) session.getAttribute("currentParticipationId")).intValue();
1460
  quizz = quizzScc.getQuestionContainerByParticipationId(quizzId, userId, participationId);
1461
  ScoreDetail userScoreDetail = null;
1462
  //Suggestion pedagogique
1463
  userScoreDetail = quizzScc.getUserScoreByFatherIdAndParticipationId(quizzId, userId, participationId);
1464
  userScoreDetail.setSuggestion(suggestion);
1465
  quizzScc.updateScore(userScoreDetail);
1466

    
1467
  if (origin.equals("0"))
1468
  {
1469

    
1470
      out.write("\n");
1471
      out.write("          <script type=\"text/javascript\">\n");
1472
      out.write("          <!--\n");
1473
      out.write("          self.location=\"palmaresAdmin.jsp?quizz_id=");
1474
      out.print(quizzId);
1475
      out.write("\";\n");
1476
      out.write("          //-->\n");
1477
      out.write("          </script>\n");
1478

    
1479
  } else if (origin.equals("1")) {
1480

    
1481
      out.write("\n");
1482
      out.write("<script type=\"text/javascript\">\n");
1483
      out.write("<!--\n");
1484
      out.write("self.location=\"quizzResultAdmin.jsp\";\n");
1485
      out.write("//-->\n");
1486
      out.write("</script>\n");
1487

    
1488
  }
1489
}
1490

    
1491
      out.write("\n");
1492
      out.write("</body>\n");
1493
      out.write("</html>\n");
1494
    } catch (java.lang.Throwable t) {
1495
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
1496
        out = _jspx_out;
1497
        if (out != null && out.getBufferSize() != 0)
1498
          try {
1499
            if (response.isCommitted()) {
1500
              out.flush();
1501
            } else {
1502
              out.clearBuffer();
1503
            }
1504
          } catch (java.io.IOException e) {}
1505
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
1506
        else throw new ServletException(t);
1507
      }
1508
    } finally {
1509
      _jspxFactory.releasePageContext(_jspx_page_context);
1510
    }
1511
  }
1512

    
1513
  private boolean _jspx_meth_view_005flooknfeel_005f0(javax.servlet.jsp.PageContext _jspx_page_context)
1514
          throws java.lang.Throwable {
1515
    javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
1516
    javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
1517
    //  view:looknfeel
1518
    org.silverpeas.core.web.util.viewgenerator.html.LookAndStyleTag _jspx_th_view_005flooknfeel_005f0 = (org.silverpeas.core.web.util.viewgenerator.html.LookAndStyleTag) _005fjspx_005ftagPool_005fview_005flooknfeel_0026_005fwithFieldsetStyle_005fwithCheckFormScript_005fnobody.get(org.silverpeas.core.web.util.viewgenerator.html.LookAndStyleTag.class);
1519
    _jspx_th_view_005flooknfeel_005f0.setPageContext(_jspx_page_context);
1520
    _jspx_th_view_005flooknfeel_005f0.setParent(null);
1521
    // /quizz/jsp/quizzQuestionsNew.jsp(764,0) name = withFieldsetStyle type = boolean reqTime = false required = false fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null 
1522
    _jspx_th_view_005flooknfeel_005f0.setWithFieldsetStyle(true);
1523
    // /quizz/jsp/quizzQuestionsNew.jsp(764,0) name = withCheckFormScript type = boolean reqTime = false required = false fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null 
1524
    _jspx_th_view_005flooknfeel_005f0.setWithCheckFormScript(true);
1525
    int _jspx_eval_view_005flooknfeel_005f0 = _jspx_th_view_005flooknfeel_005f0.doStartTag();
1526
    if (_jspx_th_view_005flooknfeel_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
1527
      _005fjspx_005ftagPool_005fview_005flooknfeel_0026_005fwithFieldsetStyle_005fwithCheckFormScript_005fnobody.reuse(_jspx_th_view_005flooknfeel_005f0);
1528
      return true;
1529
    }
1530
    _005fjspx_005ftagPool_005fview_005flooknfeel_0026_005fwithFieldsetStyle_005fwithCheckFormScript_005fnobody.reuse(_jspx_th_view_005flooknfeel_005f0);
1531
    return false;
1532
  }
1533
}
(3-3/4)