当前位置: 首页>>代码示例>>Java>>正文


Java Assignment.getCategoryName方法代码示例

本文整理汇总了Java中org.sakaiproject.service.gradebook.shared.Assignment.getCategoryName方法的典型用法代码示例。如果您正苦于以下问题:Java Assignment.getCategoryName方法的具体用法?Java Assignment.getCategoryName怎么用?Java Assignment.getCategoryName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sakaiproject.service.gradebook.shared.Assignment的用法示例。


在下文中一共展示了Assignment.getCategoryName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeGradebookItem

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Remove an assignment using the external id to locate it,
 * will only remove assignments which actually are externally managed by us
 * 
 * @param gradebookId the gradebook unique id (can also be the siteId)
 * @param externalId the external id for the assignment (must be externally controlled)
 * @return the Assignment if found and removed OR null if not found and NOT removed
 */
public GradebookItem removeGradebookItem(String gradebookId, String externalId) {
    GradebookItem removed = null;
    Assignment a = findAssignmentByExternalId(gradebookId, externalId);
    if (a != null) {
        /* NOTES:
         * (1) Removing the Assignment only does not work, adding external ones later will cause exceptions (externalId in use)
         *      gradebookService.removeAssignment(a.getId());
         * (2) Breaking the connection only does not actually remove the Assignment
         *      gradebookExternalAssessmentService.setExternalAssessmentToGradebookAssignment(gradebookId, externalId);
         * (3) The correct way which seems to remove the external assessment, Assignment, and scores is removeExternalAssessment
         *      gradebookExternalAssessmentService.removeExternalAssessment(gradebookId, externalId);
         */
        gradebookExternalAssessmentService.removeExternalAssessment(gradebookId, externalId);
        removed = new GradebookItem(gradebookId, a.getName(), a.getPoints(), a.getDueDate(), a.getCategoryName(), a.isReleased(), a.isCounted());
        removed.id = a.getId();
        removed.deleted = true;
    }
    return removed;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:28,代码来源:ExternalLogic.java

示例2: initializeCategorizedAssignmentOrder

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Set up initial Categorized Assignment Order
 */
private Map<String, List<Long>> initializeCategorizedAssignmentOrder(String siteId) throws JAXBException, IdUnusedException, PermissionException {
  Gradebook gradebook = getGradebook(siteId);

  List<Assignment> assignments = getGradebookAssignments();

  Map<String, List<Long>> categoriesToAssignments = new HashMap<String, List<Long>>();
  for (Assignment assignment : assignments) {
    String category = assignment.getCategoryName();
    if (!categoriesToAssignments.containsKey(category)) {
      categoriesToAssignments.put(category, new ArrayList<Long>());
    }
    categoriesToAssignments.get(category).add(assignment.getId());
  }

  storeCategorizedAssignmentsOrder(siteId, categoriesToAssignments);

  return categoriesToAssignments;
}
 
开发者ID:steveswinsburg,项目名称:gradebookNG,代码行数:22,代码来源:GradebookNgBusinessService.java

示例3: removeAssignment

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Remove an assignment from its gradebook
 * @param assignmentId the id of the assignment to remove
 */
public void removeAssignment(Long assignmentId) {
   Assignment assignment = getAssignment(assignmentId);
   String category = assignment.getCategoryName();

   this.gradebookService.removeAssignment(assignmentId);

   // remove assignment from the categorized sort order XML
   Map<String, List<Long>> categorizedOrder = getCategorizedAssignmentsOrder();
   if (categorizedOrder.containsKey(category)) {
       boolean removed = categorizedOrder.get(category).remove(assignmentId);
       if (removed) {
           try {
               storeCategorizedAssignmentsOrder(getCurrentSiteId(), categorizedOrder);
           } catch (JAXBException | IdUnusedException | PermissionException e) {
               e.printStackTrace();
               log.error("Unable to storeCategorizedAssignmentsOrder after removing assignmentId: " + assignmentId);
           }
       }
   }
}
 
开发者ID:steveswinsburg,项目名称:gradebookNG,代码行数:25,代码来源:GradebookNgBusinessService.java

示例4: getCategoryName

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Helper to get the category name. Looks at settings as well.
 *
 * @param assignment
 * @return
 */
private String getCategoryName(final Assignment assignment) {
	if (!this.categoriesEnabled) {
		return getString(GradebookPage.UNCATEGORISED);
	}
	return StringUtils.isBlank(assignment.getCategoryName()) ? getString(GradebookPage.UNCATEGORISED) : assignment.getCategoryName();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:13,代码来源:StudentGradeSummaryGradesPanel.java

示例5: getCategoryName

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Helper to get the category name. Looks at settings as well.
 *
 * @param assignment
 * @return
 */
private String getCategoryName(final Assignment assignment, final boolean categoriesEnabled) {

	if (!categoriesEnabled) {
		return getString(GradebookPage.UNCATEGORISED);
	}

	return StringUtils.isBlank(assignment.getCategoryName()) ? getString(GradebookPage.UNCATEGORISED) : assignment.getCategoryName();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:15,代码来源:ToggleGradeItemsToolbarPanel.java

示例6: getCategoryName

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Helper to get the category name. Looks at settings as well.
 *
 * @param assignment
 * @return
 */
private String getCategoryName(final Assignment assignment) {
	if (!this.categoriesEnabled) {
		return getString(GradebookPage.UNCATEGORISED);
	}

	return StringUtils.isBlank(assignment.getCategoryName()) ? getString(GradebookPage.UNCATEGORISED) : assignment.getCategoryName();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:14,代码来源:InstructorGradeSummaryGradesPanel.java

示例7: compare

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
@Override
public int compare(final Assignment a1, final Assignment a2) {
	// if in the same category, sort by their categorized sort order
	if (Objects.equals(a1.getCategoryId(), a2.getCategoryId())) {
		// handles null orders by putting them at the end of the list
		if (a1.getCategorizedSortOrder() == null) {
			return 1;
		} else if (a2.getCategorizedSortOrder() == null) {
			return -1;
		}
		return Integer.compare(a1.getCategorizedSortOrder(), a2.getCategorizedSortOrder());

		// otherwise, sort by their category order
	} else {
		if (a1.getCategoryOrder() == null && a2.getCategoryOrder() == null) {
			// both orders are null.. so order by A-Z
			if (a1.getCategoryName() == null && a2.getCategoryName() == null) {
				// both names are null so order by id
				return a1.getCategoryId().compareTo(a2.getCategoryId());
			} else if (a1.getCategoryName() == null) {
				return 1;
			} else if (a2.getCategoryName() == null) {
				return -1;
			} else {
				return a1.getCategoryName().compareTo(a2.getCategoryName());
			}
		} else if (a1.getCategoryOrder() == null) {
			return 1;
		} else if (a2.getCategoryOrder() == null) {
			return -1;
		} else {
			return a1.getCategoryOrder().compareTo(a2.getCategoryOrder());
		}
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:36,代码来源:SortGradeItemsByCategoryPanel.java

示例8: updateCategorizedAssignmentOrder

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Update the categorized order of an assignment.
 *
 * @param siteId the site's id
 * @param assignmentId the assignment we are reordering
 * @param order the new order
 * @throws JAXBException
 * @throws IdUnusedException
 * @throws PermissionException
 */
public void updateCategorizedAssignmentOrder(String siteId, long assignmentId, int order) throws JAXBException, IdUnusedException, PermissionException {
  Site site = null;
  try {
    site = this.siteService.getSite(siteId);
  } catch (IdUnusedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return;
  }

  Gradebook gradebook = (Gradebook)gradebookService.getGradebook(siteId);

  if (gradebook == null) {
    log.error(String.format("Gradebook not in site %s", siteId));
    return;
  }

  Assignment assignmentToMove = gradebookService.getAssignment(gradebook.getUid(), assignmentId);

  if (assignmentToMove == null) {
    // TODO Handle assignment not in gradebook
    log.error(String.format("Assignment %d not in site %s", assignmentId, siteId));
    return;
  }

  String category = assignmentToMove.getCategoryName();

  Map<String, List<Long>> orderedAssignments = getCategorizedAssignmentsOrder(siteId);

  if (!orderedAssignments.containsKey(category)) {
    orderedAssignments = initializeCategorizedAssignmentOrder(siteId, category);
  }

  orderedAssignments.get(category).remove(assignmentToMove.getId());

  if (orderedAssignments.get(category).size() == order) {
    orderedAssignments.get(category).add(assignmentToMove.getId());
  } else {
    orderedAssignments.get(category).add(order, assignmentToMove.getId());
  }

  storeCategorizedAssignmentsOrder(siteId, orderedAssignments);
}
 
开发者ID:steveswinsburg,项目名称:gradebookNG,代码行数:54,代码来源:GradebookNgBusinessService.java


注:本文中的org.sakaiproject.service.gradebook.shared.Assignment.getCategoryName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。