View Javadoc

1   /***
2    * 
3    */
4   package org.telscenter.pas.steps;
5   
6   import java.awt.BorderLayout;
7   import java.awt.Color;
8   import java.awt.Cursor;
9   import java.awt.Dimension;
10  import java.awt.FlowLayout;
11  import java.awt.Font;
12  import java.awt.GridBagConstraints;
13  import java.awt.GridBagLayout;
14  import java.awt.GridLayout;
15  import java.awt.event.ActionEvent;
16  import java.awt.event.ActionListener;
17  import java.io.Serializable;
18  import java.util.List;
19  import java.util.logging.Logger;
20  
21  import javax.swing.AbstractAction;
22  import javax.swing.BorderFactory;
23  import javax.swing.BoxLayout;
24  import javax.swing.ImageIcon;
25  import javax.swing.JButton;
26  import javax.swing.JComponent;
27  import javax.swing.JDialog;
28  import javax.swing.JFrame;
29  import javax.swing.JLabel;
30  import javax.swing.JPanel;
31  import javax.swing.JScrollPane;
32  import javax.swing.JSeparator;
33  import javax.swing.JTabbedPane;
34  import javax.swing.event.ChangeEvent;
35  import javax.swing.event.ChangeListener;
36  
37  import net.miginfocom.swing.MigLayout;
38  import net.sf.sail.core.entity.ISock;
39  import net.sf.sail.jaxb.extension.BlockInteractionType;
40  
41  import org.imsglobal.xsd.imsqti_v2p0.ChoiceInteractionType;
42  import org.imsglobal.xsd.imsqti_v2p0.ResponseDeclarationType;
43  import org.imsglobal.xsd.imsqti_v2p0.SimpleChoiceType;
44  import org.telscenter.pas.common.ui.CommonUI;
45  import org.telscenter.pas.common.ui.panel.SimpleGradientPanel;
46  import org.telscenter.pas.common.ui.tab.PasTabbedPaneUI;
47  import org.telscenter.pas.steps.actions.DialogSaveAction;
48  import org.telscenter.pas.steps.actions.LeaveStudentAssessmentAction;
49  import org.telscenter.pas.ui.dialog.PasDialogManager;
50  import org.telscenter.pas.ui.dialog.PasMessageDialogUI;
51  import org.telscenter.pas.ui.dialog.PasSaveStudentAssesmentDialogUI;
52  import org.telscenter.pas.ui.dialog.PasStudentAssessmentConfirmDialogUI;
53  import org.telscenter.pas.ui.icons.PasCommonIconProvider;
54  import org.telscenter.pas.ui.util.PasColors;
55  import org.xito.dialog.CustomDialog;
56  
57  /***
58   * This Creates the Student Assessment UI for the student assesssment bean
59   * 
60   * @author aperritano
61   *
62   */
63  public class JaxbQtiStudentAssessmentUI extends JaxbQtiStepUI {
64  
65  	/***
66  	 * Logger for this class
67  	 */
68  	static final Logger logger = Logger
69  			.getLogger(JaxbQtiStudentAssessmentUI.class.getName());
70  
71  	
72  	private static final long serialVersionUID = 1L;
73  
74  	protected JButton submitQuestionsButton;
75  
76  	protected String QUESTION_CARD = "QUESTION_CARD"; //$NON-NLS-1$
77  
78  	protected String RESULT_CARD = "RESULT_CARD"; //$NON-NLS-1$
79  
80  
81  	public boolean leaveStep = false;
82  
83  	protected JPanel submitButtonPanel;
84  
85  	protected LeaveStudentAssessmentAction leaveAction;
86  	
87  	public JaxbQtiStudentAssessmentUI(JaxbQtiStep assmt) {
88  		super(assmt);
89  		leaveStep = true;
90  		
91  	}
92  	protected void initUI() {
93  		
94  		showPlaceHolderPanel = false;
95  		
96  		System.out.println("isSubmitted: " + assessment.isSubmitted() );
97  		
98  		if( assessment.getAssessmentItem() == null || assessment.getAssessmentItem().getItemBody().getBlockElementGroup().size() == 0 ) {
99  			this.setLayout(new FlowLayout(FlowLayout.CENTER));
100 			this.setOpaque(false);
101 			JLabel noLabel = new JLabel("This Student Assessment has no items.");
102 			noLabel.setOpaque(false);
103 			this.add(noLabel, BorderLayout.CENTER);
104 			return;
105 		}
106 		
107 		List<Object> interactions = assessment.getAssessmentItem().getItemBody().getBlockElementGroup();
108 
109 		submitButtonPanel = createButtonPanel();
110 
111 
112 		// create long panel of questions
113 		JPanel questionsPanel = questionFactory(interactions);
114 
115 		// put them in a scrollpanel for the ca
116 		JPanel scrollerPanel = createScrollerPanel(questionsPanel);
117 		
118 		scrollerPanel.setName(QUESTION_CARD);
119 		
120 		JPanel jp = new JPanel();
121 		jp.add(new JLabel("dfdf"));
122 		jp.setName(RESULT_CARD);
123 		// the card panel
124 		
125 		cardPanel.add(scrollerPanel, QUESTION_CARD);
126 		
127 		cardPanel.printCardName();
128 		cardPanel.setOpaque(false);
129 		cardPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
130 		//cardPanel.setBackground(Color.WHITE);
131 
132 		
133 		SimpleGradientPanel mainPanel = new SimpleGradientPanel();
134 		mainPanel.setDirection(SimpleGradientPanel.VERTICAL);
135 		//gradientPanel.setLayout(new BoxLayout(gradientPanel,BoxLayout.Y_AXIS));
136 		//add the components
137 		mainPanel.setStartColor(PasColors.compactNavBackgroundStartColor);
138 		mainPanel.setEndColor(PasColors.compactNavBackgroundEndColor);
139 		
140 		mainPanel.setLayout(new GridBagLayout());
141 		//mainPanel.setBackground(PasColors.pandaPanelBackgroundColor);
142 		GridBagConstraints c = new GridBagConstraints();
143 		// c.fill = GridBagConstraints.HORIZONTAL;
144 		c.fill = GridBagConstraints.BOTH;
145 
146 		c.weightx = 1;
147 		c.gridx = 0;
148 		c.gridy = 0;
149 	//	mainPanel.add(bannerPanel, c);
150 
151 		c.gridx = 0;
152 		c.gridy = 0;
153 		//mainPanel.add(introPanel, c);
154 
155 		c.weighty = 1;
156 		c.gridx = 0;
157 		c.gridy = 0;
158 		// c.gridheight = GridBagConstraints.RELATIVE;
159 		c.fill = GridBagConstraints.BOTH;
160 		mainPanel.add(cardPanel, c);
161 
162 		// c.ipady = 0; //reset to default
163 		// c.weighty = 1.0; //request any extra vertical space
164 
165 		c.weighty = 0;
166 		// c.anchor = GridBagConstraints.PAGE_END; //bottom of space
167 		// c.insets = new Insets(10,0,0,0); //top padding
168 		c.gridx = 0; // aligned with button 2
169 		// c.gridwidth = 2; //2 columns wide
170 		c.gridy = 2; // third row
171 		mainPanel.add(submitButtonPanel, c);
172 
173 		this.setLayout(new BorderLayout(0,0));
174 		this.add(mainPanel,BorderLayout.CENTER);
175 		
176 		//if it has been submitted all ready
177 		if (!assessment.getResponses().isEmpty()) {
178 			JPanel resultsPanel = createResultsCard();
179 			cardPanel.add(resultsPanel, RESULT_CARD);
180 			cardPanel.showLastCard();
181 		}// if	
182 
183 	}
184 	
185 	/***
186 	 * Creates all the interactions, flag for long or tab layout.
187 	 * 
188 	 * @param interactions
189 	 * @return a panel with all the questions for an assessment
190 	 */
191 	protected JPanel questionFactory(List<Object> interactions) {
192 
193 		JPanel mainPanel = new JPanel();
194 		//mainPanel.setOpaque(false);
195 		mainPanel.setBackground(PasColors.pandaPanelBackgroundColor);
196 		mainPanel.setLayout(new BorderLayout(0, 0));
197 		
198 		String introductionHtml = ((IntroductionHtmlAware)assessment).getIntroductionHtml();
199 		JComponent introPanel = null;
200 		
201 		if( introductionHtml != null ) {
202 			introPanel = createIntroTextPanel(introductionHtml);
203 			introPanel.setBorder(BorderFactory.createEmptyBorder(4, 10,4, 2));
204 		}// if
205 		//mainPanel.add(introPanel, BorderLayout.NORTH);
206 		
207 		
208 		//if the flag is set to true, layout become tabbed otherwise its standard which
209 		//is a long list of questions
210 		if( assessment.getTabbed() ) {
211 		
212 			tabbedPane = new JTabbedPane();
213 			tabbedPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
214 			tabbedPane.setBackground(Color.white);
215 		//	tabbedPane.setBackground(PasColors.noteTabBackgrounColor);
216 			tabbedPane.setUI(new PasTabbedPaneUI());
217 			tabbedPane.addChangeListener(new ChangeListener() {
218 	
219 				public void stateChanged(ChangeEvent e) {
220 					
221 					if(nextTabButton != null || previousTabButton != null)
222 						checkTab();
223 				}});
224 			
225 			if( interactions.size() > 1 ) {
226 				showTabButtons = true;
227 			} else {
228 				showTabButtons = false;
229 			}// if
230 			
231 			int questionIndex = 1;
232 			for (Object interaction : interactions) {
233 				JPanel itemPanel = createAssessmentItemPanel((BlockInteractionType) interaction);
234 				itemPanel.setOpaque(true);
235 				itemPanel
236 						.setBackground(Color.white);
237 				// itemPanel.setBorder(BorderFactory.createLineBorder(Color.white,
238 				// 2));
239 	
240 				JPanel wpanel = new JPanel(new BorderLayout(0, 0));
241 				wpanel.setBackground(Color.white);
242 	
243 				// adjust the borders if there is more than one tab
244 				if (showTabButtons) {
245 					wpanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
246 				} else {
247 					wpanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
248 				}
249 				wpanel.setBackground(Color.WHITE);
250 				wpanel.putClientProperty(ITEM_COMPLETED, new Boolean(false));
251 				wpanel.add(itemPanel, BorderLayout.CENTER);
252 				tabbedPane.addTab("Q " + questionIndex, wpanel);
253 				questionIndex += 1;
254 			}// for
255 			
256 			if (!assessment.getResponses().isEmpty()) {
257 				for (int i = 0; i < tabbedPane.getTabCount(); i++) {
258 					showTabChecked(i);
259 				}// for
260 			}// if
261 			
262 			JPanel comboPanel = new JPanel(new BorderLayout(0,0));
263 			comboPanel.setOpaque(false);
264 			
265 			if( introPanel != null ) {
266 				comboPanel.add(introPanel);
267 			}
268 			comboPanel.add(tabbedPane,BorderLayout.CENTER);
269 			comboPanel.setBorder(BorderFactory.createEmptyBorder(4, 2,4, 2));
270 			
271 			JPanel innerButtonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
272 			innerButtonPanel.setBackground(Color.WHITE);
273 	
274 			previousTabButton = new JButton(new PreviousTabAction("prev",new ImageIcon(PasCommonIconProvider.getImage("previousTab.png"))));
275 			previousTabButton.setHorizontalAlignment(JButton.RIGHT);
276 			previousTabButton.setVerticalAlignment(JButton.TOP);
277 			previousTabButton.setVerticalTextPosition(JButton.TOP);
278 			
279 			nextTabButton = new JButton(new NextTabAction("next",new ImageIcon(PasCommonIconProvider.getImage("nextTab.png"))));
280 			nextTabButton.setHorizontalTextPosition(JButton.LEFT);
281 			nextTabButton.setVerticalAlignment(JButton.TOP);
282 			nextTabButton.setVerticalTextPosition(JButton.TOP);
283 			//check the tabs
284 			this.checkTab();
285 			
286 			innerButtonPanel.add(CommonUI.makeEnhancedButton(previousTabButton));
287 			innerButtonPanel.add(CommonUI.makeEnhancedButton(nextTabButton));
288 			
289 			JPanel shifterButtonsPanel = new JPanel(new BorderLayout(0,0));
290 			shifterButtonsPanel.setBackground(Color.WHITE);
291 			shifterButtonsPanel.add(innerButtonPanel,BorderLayout.CENTER);
292 			shifterButtonsPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 2, 2));
293 	
294 			if( showTabButtons )
295 				comboPanel.add(shifterButtonsPanel,BorderLayout.SOUTH);
296 			
297 			
298 			mainPanel.add(comboPanel, BorderLayout.CENTER);
299 		} else {
300 			
301 			MigLayout layout = new MigLayout("wrap 1");
302 			
303 			JPanel longPanel = new JPanel();
304 			longPanel.setLayout(layout);
305 			if( introPanel != null ) {
306 				longPanel.add(introPanel,"growx, wrap");
307 			}
308 			int questionIndex = 1;
309 			for (Object interaction : interactions) {
310 				JPanel itemPanel = createAssessmentItemPanel((BlockInteractionType) interaction);
311 				itemPanel.setOpaque(true);
312 				itemPanel
313 						.setBackground(Color.white);
314 				// itemPanel.setBorder(BorderFactory.createLineBorder(Color.white,
315 				// 2));
316 	
317 				JPanel wpanel = new JPanel(new BorderLayout(0, 0));
318 				wpanel.setBackground(Color.white);
319 	
320 				
321 				wpanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
322 				wpanel.setBackground(Color.WHITE);
323 				wpanel.putClientProperty(ITEM_COMPLETED, new Boolean(false));
324 				
325 				
326 				wpanel.add(itemPanel, BorderLayout.CENTER);
327 				
328 				
329 				JPanel dividerLinePanel = new JPanel();
330 				
331 				JLabel numberLabel = new JLabel(questionIndex +".");
332 				MigLayout divLayout = new MigLayout();
333 				
334 				longPanel.add(numberLabel,  "split");
335 				longPanel.add(new JSeparator(),"growx, wrap");
336 				
337 				longPanel.add(wpanel,"growx, wrap");
338 				longPanel.setBackground(wpanel.getBackground());
339 				questionIndex += 1;
340 			}// for
341 			mainPanel.add(longPanel,BorderLayout.CENTER);
342 		}
343 		mainPanel.setBackground(Color.WHITE);
344 		// mainPanel.setBorder(BorderFactory.createEtchedBorder());
345 
346 //		questionPanel.add(mainPanel, BorderLayout.NORTH);
347 //		questionPanel.setBackground(Color.WHITE);
348 
349 		return mainPanel;
350 	}
351 
352 	protected JPanel createScrollerPanel(JPanel questionsPanel) {
353 		JScrollPane questionScroller = new JScrollPane(questionsPanel);
354 		questionScroller
355 				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
356 		questionScroller
357 				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
358 		questionScroller.setBorder(BorderFactory.createEmptyBorder());
359 		questionScroller.getVerticalScrollBar().setValue(
360 				questionScroller.getVerticalScrollBar().getMaximum());
361 		questionScroller.setOpaque(false);
362 		JPanel scrollerPanel = new JPanel(new BorderLayout(0, 0));
363 		// JPanel scrollerPanel = new JPanel();
364 		scrollerPanel.add(questionScroller, BorderLayout.CENTER);
365 		// scrollerPanel.add(questionScroller);
366 		//scrollerPanel.setOpaque(false);
367 		scrollerPanel.setOpaque(true);
368 		scrollerPanel.setBackground(PasColors.pandaPanelBackgroundColor);
369 		return scrollerPanel;
370 	}
371 
372 	protected JPanel createButtonPanel() {
373 		JPanel submitButtonPanel = new JPanel(new BorderLayout(0, 0));
374 		//submitButtonPanel.setOpaque(false);
375 		submitButtonPanel.setBackground(Color.white);
376 		
377 		String bLabel = Messages
378 		.getString("StudentAssessment.8"); 
379 		if( assessment.isLockStudentAnswers() == false ) {
380 			bLabel = "Save";
381 		}
382 			
383 		submitQuestionsButton = new JButton(bLabel); //$NON-NLS-1$
384 		submitQuestionsButton = CommonUI
385 				.makeEnhancedButton(submitQuestionsButton);
386 		submitQuestionsButton.setCursor(Cursor
387 				.getPredefinedCursor(Cursor.HAND_CURSOR));
388 		
389 		final AbstractAction submitAction = new DialogSaveAction() {
390 
391 			public void actionPerformed(ActionEvent e) {
392 				performSubmit();
393 				hideRootDialog(e.getSource());
394 			}};
395 		
396 		submitQuestionsButton.addActionListener(new ActionListener() {
397 
398 			public void actionPerformed(ActionEvent e) {
399 				
400 				if( assessment.isLockStudentAnswers() == false ) {
401 					performSubmit();
402 				} else {
403 					JDialog showAreYouSureCheckDialog = showAreYouSureCheckDialog(submitAction);
404 					showAreYouSureCheckDialog.setAlwaysOnTop(true);
405 				}
406 				
407 				
408 			}
409 		});
410 
411 		submitButtonPanel.add(new JLabel(" "), BorderLayout.WEST);
412 		submitButtonPanel.add(new JLabel(" "), BorderLayout.EAST);
413 
414 		JPanel buttonFillerPanel = new JPanel();
415 		buttonFillerPanel.setOpaque(false);
416 		buttonFillerPanel.add(submitQuestionsButton);
417 		submitButtonPanel.add(buttonFillerPanel, BorderLayout.CENTER);
418 		// submitButtonPanel.setBorder(BorderFactory.createEtchedBorder());
419 		JPanel t = new JPanel(new GridLayout(1, 1));
420 		t.setOpaque(false);
421 		t.add(submitButtonPanel);
422 		return t;
423 	}
424 
425 	
426 	/***
427 	 * Switches to the results panel
428 	 */
429 	protected void showResultsCard() {
430 		submitButtonPanel.setVisible(false);
431 		if( cardPanel.getComponentCount() > 1 ) {
432 			cardPanel.remove(1);
433 		}
434 		JPanel resultsCard = createResultsCard();
435 		cardPanel.add(resultsCard, RESULT_CARD);
436 		
437 		logger.info("COUNT " + cardPanel.getComponentCount() );
438 		cardPanel.showNextCard();
439 	}
440 
441 	
442 	/***
443 	 * Creates the results of the assessment
444 	 * 
445 	 * @return results card
446 	 */
447 	protected JPanel createResultsCard() {
448 
449 		SimpleGradientPanel resultsCard = new SimpleGradientPanel(new BorderLayout(0, 0));
450 		resultsCard.setDirection(SimpleGradientPanel.VERTICAL);
451 		resultsCard.setStartColor(PasColors.compactNavBackgroundStartColor);
452 		resultsCard.setEndColor(PasColors.compactNavBackgroundEndColor);
453 		
454 		
455 		JLabel finishedLabel = new JLabel(Messages
456 				.getString("StudentAssessment.11")); //$NON-NLS-1$
457 		Font font = finishedLabel.getFont().deriveFont(Font.BOLD, 16f);
458 		finishedLabel.setFont(font);
459 		finishedLabel.setForeground(Color.white);
460 		finishedLabel.setBorder(BorderFactory.createEmptyBorder(15, 2, 15, 2));
461 
462 		JPanel itemsPanel = new JPanel();
463 		// answerScroller.setBorder(BorderFactory.createEmptyBorder());
464 		itemsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
465 		itemsPanel.setLayout(new BoxLayout(itemsPanel, BoxLayout.PAGE_AXIS));
466 		itemsPanel.setOpaque(false);
467 		List<ResponseDeclarationType> reponseDeclarations = assessment.getAssessmentItem().getResponseDeclaration();
468 
469 		for (ResponseDeclarationType rd : reponseDeclarations) {
470 			String answerId = null;
471 			String humanReadableAnswer = null;
472 
473 			ISock<String> sock = assessment.getResponseDeclarationToSocks().get(rd);
474 			if (sock != null && !sock.isEmpty()) {
475 				answerId = sock.peek();
476 
477 				humanReadableAnswer = JaxbQtiStep.lastAnswer(assessment.getResponseDeclarationToSocks(), rd);
478 				
479 				BlockInteractionType bi = JaxbQtiStep.getInteractionByResponseDeclaration(assessment.getAssessmentItem().getItemBody().getBlockElementGroup(),rd);
480 				
481 				if (bi instanceof ChoiceInteractionType) {
482 					ChoiceInteractionType ci = (ChoiceInteractionType) bi;
483 					
484 					List<SimpleChoiceType> simpleChoices = ci.getSimpleChoice();
485 					for (SimpleChoiceType simpleChoice : simpleChoices) {
486 						if( simpleChoice.getIdentifier().equals(answerId)) {
487 							
488 							List<Serializable> choiceContent = simpleChoice.getContent();
489 							for (Serializable serializable : choiceContent) {
490 								if (serializable instanceof String) {
491 										humanReadableAnswer = (String) serializable;
492 								}// if
493 							}//for
494 							
495 						}// if
496 					}// for
497 					
498 				} else {
499 					humanReadableAnswer = answerId;
500 				}
501 			} else {
502 				humanReadableAnswer = Messages
503 						.getString("StudentAssessment.12"); //$NON-NLS-1$
504 			}// if
505 
506 			JPanel aItemPanel = new JPanel(new BorderLayout(0, 0));
507 			aItemPanel.setBackground(Color.BLACK);
508 			aItemPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 1, 2));
509 
510 			JPanel promptPanel = new JPanel(new BorderLayout(0, 0));
511 
512 			JComponent editorPane = JaxbQtiStepUI.createPromptPanel( JaxbQtiStep.getInteractionByResponseDeclaration(assessment.getAssessmentItem().getItemBody().getBlockElementGroup(), rd));
513 			editorPane.setBackground(PasColors.studentnAssessmentResultBackgroundColor);
514 			promptPanel.add(editorPane, BorderLayout.CENTER);
515 			promptPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
516 			promptPanel.setBackground(PasColors.studentnAssessmentResultBackgroundColor);
517 			aItemPanel.add(promptPanel, BorderLayout.NORTH);
518 
519 			JPanel answerPanel = new JPanel(new BorderLayout(0, 0));
520 
521 			humanReadableAnswer = wrapText(humanReadableAnswer,100.0);
522 			JLabel answerLabel = getFeedbackLbl(humanReadableAnswer,100.0);
523 			answerPanel.add(answerLabel,BorderLayout.CENTER);
524 			//answerPanel.add(new JLabel(humanReadableAnswer),
525 			//		BorderLayout.CENTER);
526 			System.out.println(humanReadableAnswer);
527 			answerPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
528 			answerPanel.setBackground(Color.WHITE);
529 			aItemPanel.add(answerPanel, BorderLayout.CENTER);
530 
531 			// JPanel temp = new JPanel(new BorderLayout(0,0));
532 			// temp.setOpaque(false);
533 			// temp.add(aItemPanel,BorderLayout.NORTH);
534 
535 			itemsPanel.add(aItemPanel);
536 
537 		}// for
538 
539 		JPanel innerPanel = new JPanel(new BorderLayout(0, 0));
540 		innerPanel.setOpaque(false);
541 		innerPanel.add(finishedLabel, BorderLayout.NORTH);
542 		//innerPanel.setBackground(Color.red);
543 		JScrollPane answerScroller = new JScrollPane();
544 		answerScroller
545 				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
546 		answerScroller
547 				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
548 
549 		JPanel temp = new JPanel(new BorderLayout(0, 0));
550 		temp.add(itemsPanel, BorderLayout.NORTH);
551 		//temp.setBackground(Color.blue);
552 		temp.setOpaque(false);
553 		temp.setBorder(BorderFactory.createLineBorder(Color.black, 2));
554 		answerScroller.setViewportView(temp);
555 		answerScroller.setBorder(BorderFactory.createEmptyBorder());
556 		answerScroller.getViewport().setViewPosition(new java.awt.Point(0, 0));
557 		answerScroller.getVerticalScrollBar().setValue(
558 				answerScroller.getVerticalScrollBar().getMaximum());
559 		answerScroller.setBackground(Color.RED);
560 		//answerScroller.setOpaque(false);
561 		resultsCard.add(answerScroller, BorderLayout.CENTER);
562 
563 		resultsCard.add(innerPanel, BorderLayout.NORTH);
564 		// resultsCard.add(,BorderLayout.CENTER);
565 
566 		JButton backButton = new JButton(Messages
567 				.getString("StudentAssessment.13")); //$NON-NLS-1$
568 		CommonUI.makeEnhancedButton(backButton);
569 		backButton.addActionListener(new ActionListener() {
570 
571 			public void actionPerformed(ActionEvent e) {
572 				// responses = new HashMap();
573 				//hasSubmited = false;
574 				submitButtonPanel.setVisible(true);
575 				cardPanel.showCard(cardPanel.getComponent(0));
576 			}
577 		});
578 
579 		JPanel buttonFillerPanel = new JPanel();
580 		buttonFillerPanel.setOpaque(false);
581 		if( assessment.isLockStudentAnswers() == false )
582 			buttonFillerPanel.add(backButton);
583 
584 		resultsCard.add(buttonFillerPanel, BorderLayout.SOUTH);
585 		
586 		submitButtonPanel.setVisible(false);
587 		
588 		return resultsCard;
589 	}
590 	
591 	/***
592 	 * @param textLen
593 	 * @param adjustedWidth
594 	 * @param inlineFeedbackText
595 	 * @return
596 	 */
597 	private JLabel getFeedbackLbl(String inlineFeedbackText, double adjustedWidth) {
598 		double factor;
599 		int textlen = inlineFeedbackText.length();
600 		JLabel fiLabel = new JLabel();
601 		fiLabel.setLayout(new BoxLayout(fiLabel,BoxLayout.Y_AXIS));
602 		fiLabel.setBorder(BorderFactory.createLineBorder(PasColors.blackColor,1));
603 		Dimension thisDim = fiLabel.getPreferredSize();					
604 		factor = Math.ceil((double)textlen/adjustedWidth);
605 		thisDim.setSize(adjustedWidth,15*factor);
606 		fiLabel.setPreferredSize(thisDim);
607 		fiLabel.setMaximumSize(fiLabel.getPreferredSize());
608 		fiLabel.setMinimumSize(fiLabel.getPreferredSize());
609 		fiLabel.setText(inlineFeedbackText);
610 		fiLabel.setVisible(true);
611 //		fiLabel.setForeground(Color.RED);
612 		fiLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
613 		return fiLabel;
614 	}
615 
616 	private String wrapText(String comments, double textWidth){		
617 		String initHtml = "<html><body>";
618 		String finalHtml = "</body></html>";
619 		String finalStr = "";	
620 		int lastIndex = 0;
621 
622 		comments.trim();
623 
624 		while(comments.length() > textWidth){
625 			String substri = comments.substring(0,(int)textWidth);
626 			lastIndex = substri.lastIndexOf(" ");
627 			finalStr = finalStr + substri.substring(0,lastIndex) + "\n";
628 			comments = comments.substring((int)lastIndex, comments.length());
629 
630 		}
631 		
632 		return initHtml + finalStr + comments.substring(0,comments.length()) + finalHtml;		
633 	}
634 	
635 	/***
636 	 * Saves all the responses to rims
637 	 * 
638 	 * @param clientProperty
639 	 */
640 	protected void doSave() {
641 		JaxbQtiStep.saveAssessmentItem(assessment.getAssessmentItem(), assessment.getResponses(),
642 				assessment.getResponseDeclarationToSocks());
643 		((JaxbQtiStudentAssessment)assessment).setSubmitted(true);
644 		showResultsCard();
645 	}
646 	
647 	public JDialog showAssessmentPartsCheckDialog() {
648 		final PasMessageDialogUI ui = new PasMessageDialogUI(true);
649 		// TODO note save action NEEDs to ask the note service for
650 		// its info and have not passed in via constructor
651 		ui
652 				.setMessage("You need to complete all assessment questions before saving");
653 		return PasDialogManager.showPasMessageDialog("Warning", ui
654 				.createDialogPanel(), null, true);
655 	}
656 	
657 	public JDialog showAreYouSureCheckDialog(AbstractAction action) {
658 		final PasStudentAssessmentConfirmDialogUI ui = new PasStudentAssessmentConfirmDialogUI(action);
659 	
660 		ui
661 				.setMessage("Are all the questions answered? Once submitted all answers are final.");
662 		return PasDialogManager.showPasMessageDialog("Warning", ui
663 				.createDialogPanel(), null, true);
664 	}
665 	
666 	
667 	/***
668 	 * @return the leaveAction
669 	 */
670 	public LeaveStudentAssessmentAction getLeaveAction() {
671 		return leaveAction;
672 	}
673 	
674 	/***
675 	 * @param projectFrame
676 	 * @return 
677 	 */
678 	public JDialog  showSubmitDialog(JFrame projectFrame) {
679 		
680 		leaveAction = new LeaveStudentAssessmentAction(
681 				Messages.getString("StudentAssessment.51")); //$NON-NLS-1$
682 
683 		PasSaveStudentAssesmentDialogUI ui = new PasSaveStudentAssesmentDialogUI(
684 				leaveAction);
685 		ui.setMessage(Messages.getString("StudentAssessment.52")); //$NON-NLS-1$
686 		// TODO note save action NEEDs to ask the note service for its info and
687 		// have not passed in via constructor
688 
689 		// ui.setMessage("Your issue has not been sent to the TELS Team, would
690 		// you like to send it?");
691 		CustomDialog dialog = PasDialogManager
692 				.showPasMessageDialog(
693 						Messages.getString("StudentAssessment.53"), ui.createDialogPanel(), projectFrame, true); //$NON-NLS-1$
694 		
695 //		JDialog d = new JDialog(projectFrame, true);
696 //		d.getContentPane().add(ui.createDialogPanel());
697 //		d.pack();
698 		//d.setVisible(true);
699 		
700 		
701 		//this.setLeaveStep(leaveAction.hasLeft());
702 		
703 		return dialog;
704 //		     
705 //		});
706 		// System.out.println("StudentAssessment.showSubmitDialog()");
707 
708 	}
709 	public boolean isLeaveStep() {
710 		return leaveStep;
711 	}
712 	public void setLeaveStep(boolean leaveStep) {
713 		this.leaveStep = leaveStep;
714 	}
715 	/***
716 	 * 
717 	 */
718 	private void performSubmit() {
719 		cardPanel.showNextCard();
720 		
721 		//for tabs 
722 		if( assessment.getTabbed() ) {
723 			if( isCompleted() ) {
724 				doSave();
725 			} else {
726 				if( assessment.isLockStudentAnswers() == false )
727 					showAssessmentPartsCheckDialog();
728 			}// if
729 		} else {
730 			//no tabs just save
731 			doSave();
732 		}
733 	}
734 	
735 
736 
737 }