* Load referenced checklist or create a new one
* @param cpm
* @return Checklist
*/
public Checklist loadOrCreateChecklist(final CoursePropertyManager cpm) {
Checklist checklist;
if(getChecklistKey(cpm) == null) {
// this is a copied node, the checklist is referenced by createInstanceForCopy()
if(getModuleConfiguration().get(CONF_CHECKLIST_COPY) != null) {
checklist = ChecklistManager.getInstance().loadChecklist((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST_COPY));
getModuleConfiguration().remove(CONF_CHECKLIST_COPY);
} else
// this is part of a copied course, the original checklist will be copied
if(getModuleConfiguration().get(CONF_CHECKLIST) != null) {
Checklist orgChecklist = ChecklistManager.getInstance().loadChecklist((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST));
checklist = ChecklistManager.getInstance().copyChecklist(orgChecklist);
} else {
// no checklist available, create new one
checklist = new Checklist();
ChecklistManager.getInstance().saveChecklist(checklist);
}
// set referenced checklist in configuration
setChecklistKey(cpm, checklist.getKey());
} else {