-
Notifications
You must be signed in to change notification settings - Fork 26
/
Evaluation.jws
549 lines (450 loc) · 27 KB
/
Evaluation.jws
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.apache.axis.AxisFault;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.authz.cover.SecurityService;
import org.sakaiproject.authz.cover.AuthzGroupService;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.cover.SessionManager;
import org.sakaiproject.user.api.UserDirectoryService;
import org.sakaiproject.evaluation.constant.EvalConstants;
import org.sakaiproject.evaluation.logic.EvalAuthoringService;
import org.sakaiproject.evaluation.logic.EvalEvaluationService;
import org.sakaiproject.evaluation.logic.EvalEvaluationSetupService;
import org.sakaiproject.evaluation.logic.externals.EvalExternalLogic;
import org.sakaiproject.evaluation.logic.EvalEvaluationService;
import org.sakaiproject.evaluation.logic.EvalDeliveryService;
import org.sakaiproject.evaluation.logic.externals.ExternalHierarchyLogic;
import org.sakaiproject.evaluation.logic.model.EvalHierarchyNode;
import org.sakaiproject.evaluation.model.EvalAnswer;
import org.sakaiproject.evaluation.model.EvalEvaluation;
import org.sakaiproject.evaluation.model.EvalScale;
import org.sakaiproject.evaluation.model.EvalTemplateItem;
import org.sakaiproject.evaluation.model.EvalTemplate;
import org.sakaiproject.evaluation.model.EvalItem;
import org.sakaiproject.evaluation.utils.ArrayUtils;
import org.sakaiproject.evaluation.utils.EvalUtils;
import org.sakaiproject.evaluation.utils.TemplateItemDataList;
import org.sakaiproject.evaluation.utils.TemplateItemUtils;
import org.sakaiproject.evaluation.utils.TemplateItemDataList.DataTemplateItem;
import org.sakaiproject.evaluation.utils.TemplateItemDataList.HierarchyNodeGroup;
import org.sakaiproject.evaluation.utils.TemplateItemDataList.TemplateItemGroup;
import org.sakaiproject.util.Validator;
public class Evaluation {
private static final Log LOG = LogFactory.getLog("org.sakaiproject.axis.evaluation");
private EvalAuthoringService evalAuthoringService;
private EvalEvaluationSetupService evalEvaluationSetupService;
private EvalExternalLogic evalExternalLogic;
private EvalEvaluationService evalEvaluationService;
private EvalDeliveryService evalDeliveryService;
private ExternalHierarchyLogic hierarchyLogic;
//private EvalResponseAggregatorUtil responseAggregator;
public Evaluation() {
evalEvaluationService = (EvalEvaluationService) ComponentManager.get("org.sakaiproject.evaluation.logic.EvalEvaluationService");
evalEvaluationSetupService = (EvalEvaluationSetupService) ComponentManager.get("org.sakaiproject.evaluation.logic.EvalEvaluationSetupService");
evalAuthoringService = (EvalAuthoringService) ComponentManager.get("org.sakaiproject.evaluation.logic.EvalAuthoringService");
evalExternalLogic = (EvalExternalLogic) ComponentManager.get("org.sakaiproject.evaluation.logic.externals.EvalExternalLogic");
evalDeliveryService = (EvalDeliveryService) ComponentManager.get("org.sakaiproject.evaluation.logic.EvalDeliveryService");
hierarchyLogic = (ExternalHierarchyLogic) ComponentManager.get("org.sakaiproject.evaluation.logic.externals.ExternalHierarchyLogic");
//responseAggregator = (EvalResponseAggregatorUtil) ComponentManager.get("org.sakaiproject.evaluation.tool.utils.EvalResponseAggregatorUtil");
}
private void checkSecurity(String sessionid) throws AxisFault {
Session session = establishSession(sessionid);
if (!SecurityService.isSuperUser() && !"evaluation".equals(session.getUserEid()))
{
LOG.warn("NonSuperUser trying to script eval: " + session.getUserId());
throw new AxisFault("NonSuperUser trying script eval: " + session.getUserId());
}
}
private Session establishSession(String id) throws AxisFault
{
Session s = SessionManager.getSession(id);
if (s == null) {
throw new AxisFault("Session "+id+" is not active");
}
s.setActive();
SessionManager.setCurrentSession(s);
return s;
}
public String getEvalBySectionEid(String sectioneid) throws AxisFault {
// Look up the course id
//AuthzGroupService.getAuthzGroupIds(String sectioneid);
return "not-implemented";
}
/* Reporting methods */
public String getAllResponses(String sessionid, Long evaluationId, String groupid) throws AxisFault {
checkSecurity(sessionid);
LOG.info("getResponses: "+ sessionid + " " + evaluationId + " ");
EvalEvaluation evaluation = evalEvaluationService.getEvaluationById(evaluationId);
String groupIds[] = new String[]{ groupid };
String responseList = "";
// do a permission check
// if (! reportingPermissions.canViewEvaluationResponses(evaluation, reportViewParams.groupIds)) {
// throw new SecurityException("Invalid user attempting to access reports page: " + currentUserId);
// }
Long templateId = evaluation.getTemplate().getId();
// Fetch most of all the data and metadata with the ultra TIDL object
TemplateItemDataList tidl = prepareTemplateItemDataStructure(evaluation, groupIds);
List<EvalTemplateItem> allTemplateItems = tidl.getAllTemplateItems();
if (! allTemplateItems.isEmpty()) {
// Evaluation Info
// evaluation.getTitle());
// get the list of all instructors for this report and put the user objects for them into a map
// Set<String> instructorIds = TemplateItemDataList.getInstructorsForAnswers(tidl.getAnswers());
// Map<String, EvalUser> instructorIdtoEvalUser = responseAggregator.getInstructorsInformation(instructorIds);
int renderedItemCount = 0;
// loop through the TIGs and handle each associated category
for (TemplateItemGroup tig : tidl.getTemplateItemGroups()) {
// loop through the hierarchy node groups
for (HierarchyNodeGroup hng : tig.hierarchyNodeGroups) {
List<DataTemplateItem> dtis = hng.getDataTemplateItems(true); // include block children
for (int i = 0; i < dtis.size(); i++) {
DataTemplateItem dti = dtis.get(i);
EvalTemplateItem templateItem = dti.templateItem;
String templateItemType = TemplateItemUtils.getTemplateItemType(templateItem);
if ( EvalConstants.ITEM_TYPE_SCALED.equals(templateItemType)
|| EvalConstants.ITEM_TYPE_MULTIPLEANSWER.equals(templateItemType)
|| EvalConstants.ITEM_TYPE_MULTIPLECHOICE.equals(templateItemType)
|| EvalConstants.ITEM_TYPE_BLOCK_CHILD.equals(templateItemType) ) {
responseList = responseList + templateItem.getId() + "," + templateItem.getItem().getCopyOf() + "," +templateItem.getItem().getEid() + ",";
// evalExternalLogic.makePlainTextFromHTML(templateItem.getItem().getItemText()) + ",";
// get the answers associated with this data template item
List<EvalAnswer> itemAnswers = dti.getAnswers();
int responsesCount = itemAnswers.size();
EvalScale scale = templateItem.getItem().getScale();
List<String> scaleOptions = scale.getOptions();
String scaleLabels[] = new String[scaleOptions.size()];
int[] choicesCounts = TemplateItemDataList.getAnswerChoicesCounts(templateItemType, scaleOptions.size(), itemAnswers);
for (int x = 0; x < scaleLabels.length; x++) {
responseList = responseList + choicesCounts[x] + ",";
// evalExternalLogic.makePlainTextFromHTML(scaleOptions.get(x)) +
}
if (templateItem.getUsesNA() != null && templateItem.getUsesNA()) {
responseList = responseList + choicesCounts[choicesCounts.length-1] + ",";
//"na" + " : " +
}
renderedItemCount++;
responseList = responseList + "END\n";
}
}
}
}
}
return responseList;
}
public String getRespondents(String sessionid, Long evaluationId, String groupid) throws AxisFault {
return "not-implemented";
}
/* Create a scale with mostly default settings */
public String addScale(String sessionid, String ownerEid, String title, List<String> choices) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
EvalScale scale = new EvalScale(ownerId, title, EvalConstants.SCALE_MODE_SCALE, DEFAULT_SHARING, DEFAULT_IS_EXPERT);
scale.setOptions(choices);
// We may need to add an option for the scale type
scale.setIdeal(EvalConstants.SCALE_IDEAL_HIGH);
evalAuthoringService.saveScale(scale,ownerId);
return scale.getId()+"";
}
public String addScale(String sessionid, String ownerEid, String title, List<String> choices, String scaletype) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
EvalScale scale = new EvalScale(ownerId, title, EvalConstants.SCALE_MODE_SCALE, DEFAULT_SHARING, DEFAULT_IS_EXPERT);
scale.setOptions(choices);
// We may need to add an option for the scale type
scale.setIdeal(scaletype);
evalAuthoringService.saveScale(scale,ownerId);
return scale.getId()+"";
}
/**
* This addScale method takes an EID and Scale Mode
*
*/
public String addScale(String sessionid, String ownerEid, List<String> choices, String idealscaletype, String scaleEid, String scaleMode) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
EvalScale scale = new EvalScale(ownerId, EvalUtils.makeUniqueIdentifier(36), scaleMode, DEFAULT_SHARING, DEFAULT_IS_EXPERT);
scale.setOptions(choices);
// We may need to add an option for the scale type
scale.setIdeal(idealscaletype);
scale.setEid(scaleEid);
evalAuthoringService.saveScale(scale,ownerId);
return scale.getId()+"";
}
/*
* Returns a String representation of the new Template ID.
*/
public String addTemplate(String sessionid, String ownerEid, String title, String desc) throws AxisFault {
checkSecurity(sessionid);
return addTemplate(sessionid, ownerEid, title, desc, "private", false, "standard");
}
/*
* Returns a String representation of the new Template ID.
*/
public String addTemplate(String sessionid, String ownerEid, String title, String desc, String sharing,
boolean expert, String templateType) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
EvalTemplate template = new EvalTemplate(ownerId, templateType,title,sharing,new Boolean(expert));
template.setDescription(desc);
template.setExpertDescription("");
evalAuthoringService.saveTemplate(template,ownerId);
return template.getId()+"";
}
public String addHeaderItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText) throws AxisFault {
checkSecurity(sessionid);
return addHeaderItemToTemplate(sessionid, templateId,ownerEid,itemText,DEFAULT_SHARING,DEFAULT_CATEGORY,
DEFAULT_IS_EXPERT,EvalConstants.HIERARCHY_LEVEL_TOP,EvalConstants.HIERARCHY_NODE_ID_NONE);
}
private static final String DEFAULT_SHARING = EvalConstants.SHARING_PRIVATE;
private static final String DEFAULT_EVAL_STATE = EvalConstants.EVALUATION_STATE_VIEWABLE;
private static final String DEFAULT_CATEGORY = "Course";
private static final boolean DEFAULT_IS_EXPERT = false;
private String getOwnerId(String ownerEid) throws AxisFault {
return evalExternalLogic.getUserId(ownerEid);
}
public String addHeaderItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, String sharing, String category, boolean expert, String hierLevel,
String hierNodeId) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
String classification = "Header";
Long templateIdLong = new Long( templateId);
EvalTemplate evalTemplate = evalAuthoringService.getTemplateById(templateIdLong);
EvalItem evalItem = new EvalItem(new Date(),ownerId,itemText,sharing,classification,expert);
evalAuthoringService.saveItem(evalItem,ownerId);
int displayOrder = evalTemplate.getTemplateItems().size()+1;
EvalTemplateItem templateItem = new EvalTemplateItem(ownerId, evalTemplate, evalItem, displayOrder,
category, hierLevel, hierNodeId);
evalAuthoringService.saveTemplateItem(templateItem,ownerId);
return templateItem.getId()+"";
}
public String addEssayItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, int numberOfResponseLines) throws AxisFault {
checkSecurity(sessionid);
return addEssayItemToTemplate(sessionid, templateId, ownerEid, itemText, numberOfResponseLines,
DEFAULT_SHARING, DEFAULT_CATEGORY, DEFAULT_IS_EXPERT, EvalConstants.HIERARCHY_LEVEL_TOP, EvalConstants.HIERARCHY_NODE_ID_NONE);
}
public String addEssayItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, int numberOfResponseLines, String sharing, String category, boolean expert, String hierLevel,
String hierNodeId) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
String classification = "Essay";
Long templateIdLong = new Long(templateId);
EvalTemplate evalTemplate = evalAuthoringService.getTemplateById(templateIdLong);
EvalItem evalItem = new EvalItem(new Date(),ownerId,itemText,sharing,classification,expert);
evalItem.setDisplayRows(new Integer(numberOfResponseLines));
evalAuthoringService.saveItem(evalItem,ownerId);
int displayOrder = evalTemplate.getTemplateItems().size()+1;
EvalTemplateItem templateItem = new EvalTemplateItem(ownerId, evalTemplate, evalItem, displayOrder,
category, hierLevel, hierNodeId);
evalAuthoringService.saveTemplateItem(templateItem,ownerId);
return templateItem.getId()+"";
}
/* This version takes a scale id, rather than array of strings to make a new scale */
public String addScaledItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, String scaleDisplayType, int scaleId) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
// Fetch the Scale
EvalScale scale = evalAuthoringService.getScaleById(new Long(scaleId));
String classification = EvalConstants.ITEM_TYPE_SCALED;
Long templateIdLong = new Long(templateId);
EvalTemplate evalTemplate = evalAuthoringService.getTemplateById(templateIdLong);
EvalItem evalItem = new EvalItem(new Date(),ownerId,itemText,DEFAULT_SHARING,classification,DEFAULT_IS_EXPERT);
evalItem.setScale(scale);
evalItem.setScaleDisplaySetting(scaleDisplayType);
//evalItem.setScaleDisplaySetting("Vertical");
evalAuthoringService.saveItem(evalItem,ownerId);
int displayOrder = evalTemplate.getTemplateItems().size()+1;
EvalTemplateItem templateItem = new EvalTemplateItem(ownerId, evalTemplate, evalItem, displayOrder,
DEFAULT_CATEGORY, EvalConstants.HIERARCHY_LEVEL_TOP, EvalConstants.HIERARCHY_NODE_ID_NONE);
evalAuthoringService.saveTemplateItem(templateItem,ownerId);
return templateItem.getId()+"";
}
public String addScaledItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, List<String> choices, String scaleDisplayType) throws AxisFault {
checkSecurity(sessionid);
return addScaledItemToTemplate(sessionid, templateId, ownerEid, itemText, choices, scaleDisplayType,
DEFAULT_SHARING, DEFAULT_CATEGORY, DEFAULT_IS_EXPERT, EvalConstants.HIERARCHY_LEVEL_TOP, EvalConstants.HIERARCHY_NODE_ID_NONE);
}
public String addScaledItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, List<String> choices, String scaleDisplayType, String sharing, String category, boolean expert, String hierLevel,
String hierNodeId) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
//Make the Scale
EvalScale scale = new EvalScale(ownerId, EvalUtils.makeUniqueIdentifier(36), EvalConstants.SCALE_MODE_SCALE, DEFAULT_SHARING, DEFAULT_IS_EXPERT);
scale.setOptions(choices);
// We may need to add an option for the scale type
scale.setIdeal(EvalConstants.SCALE_IDEAL_HIGH);
evalAuthoringService.saveScale(scale,ownerId);
String classification = EvalConstants.ITEM_TYPE_SCALED;
Long templateIdLong = new Long(templateId);
EvalTemplate evalTemplate = evalAuthoringService.getTemplateById(templateIdLong);
EvalItem evalItem = new EvalItem(new Date(),ownerId,itemText,sharing,classification,expert);
evalItem.setScale(scale);
evalItem.setScaleDisplaySetting(scaleDisplayType);
//evalItem.setScaleDisplaySetting("Vertical");
evalAuthoringService.saveItem(evalItem,ownerId);
int displayOrder = evalTemplate.getTemplateItems().size()+1;
EvalTemplateItem templateItem = new EvalTemplateItem(ownerId, evalTemplate, evalItem, displayOrder,
category, hierLevel, hierNodeId);
evalAuthoringService.saveTemplateItem(templateItem,ownerId);
return templateItem.getId()+"";
}
public String addMultipleChoiceItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, int scaleId) throws AxisFault {
checkSecurity(sessionid);
return addMultipleChoiceItemToTemplate(sessionid, templateId, ownerEid, itemText, scaleId,
DEFAULT_SHARING, DEFAULT_CATEGORY, DEFAULT_IS_EXPERT, EvalConstants.HIERARCHY_LEVEL_TOP, EvalConstants.HIERARCHY_NODE_ID_NONE);
}
public String addMultipleChoiceItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, int scaleId, String sharing, String category, boolean expert, String hierLevel,
String hierNodeId) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
//Make the Scale
EvalScale scale = evalAuthoringService.getScaleById(new Long(scaleId));
String classification = "MultipleChoice";
Long templateIdLong = new Long(templateId);
EvalTemplate evalTemplate = evalAuthoringService.getTemplateById(templateIdLong);
EvalItem evalItem = new EvalItem(new Date(),ownerId,itemText,sharing,classification,expert);
evalItem.setScale(scale);
evalItem.setScaleDisplaySetting("Vertical");
evalAuthoringService.saveItem(evalItem,ownerId);
int displayOrder = evalTemplate.getTemplateItems().size()+1;
EvalTemplateItem templateItem = new EvalTemplateItem(ownerId, evalTemplate, evalItem, displayOrder,
category, hierLevel, hierNodeId);
evalAuthoringService.saveTemplateItem(templateItem,ownerId);
return templateItem.getId()+"";
}
public String addMultipleAnswerItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, int scaleId) throws AxisFault {
checkSecurity(sessionid);
return addMultipleAnswerItemToTemplate(sessionid, templateId, ownerEid, itemText, scaleId,
DEFAULT_SHARING, DEFAULT_CATEGORY, DEFAULT_IS_EXPERT, EvalConstants.HIERARCHY_LEVEL_TOP, EvalConstants.HIERARCHY_NODE_ID_NONE);
}
public String addMultipleAnswerItemToTemplate(String sessionid, int templateId, String ownerEid,
String itemText, int scaleId, String sharing, String category, boolean expert, String hierLevel,
String hierNodeId) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
//Make the Scale
EvalScale scale = evalAuthoringService.getScaleById(new Long(scaleId));
String classification = "MultipleAnswer";
Long templateIdLong = new Long(templateId);
EvalTemplate evalTemplate = evalAuthoringService.getTemplateById(templateIdLong);
EvalItem evalItem = new EvalItem(new Date(),ownerId,itemText,sharing,classification,expert);
evalItem.setScale(scale);
evalItem.setScaleDisplaySetting("Vertical");
evalAuthoringService.saveItem(evalItem,ownerId);
int displayOrder = evalTemplate.getTemplateItems().size()+1;
EvalTemplateItem templateItem = new EvalTemplateItem(ownerId, evalTemplate, evalItem, displayOrder,
category, hierLevel, hierNodeId);
evalAuthoringService.saveTemplateItem(templateItem,ownerId);
return templateItem.getId()+"";
}
/**
* Returns the String representation of the created evaluation id
*
* This creates a Simple Evaluation with some stop/due/view dates based off
* the current time.
*
* If anonymous is set to true the survey will be anonymous. If set to false,
* will try to use the groupIds params to assign the authentication.
*/
/*
public String createSimpleEvaluation(String sessionid, String ownerEid, String title,
String instructions, int templateId, boolean anonymous, String[] groupIds) throws AxisFault {
checkSecurity(sessionid);
String ownerId = getOwnerId(ownerEid);
Date startDate = new Date();
Date dueDate = new Date(startDate.getTime() + (1000 * 60 * 3));
Date stopDate = new Date(startDate.getTime() + (1000 * 60 * 4));
Date viewDate = new Date(startDate.getTime() + (1000 * 60 * 5));
EvalTemplate template = evalAuthoringService.getTemplateById(new Long(templateId));
//EvalEvaluation eval = new EvalEvaluation(ownerId, title, startDate, dueDate,
// stopDate, viewDate, DEFAULT_EVAL_STATE, new Integer(0), template);
String authtype = EvalConstants.EVALUATION_AUTHCONTROL_NONE;
if (!anonymous) {
authtype = EvalConstants.EVALUATION_AUTHCONTROL_AUTH_REQ;
}
// Get the EmailTemplates getDefaultEmailTemplate
EvalEmailTemplate availableEmailTemplate = evalEvaluationService.getDefaultEmailTemplate(EvalConstants.EMAIL_TEMPLATE_DEFAULT_CREATED);
EvalEmailTemplate reminderEmailTemplate = evalEvaluationService.getDefaultEmailTemplate(EvalConstants.EMAIL_TEMPLATE_AVAILABLE);
EvalEvaluation eval = new EvalEvaluation(
EvalConstants.EVALUATION_TYPE_EVALUATION, // type
ownerId, title, instructions, //eval owner, title, and instructions
startDate, dueDate, stopDate, viewDate, // start, due, stop, and view dates
null, null, // studentsDate, instructorsDate
DEFAULT_EVAL_STATE, EvalConstants.INSTRUCTOR_OPT_OUT, // eval state and instructor opting
new Integer(0), "[email protected]", // reminderDays, reminder email
null, // termid
availableEmailTemplate, reminderEmailTemplate, // EvalEmailTemplates for availableEmailTemplate and reminderEmailTemplate
template,
null, // EvalTemplate for added template?
null, // Set<EvalResponse> responses,
new Boolean(false), // resultsPrivate,
new Boolean(true), new Boolean(false), // blankResponsesAllowed, modifyResponsesAllowed
new Boolean(false), new Boolean(false), // unregisteredAllowed, locked
authtype, "" // authControl, evalCategory
);
evalEvaluationSetupService.saveEvaluation(eval, ownerId);
if (!anonymous) {
evalEvaluationSetupService.addEvalAssignments(eval.getId(), new String[] {}, groupIds);
}
return eval.getId()+"";
}
*/
/* Returns the String representation of the created evaluation id */
//public boolean checkIfTemplateExists(String sessionid, String templateName) throws AxisFault {
// checkSecurity(sessionid);
// return !evalAuthoringService.checkTemplateTitleUnused(templateName, null);
// }
//public boolean checkIfScaleExists(String sessionid, String templateName) throws AxisFault {
// checkSecurity(sessionid);
// return !evalAuthoringService.checkTemplateTitleUnused(templateName, null);
//}
/* Util methods */
// copied from EvalResponseAggregatorUtil
private TemplateItemDataList prepareTemplateItemDataStructure(EvalEvaluation eval, String[] groupIds) {
List<EvalTemplateItem> allTemplateItems =
evalAuthoringService.getTemplateItemsForTemplate(eval.getTemplate().getId(), new String[] {}, new String[] {}, new String[] {});
// get all the answers
List<EvalAnswer> answers = evalDeliveryService.getAnswersForEval(eval.getId(), groupIds, null);
// get the list of all instructors for this report and put the user objects for them into a map
Set<String> instructorIds = TemplateItemDataList.getInstructorsForAnswers(answers);
// Get the sorted list of all nodes for this set of template items
List<EvalHierarchyNode> hierarchyNodes = makeEvalNodesList(hierarchyLogic, allTemplateItems);
// make the TI data structure
Map<String, List<String>> associates = new HashMap<String, List<String>>();
associates.put(EvalConstants.ITEM_CATEGORY_INSTRUCTOR, new ArrayList<String>(instructorIds));
TemplateItemDataList tidl = new TemplateItemDataList(allTemplateItems, hierarchyNodes, associates, answers);
return tidl;
}
// copied from ...
private static List<EvalHierarchyNode> makeEvalNodesList(ExternalHierarchyLogic hierarchyLogic, List<EvalTemplateItem> templateItems) {
Set<String> nodeIds = new HashSet<String>();
for (EvalTemplateItem templateItem : templateItems) {
if (EvalConstants.HIERARCHY_LEVEL_NODE.equals(templateItem.getHierarchyLevel())) {
nodeIds.add(templateItem.getHierarchyNodeId());
}
}
List<EvalHierarchyNode> hierarchyNodes = new ArrayList<EvalHierarchyNode>();
if (nodeIds.size() > 0) {
Set<EvalHierarchyNode> nodes = hierarchyLogic.getNodesByIds(nodeIds.toArray(new String[] {}));
hierarchyNodes = hierarchyLogic.getSortedNodes(nodes);
}
return hierarchyNodes;
}
}