001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/author/IndexBean.java $
003: * $Id: IndexBean.java 9268 2006-05-10 21:27:24Z daisyf@stanford.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.ui.bean.author;
021:
022: import java.io.Serializable;
023: import java.util.ArrayList;
024: import java.util.Collection;
025: import java.util.Iterator;
026: import javax.faces.context.FacesContext;
027:
028: import org.apache.commons.logging.Log;
029: import org.apache.commons.logging.LogFactory;
030:
031: import org.sakaiproject.tool.assessment.facade.AssessmentTemplateFacade;
032: import org.sakaiproject.tool.assessment.services.assessment.AssessmentService;
033: import org.sakaiproject.tool.assessment.util.BeanSort;
034:
035: /**
036: * Used to be org.navigoproject.ui.web.form.IndexForm.java
037: *
038: * @author $author$
039: * @version $Id: IndexBean.java 9268 2006-05-10 21:27:24Z daisyf@stanford.edu $
040: */
041: public class IndexBean implements Serializable {
042: private static BeanSort bs;
043: private Collection templateList;
044: private ArrayList sortTemplateList;
045:
046: /** Use serialVersionUID for interoperability. */
047: private final static long serialVersionUID = 7919219404875270127L;
048: private Collection templateNames;
049: private Collection templateIds;
050: // private Collection studentAssessmentList;
051: // private Collection assessmentList;
052: // private Collection assessmentTypeList;
053: private String assessmentTypeChoice;
054: private String course_id;
055: private String agent_id;
056: private String templateOrderBy = "templateName";
057: private boolean templateAscending = true;
058:
059: private static Log log = LogFactory.getLog(IndexBean.class);
060:
061: /**
062: * Creates a new IndexBean object.
063: */
064: public IndexBean() {
065: // if(assessmentTypeList == null)
066: // {
067: // assessmentTypeList = new ArrayList();
068: // }
069: }
070:
071: /**
072: * DOCUMENTATION PENDING
073: *
074: * @return DOCUMENTATION PENDING
075: */
076: public Collection getTemplateList() {
077:
078: try {
079: AssessmentService delegate = new AssessmentService();
080: ArrayList list = delegate
081: .getBasicInfoOfAllActiveAssessmentTemplates("title");
082: //ArrayList list = delegate.getAllAssessmentTemplates();
083: ArrayList templates = new ArrayList();
084: Iterator iter = list.iterator();
085: while (iter.hasNext()) {
086: AssessmentTemplateFacade facade = (AssessmentTemplateFacade) iter
087: .next();
088: TemplateBean bean = new TemplateBean();
089: bean.setTemplateName(facade.getTitle());
090: bean.setIdString(facade.getAssessmentBaseId()
091: .toString());
092: bean.setLastModified(facade.getLastModifiedDate()
093: .toString());
094: templates.add(bean);
095: }
096: this .templateList = templates;
097: } catch (Exception e) {
098: e.printStackTrace();
099: templateList = new ArrayList();
100: }
101:
102: return this .templateList;
103: }
104:
105: /**
106: * DOCUMENTATION PENDING
107: *
108: * @param templateList DOCUMENTATION PENDING
109: */
110: public void setTemplateList(Collection templateList) {
111: this .templateList = templateList;
112: }
113:
114: public ArrayList getSortTemplateList() {
115: return this .sortTemplateList;
116: }
117:
118: /**
119: * DOCUMENTATION PENDING
120: *
121: * @param templateList DOCUMENTATION PENDING
122: */
123: public void setSortTemplateList(ArrayList sortTemplateList) {
124: this .sortTemplateList = sortTemplateList;
125: }
126:
127: /**
128: * DOCUMENTATION PENDING
129: *
130: * @return DOCUMENTATION PENDING
131: */
132: public Collection getTemplateNames() {
133: if (templateNames == null) {
134: getTemplateList();
135: }
136:
137: return templateNames;
138: }
139:
140: /**
141: * DOCUMENTATION PENDING
142: *
143: * @param names DOCUMENTATION PENDING
144: */
145: public void setTemplateNames(Collection names) {
146: templateNames = names;
147: }
148:
149: /**
150: * DOCUMENTATION PENDING
151: *
152: * @return DOCUMENTATION PENDING
153: */
154: public Collection getTemplateIds() {
155: if (templateIds == null) {
156: getTemplateList();
157: }
158:
159: return templateIds;
160: }
161:
162: /**
163: * DOCUMENTATION PENDING
164: *
165: * @param ids DOCUMENTATION PENDING
166: */
167: public void setTemplateIds(Collection ids) {
168: templateIds = ids;
169: }
170:
171: // /**
172: // * This is designed to quickly and efficiently obtain a small number of
173: // * pieces of information in the assessment list. Specifically, you will not
174: // * be able to obtain properties from the getData() method. To get a more
175: // * complete, but less efficient list, use getStudentAssessmentList()
176: // * instead.
177: // *
178: // * @return bare Collection of assessments
179: // */
180: // public Collection getAssessmentList()
181: // {
182: // try
183: // {
184: // AssessmentServiceDelegate delegate = new AssessmentServiceDelegate();
185: // AssessmentIterator aiter = null;
186: // try
187: // {
188: // aiter = delegate.getAssessments((new Long(course_id)).longValue());
189: // }
190: // catch(Exception e)
191: // {
192: // log.warn("No Course ID specified.");
193: // aiter = delegate.getAssessments();
194: // }
195: //
196: // assessmentList = new ArrayList();
197: //
198: // while(aiter.hasNext())
199: // {
200: // Assessment assessment = (Assessment) aiter.next();
201: // assessmentList.add(assessment);
202: // }
203: // }
204: // catch(Exception e)
205: // {
206: // log.error(e);
207: // if(assessmentList == null)
208: // {
209: // assessmentList = new ArrayList();
210: // }
211: // }
212: //
213: // return assessmentList;
214: // }
215: //
216: // /**
217: // * This is designed to obtain a list of assessments and their properties.
218: // *
219: // * @return Collection of assessments
220: // */
221: // public Collection getStudentAssessmentList()
222: // {
223: // try
224: // {
225: // AssessmentServiceDelegate delegate = new AssessmentServiceDelegate();
226: // Collection coll = null;
227: // try
228: // {
229: // SharedManager sm = OsidManagerFactory.createSharedManager();
230: // AuthenticationManager am =
231: // OsidManagerFactory.createAuthenticationManager(
232: // OsidManagerFactory.getOsidOwner());
233: // Agent agent =
234: // sm.getAgent(
235: // am.getUserId(new TypeImpl("Stanford", "AAM", "agent", "sunetid")));
236: // long courseId = new Long(course_id).longValue();
237: // coll = delegate.getStudentView(courseId, agent);
238: // }
239: // catch(Exception e)
240: // {
241: // log.warn("Either No Course ID or Agent ID or Both.");
242: // coll = delegate.getStudentView(0, null);
243: // }
244: //
245: // studentAssessmentList = new ArrayList(coll);
246: // }
247: // catch(Exception e)
248: // {
249: // log.error(e);
250: // if(studentAssessmentList == null)
251: // {
252: // studentAssessmentList = new ArrayList();
253: // }
254: // }
255: //
256: // return studentAssessmentList;
257: // }
258:
259: // /**
260: // * DOCUMENTATION PENDING
261: // *
262: // * @param assessmentList DOCUMENTATION PENDING
263: // */
264: // public void setStudentAssessmentList(Collection assessmentList)
265: // {
266: // studentAssessmentList = assessmentList;
267: // }
268: //
269: // /**
270: // * DOCUMENTATION PENDING
271: // *
272: // * @param assessmentList DOCUMENTATION PENDING
273: // */
274: // public void setAssessmentList(Collection assessmentList)
275: // {
276: // this.assessmentList = assessmentList;
277: // }
278:
279: // /**
280: // * DOCUMENTATION PENDING
281: // *
282: // * @return DOCUMENTATION PENDING
283: // */
284: // public Collection getAssessmentTypeList()
285: // {
286: // return assessmentTypeList;
287: // }
288: //
289: // /**
290: // * DOCUMENTATION PENDING
291: // *
292: // * @param assessmentTypeList DOCUMENTATION PENDING
293: // */
294: // public void setAssessmentTypeList(Collection assessmentTypeList)
295: // {
296: // this.assessmentTypeList = assessmentTypeList;
297: // }
298:
299: /**
300: * DOCUMENTATION PENDING
301: *
302: * @return DOCUMENTATION PENDING
303: */
304: public String getAssessmentTypeChoice() {
305: return assessmentTypeChoice;
306: }
307:
308: /**
309: * DOCUMENTATION PENDING
310: *
311: * @param typeChoice DOCUMENTATION PENDING
312: */
313: public void setAssessmentTypeChoice(String typeChoice) {
314: assessmentTypeChoice = typeChoice;
315: }
316:
317: /**
318: * DOCUMENTATION PENDING
319: *
320: * @return DOCUMENTATION PENDING
321: */
322: public String getCourseId() {
323: return course_id;
324: }
325:
326: /**
327: * DOCUMENTATION PENDING
328: *
329: * @param id DOCUMENTATION PENDING
330: */
331: public void setCourseId(String id) {
332: log.debug("Setting course id to " + id);
333: course_id = id;
334: }
335:
336: /**
337: * DOCUMENTATION PENDING
338: *
339: * @return DOCUMENTATION PENDING
340: */
341: public String getAgentId() {
342: return agent_id;
343: }
344:
345: /**
346: * DOCUMENTATION PENDING
347: *
348: * @param id DOCUMENTATION PENDING
349: */
350: public void setAgentId(String id) {
351: log.debug("Setting agent id to " + id);
352: agent_id = id;
353: }
354:
355: public String getTemplateOrderBy() {
356: return this .templateOrderBy;
357: }
358:
359: public void setTemplateOrderBy(String templateOrderBy) {
360: this .templateOrderBy = templateOrderBy;
361: }
362:
363: /**
364: * is Template table sorted in ascending order
365: * @return true if it is
366: */
367: public boolean isTemplateAscending() {
368: return templateAscending;
369: }
370:
371: /**
372: *
373: * @param Ascending is template table sorted in ascending order
374: */
375: public void setTemplateAscending(boolean templateAscending) {
376: this .templateAscending = templateAscending;
377: }
378:
379: private String outcome;
380:
381: public void setOutcome(String outcome) {
382: this .outcome = outcome;
383: }
384:
385: public String getOutcome() {
386: return outcome;
387: }
388:
389: }
|