public void checkForQuestionPoolItem(AssessmentData assessment, Map qpItemHash) { Set sectionSet = getSectionSetForAssessment(assessment); Iterator iter = sectionSet.iterator(); while (iter.hasNext()) { SectionData s = (SectionData) iter.next(); checkForQuestionPoolItem(s, qpItemHash); } }
/** * This method is the same as createAssessment() except that no default * section will be created with the assessment. */ public AssessmentFacade createAssessmentWithoutDefaultSection(String title, String description, Long typeId, Long templateId) throws Exception { return createAssessmentWithoutDefaultSection(title, description, typeId, templateId, null); }
/** * This method return a list of ItemData belings to the section with the * given sectionId * * @param sectionId * @return */ private List loadAllItems(Long sectionId) { return getHibernateTemplate().find( "from ItemData i where i.section.sectionId=" + sectionId); }
public List<AssessmentFacade> getAllActiveAssessments(String orderBy) { List<AssessmentData> list = (List<AssessmentData>) getHibernateTemplate().findByNamedParam( "from AssessmentData a where a.status = :status order by a." + orderBy, "status", 1); List<AssessmentFacade> assessmentList = new ArrayList<>(); for (AssessmentData a : list) { a.setSectionSet(getSectionSetForAssessment(a)); AssessmentFacade f = new AssessmentFacade(a); assessmentList.add(f); } return assessmentList; }
public AssessmentFacade createAssessmentWithoutDefaultSection(String title, String description, Long typeId, Long templateId, String siteId) throws Exception { // this assessment came with one default section AssessmentData assessment = null; try { assessment = prepareAssessment(title, description, typeId, templateId, siteId); } catch (Exception e) { throw new Exception(e); } assessment.setSectionSet(new HashSet()); getHibernateTemplate().save(assessment); // register assessment with current site registerWithSite(assessment.getAssessmentId().toString(), siteId); return new AssessmentFacade(assessment); }
attach.setFileSize(fileSizeInKB(cr.getContentLength())); if (cr.getContentType().lastIndexOf("url") > -1) { isLink = Boolean.TRUE; .getNamePropModifiedBy())); attach.setLastModifiedDate(new Date()); attach.setLocation(getRelativePath(cr.getUrl(), protocol));
public AssessmentFacade createAssessment(String title, String description, Long typeId, Long templateId, String siteId) throws Exception { // this assessment comes with a default section AssessmentData assessment = null; try { assessment = prepareAssessment(title, description, typeId, templateId, siteId); } catch (Exception e) { throw new Exception(e); } int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount() .intValue(); while (retryCount > 0) { try { getHibernateTemplate().save(assessment); retryCount = 0; } catch (Exception e) { log.warn("problem saving assessment: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount); } } // register assessmnet with current site registerWithSite(assessment.getAssessmentId().toString(), siteId); return new AssessmentFacade(assessment); }
public void removeSection(Long sectionId) { SectionData section = loadSection(sectionId); if (section != null) { checkForQuestionPoolItem(section, h); Set sectionSet = getSectionSetForAssessment(assessment); assessment.setSectionSet(sectionSet); List sections = assessment.getSectionArraySorted(); while (retryCount > 0) { try { getHibernateTemplate().update(assessment); // sections while (retryCount > 0) { try { getHibernateTemplate().delete(section); retryCount = 0; } catch (Exception e) {
ContentResource cr = contentHostingService.getResource(resourceId); if (cr != null) { AssessmentFacadeQueries assessmentFacadeQueries = new AssessmentFacadeQueries(); ResourceProperties p = cr.getProperties(); attach = new GradingAttachmentData(); attach.setMimeType(cr.getContentType()); attach.setFileSize(assessmentFacadeQueries.fileSizeInKB(cr.getContentLength())); if (cr.getContentType().lastIndexOf("url") > -1) { isLink = Boolean.TRUE; attach.setLastModifiedBy(p.getProperty(p.getNamePropModifiedBy())); attach.setLastModifiedDate(new Date()); attach.setLocation(assessmentFacadeQueries.getRelativePath(cr.getUrl(), protocol));
public void copyAllAssessments(String fromContext, String toContext, Map<String,String> transversalMap) { List<AssessmentData> list = getAllActiveAssessmentsByAgent(fromContext); List<AssessmentData> newList = new ArrayList<>(); Map<AssessmentData, String> assessmentMap = new HashMap<>(); AssessmentData new_a = prepareAssessment(a, ServerConfigurationService.getServerUrl(), toContext); newList.add(new_a); assessmentMap.put(new_a, CoreAssessmentEntityProvider.ENTITY_PREFIX + "/" + a.getAssessmentBaseId()); getHibernateTemplate().saveOrUpdate(assessmentData); // write getHibernateTemplate().saveOrUpdate(assessmentData); // write
return q.list(); }; List<AssessmentData> list = getHibernateTemplate().execute(hcb); return q2.list(); }; List<Object[]> questionSizeList = getHibernateTemplate().execute(hcb2); Map<Object, Object> questionSizeMap = new HashMap<>(); for (Object[] o : questionSizeList) { if (a.getReleaseTo().equals(AssessmentAccessControl.RELEASE_TO_SELECTED_GROUPS)) { if (groupsForSite == null) { groupsForSite = getGroupsForSite(siteAgentId); releaseToGroups = getReleaseToGroups(groupsForSite, assessmentId);
public void deleteTemplate(Long templateId) { int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount(); while (retryCount > 0) { try { getHibernateTemplate().delete( getAssessmentTemplate(templateId).getData()); retryCount = 0; } catch (Exception e) { log.warn("problem delete template: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount); } } }
private AssessmentData prepareAssessment(String title, String description, Long typeId, Long templateId, String siteId) throws Exception { AssessmentTemplateFacade template = getAssessmentTemplate(templateId); AssessmentData assessment = cloneAssessmentFromTemplate((AssessmentTemplateData) template .getData()); assessment.setTitle(title);
attach.setMimeType(cr.getContentType()); attach.setFileSize(fileSizeInKB(cr.getContentLength())); if (cr.getContentType().lastIndexOf("url") > -1) { isLink = Boolean.TRUE; .getNamePropModifiedBy())); attach.setLastModifiedDate(new Date()); attach.setLocation(getRelativePath(cr.getUrl(), protocol));
public AssessmentFacade createAssessment(String title, String description, Long typeId, Long templateId, String siteId) throws Exception { // this assessment comes with a default section AssessmentData assessment = null; try { assessment = prepareAssessment(title, description, typeId, templateId, siteId); } catch (Exception e) { throw new Exception(e); } int retryCount = PersistenceService.getInstance().getPersistenceHelper().getRetryCount() .intValue(); while (retryCount > 0) { try { getHibernateTemplate().save(assessment); retryCount = 0; } catch (Exception e) { log.warn("problem saving assessment: " + e.getMessage()); retryCount = PersistenceService.getInstance().getPersistenceHelper().retryDeadlock(e, retryCount); } } // register assessmnet with current site registerWithSite(assessment.getAssessmentId().toString(), siteId); return new AssessmentFacade(assessment); }
public void removeSection(Long sectionId) { SectionData section = loadSection(sectionId); if (section != null) { checkForQuestionPoolItem(section, h); Set sectionSet = getSectionSetForAssessment(assessment); assessment.setSectionSet(sectionSet); List sections = assessment.getSectionArraySorted(); while (retryCount > 0) { try { getHibernateTemplate().update(assessment); // sections while (retryCount > 0) { try { getHibernateTemplate().delete(section); retryCount = 0; } catch (Exception e) {
public AssessmentFacade createAssessmentWithoutDefaultSection(String title, String description, Long typeId, Long templateId, String siteId) throws Exception { // this assessment came with one default section AssessmentData assessment = null; try { assessment = prepareAssessment(title, description, typeId, templateId, siteId); } catch (Exception e) { throw new Exception(e); } assessment.setSectionSet(new HashSet()); getHibernateTemplate().save(assessment); // register assessment with current site registerWithSite(assessment.getAssessmentId().toString(), siteId); return new AssessmentFacade(assessment); }
ContentResource cr = contentHostingService.getResource(resourceId); if (cr != null) { AssessmentFacadeQueries assessmentFacadeQueries = new AssessmentFacadeQueries(); ResourceProperties p = cr.getProperties(); attach = new GradingAttachmentData(); attach.setMimeType(cr.getContentType()); attach.setFileSize(assessmentFacadeQueries.fileSizeInKB(cr.getContentLength())); if (cr.getContentType().lastIndexOf("url") > -1) { isLink = Boolean.TRUE; attach.setLastModifiedBy(p.getProperty(p.getNamePropModifiedBy())); attach.setLastModifiedDate(new Date()); attach.setLocation(assessmentFacadeQueries.getRelativePath(cr.getUrl(), protocol));
public void copyAllAssessments(String fromContext, String toContext, Map<String,String> transversalMap) { List<AssessmentData> list = getAllActiveAssessmentsByAgent(fromContext); List<AssessmentData> newList = new ArrayList<>(); Map<AssessmentData, String> assessmentMap = new HashMap<>(); for (AssessmentData a : list) { log.debug("****protocol:" + ServerConfigurationService.getServerUrl()); AssessmentData new_a = prepareAssessment(a, ServerConfigurationService.getServerUrl(), toContext); newList.add(new_a); assessmentMap.put(new_a, CoreAssessmentEntityProvider.ENTITY_PREFIX + "/" + a.getAssessmentBaseId()); getHibernateTemplate().saveOrUpdate(assessmentData); // write getHibernateTemplate().saveOrUpdate(data); String oldRef = assessmentMap.get(data); if (oldRef != null && data.getAssessmentBaseId() != null)
public AssessmentFacade getAssessment(Long assessmentId) { try { AssessmentData assessment = getHibernateTemplate().get(AssessmentData.class, assessmentId); if (assessment != null) { assessment.setSectionSet(getSectionSetForAssessment(assessment)); return new AssessmentFacade(assessment); } } catch (DataAccessException dae) { log.warn("Could not retrieve assessment: {}", assessmentId, dae); } return null; }