1 package com.germinus.merlin.controller.assignments;
2
3 import javax.portlet.ActionRequest;
4 import javax.portlet.ActionResponse;
5 import javax.portlet.RenderRequest;
6 import javax.portlet.RenderResponse;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10 import org.springframework.beans.factory.InitializingBean;
11 import org.springframework.web.portlet.ModelAndView;
12 import org.springframework.web.portlet.mvc.AbstractController;
13
14 import com.germinus.merlin.manager.AssignmentManager;
15 import com.germinus.merlin.manager.AssignmentResultManager;
16 import com.germinus.merlin.manager.CourseManager;
17 import com.germinus.merlin.model.assignment.Assignment;
18 import com.germinus.merlin.model.assignment.AssignmentResult;
19 import com.germinus.merlin.model.assignment.AssignmentUploadASingleFile;
20 import com.germinus.liferay.util.ILiferayUtil;
21
22
23
24
25
26
27
28
29
30
31
32 public class AssignmentSubmitController extends AbstractController implements
33 InitializingBean {
34
35 private ILiferayUtil liferayUtil;
36 private static final Log log = LogFactory.getLog(AssignmentSubmitController.class);
37 public Long assignmentId;
38
39 private AssignmentManager assignmentManager;
40 private AssignmentResultManager assignmentResultManager;
41 private CourseManager courseManager;
42
43 public void afterPropertiesSet() throws Exception {
44 }
45
46
47
48
49 public AssignmentManager getAssignmentManager() {
50 return assignmentManager;
51 }
52
53
54
55
56 public CourseManager getCourseManager() {
57 return courseManager;
58 }
59
60
61
62
63
64
65
66 public void handleActionRequestVoid(ActionRequest request,
67 ActionResponse response) throws Exception {
68 }
69
70
71
72
73
74
75
76
77
78
79 public ModelAndView handleRenderRequestInternal(RenderRequest request,
80 RenderResponse response) throws Exception {
81 log.debug("\n\n Redirecting to adequate assignment for assignmentSubmit");
82 Assignment assignment;
83 AssignmentResult result;
84
85 assignment = assignmentManager.searchAssignment(request, response);
86 result=assignmentResultManager.searchAssignmentResult(request,response);
87
88 String assignmentType = request.getParameter("type");
89 request.setAttribute("result", result);
90
91 if (assignmentType.compareTo("Online Activity")==0){
92 return new ModelAndView("assignments/submitAssignment/submitAssignmentOnline", "assignment", assignment);
93 }else
94 if (assignmentType.compareTo("Upload a Single File")==0){
95 if (((AssignmentUploadASingleFile)assignment).getAllowNotes()!=null &&
96 ((AssignmentUploadASingleFile)assignment).getAllowNotes()){
97 return new ModelAndView("assignments/submitAssignment/submitAssignmentUploadSingleFileWithNotes", "assignment", assignment);
98 }
99 else
100 return new ModelAndView("assignments/submitAssignment/submitAssignmentUploadSingleFile", "assignment", assignment);
101 }else
102 if (assignmentType.compareTo("Offline Activity")==0){
103 return new ModelAndView("assignments/submitAssignment/submitAssignmentOffline","assignment", assignment);
104 } else {
105 return new ModelAndView("errors/error", "", null);
106 }
107 }
108
109
110
111
112 public void setAssignmentManager(AssignmentManager assignmentsManagement) {
113 this.assignmentManager = assignmentsManagement;
114 }
115
116
117
118
119 public void setCourseManager(CourseManager courseManager) {
120 this.courseManager = courseManager;
121 }
122
123
124
125
126 public ILiferayUtil getLiferayUtil() {
127 return liferayUtil;
128 }
129
130
131
132
133 public void setLiferayUtil(ILiferayUtil liferayUtil) {
134 this.liferayUtil = liferayUtil;
135 }
136
137 public AssignmentResultManager getAssignmentResultManager() {
138 return assignmentResultManager;
139 }
140
141 public void setAssignmentResultManager(
142 AssignmentResultManager assignmentResultManager) {
143 this.assignmentResultManager = assignmentResultManager;
144 }
145 }