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