本文整理汇总了Java中org.sakaiproject.service.gradebook.shared.Assignment类的典型用法代码示例。如果您正苦于以下问题:Java Assignment类的具体用法?Java Assignment怎么用?Java Assignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Assignment类属于org.sakaiproject.service.gradebook.shared包,在下文中一共展示了Assignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssociatedGbItem
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
/**
* Return the Gradebook item associated with an assignment.
* @param data Map containing Site/Assignment IDs
* @return Associated gradebook item
*/
public Assignment getAssociatedGbItem(Map data){
Assignment assignment = null;
String taskId = data.get("taskId").toString();
String siteId = data.get("siteId").toString();
String taskTitle = data.get("taskTitle").toString();
pushAdvisor();
try {
List<Assignment> allGbItems = gradebookService.getAssignments(siteId);
for (Assignment assign : allGbItems) {
//Match based on External ID / Assignment title
if(taskId.equals(assign.getExternalId()) || assign.getName().equals(taskTitle) ){
assignment = assign;
break;
}
}
} catch (Exception e) {
log.error("(allGbItems)"+e.toString());
} finally{
popAdvisor();
}
return assignment;
}
示例2: validateActivityConfiguration
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
@Override
public boolean validateActivityConfiguration(String toolId, String activityId)
{
// if new integration, check for the turnitin assignment id and the stealthed lti id
boolean useLTI;
try
{
// assume we're always in assignments since this is just a temporary check until
// we remove the legacy integration
org.sakaiproject.assignment.api.Assignment asn = assignmentService.getAssignment(activityId);
Site site = siteService.getSite(asn.getContext());
useLTI = siteAdvisor.siteCanUseLTIReviewServiceForAssignment(site, new Date(asn.getTimeCreated().getTime()));
}
catch (IdUnusedException | PermissionException e)
{
log.debug("Unable to find Assignment for the given activity id (" + activityId + ")", e);
return false;
}
return !useLTI || (!getActivityConfigValue(TurnitinConstants.TURNITIN_ASN_ID, activityId, toolId, TurnitinConstants.PROVIDER_ID).isEmpty()
&& !getActivityConfigValue(TurnitinConstants.STEALTHED_LTI_ID, activityId, toolId, TurnitinConstants.PROVIDER_ID).isEmpty());
}
示例3: findAssignmentByExternalId
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
/**
* Find an internal assignment (with internal id) for an assignment in a gradebook by the external id if it exists
*
* @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 OR null if not found
*/
protected Assignment findAssignmentByExternalId(String gradebookId, String externalId) {
Assignment assignment = null;
if (gradebookExternalAssessmentService.isExternalAssignmentDefined(gradebookId, externalId)) {
@SuppressWarnings("unchecked")
List<Assignment> assignments = gradebookService.getAssignments(gradebookId);
for (Assignment a : assignments) {
if (externalId.equals(a.getExternalId())
&& EXTERNAL_DATASOURCE.equals(a.getExternalAppName()) ) {
assignment = a;
break;
}
}
}
return assignment;
}
示例4: 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;
}
示例5: getEntitiesForContext
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
public Map<String, String> getEntitiesForContext(String gradebookUid) {
Map<String, String> rv = new LinkedHashMap<String, String>();
if (!gbs.isGradebookDefined(gradebookUid)) {
return rv;
}
List<Assignment> assignments = gbs.getAssignments(gradebookUid, SortType.SORT_BY_NAME);
for (Assignment asn : assignments) {
String assignmentName = asn.getName();
String assignmentPoints = asn.getPoints().toString();
boolean isReleasedToStudents = asn.isReleased();
boolean isUsedInGradeCalculation = asn.isCounted();
Date dueDate = asn.getDueDate();
long dueDateMillis = 0;
if (dueDate != null) dueDateMillis = dueDate.getTime();
// event resource of the form: /gradebook/[gradebook id]/[assignment name]/[points possible]/[due date millis]/[is released]/[is included in course grade]/[has authz]
rv.put("/gradebook/"+ gradebookUid + "/" + assignmentName + "/" + assignmentPoints + "/" + dueDateMillis + "/" + isReleasedToStudents + "/" + isUsedInGradeCalculation , assignmentName + " (" + assignmentPoints + " points)");
}
return rv;
}
示例6: getData
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
public Map<String, String> getData(String type, String context) {
Map<String, String> rv = new HashMap<String, String>();
if ("grades".equals(type)) {
String[] contextParts = context.split("\\|");
String gradebookId = contextParts[0];
String assignmentName = contextParts[1];
String studentId = contextParts[2];
Long assignmentId = null;
for (Object assignment : gbs.getAssignments(gradebookId)) {
if (((Assignment)assignment).getName().equals(assignmentName)) {
assignmentId = ((Assignment)assignment).getId();
break;
}
}
if (assignmentId != null) {
String score = gbs.getAssignmentScoreString(gradebookId, assignmentId, studentId);
if (score == null) {
score = "";
}
rv.put("score", score);
}
}
return rv;
}
示例7: getAssociatedGbItem
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
/**
* Return the Gradebook item associated with an assignment.
*
* @param data
* Map containing Site/Assignment IDs
* @return Associated gradebook item
*/
public Assignment getAssociatedGbItem(Map data) {
Assignment assignment = null;
String taskId = data.get("taskId").toString();
String siteId = data.get("siteId").toString();
String taskTitle = data.get("taskTitle").toString();
pushAdvisor();
try {
List<Assignment> allGbItems = gradebookService.getAssignments(siteId);
for (Assignment assign : allGbItems) {
// Match based on External ID / Assignment title
if (taskId.equals(assign.getExternalId()) || assign.getName().equals(taskTitle)) {
assignment = assign;
break;
}
}
} catch (Exception e) {
log.error("(allGbItems)" + e.toString());
} finally {
popAdvisor();
}
return assignment;
}
示例8: calculateCurrentCategorizedSortOrder
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
/**
* Get the assignment's current sort index within its category. If this value is null in the database, best calculate this index from
* the assignments.
*
* @param assignmentId the id of the assignment
* @return the current sort index of the assignment within their category
*/
protected Integer calculateCurrentCategorizedSortOrder(final Long assignmentId) {
final Assignment assignment = MoveAssignmentAction.this.businessService.getAssignment(assignmentId.longValue());
Integer order = assignment.getCategorizedSortOrder();
if (order == null) {
// if no categorized order for assignment, calculate one based on the default sort order
final List<Assignment> assignments = MoveAssignmentAction.this.businessService.getGradebookAssignments();
final List<Long> assignmentIdsInCategory = assignments.stream()
.filter(a -> (a.getCategoryId() != null) && a.getCategoryId().equals(assignment.getCategoryId()))
.map(Assignment::getId)
.collect(Collectors.toList());
order = assignmentIdsInCategory.indexOf(assignmentId);
}
return order;
}
示例9: onInitialize
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
@Override
public void onInitialize() {
super.onInitialize();
final List<Assignment> assignments = this.businessService.getGradebookAssignments(SortType.SORT_BY_SORTING);
add(new ListView<Assignment>("gradeItemList", assignments) {
@Override
protected void populateItem(final ListItem<Assignment> assignmentItem) {
final Assignment assignment = assignmentItem.getModelObject();
assignmentItem.add(new Label("name", assignment.getName()));
assignmentItem.add(new HiddenField<Long>("id",
Model.of(assignment.getId())).add(
new AttributeModifier("name",
String.format("id", assignment.getId()))));
assignmentItem.add(new HiddenField<Integer>("order",
Model.of(assignment.getSortOrder())).add(
new AttributeModifier("name",
String.format("item_%s[order]", assignment.getId()))));
assignmentItem.add(new HiddenField<Integer>("current_order",
Model.of(assignment.getSortOrder())).add(
new AttributeModifier("name",
String.format("item_%s[current_order]", assignment.getId()))));
}
});
}
示例10: constructAverageLabel
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
private String constructAverageLabel(final List<Double> allGrades, final Assignment assignment) {
final double average = calculateAverage(allGrades);
final String averageFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(average));
if (GradingType.PERCENTAGE.equals(this.gradingType)) {
return (new StringResourceModel("label.percentage.valued",
null,
new Object[] { averageFormatted })).getString();
}
final Double total = assignment.getPoints();
final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (average / total.doubleValue()));
return (new StringResourceModel("label.statistics.averagevalue",
null,
new Object[] { averageFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage })).getString();
}
示例11: constructMedianLabel
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
private String constructMedianLabel(final List<Double> allGrades, final Assignment assignment) {
final double median = calculateMedian(allGrades);
final String medianFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(median));
if (GradingType.PERCENTAGE.equals(this.gradingType)) {
return (new StringResourceModel("label.percentage.valued",
null,
new Object[] { medianFormatted })).getString();
}
final Double total = assignment.getPoints();
final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (median / total.doubleValue()));
return (new StringResourceModel("label.statistics.medianvalue",
null,
new Object[] { medianFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage })).getString();
}
示例12: constructLowestLabel
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
private String constructLowestLabel(final List<Double> allGrades, final Assignment assignment) {
final double lowest = Collections.min(allGrades);
final String lowestFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(lowest));
if (GradingType.PERCENTAGE.equals(this.gradingType)) {
return (new StringResourceModel("label.percentage.valued",
null,
new Object[] { lowestFormatted })).getString();
}
final Double total = assignment.getPoints();
final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (lowest / total.doubleValue()));
return (new StringResourceModel("label.statistics.lowestvalue",
null,
new Object[] { lowestFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage })).getString();
}
示例13: constructHighestLabel
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
private String constructHighestLabel(final List<Double> allGrades, final Assignment assignment) {
final double highest = Collections.max(allGrades);
final String highestFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(highest));
if (GradingType.PERCENTAGE.equals(this.gradingType)) {
return (new StringResourceModel("label.percentage.valued",
null,
new Object[] { highestFormatted })).getString();
}
final Double total = assignment.getPoints();
final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (highest / total.doubleValue()));
return new StringResourceModel("label.statistics.highestvalue",
null,
new Object[] { highestFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage }).getString();
}
示例14: makeAssignmentsToCreateListView
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
/**
* Helper to create a listview for what needs to be shown for new assignments
* @param markupId wicket markup id
* @param itemList list of Assignments populated by the item creation steps
*/
private ListView<Assignment> makeAssignmentsToCreateListView(final String markupId, final List<Assignment> itemList) {
final ListView<Assignment> rval = new ListView<Assignment>(markupId, itemList) {
@Override
protected void populateItem(final ListItem<Assignment> item) {
final Assignment assignment = item.getModelObject();
String extraCredit = assignment.isExtraCredit() ? yes : no;
String dueDate = FormatHelper.formatDate(assignment.getDueDate(), "");
String releaseToStudents = assignment.isReleased() ? yes : no;
String includeInCourseGrades = assignment.isCounted() ? yes : no;
item.add(new Label("title", assignment.getName()));
item.add(new Label("points", assignment.getPoints()));
item.add(new Label("extraCredit", extraCredit));
item.add(new Label("dueDate", dueDate));
item.add(new Label("releaseToStudents", releaseToStudents));
item.add(new Label("includeInCourseGrades", includeInCourseGrades));
}
};
return rval;
}
示例15: getGradebookAssignmentsForStudent
import org.sakaiproject.service.gradebook.shared.Assignment; //导入依赖的package包/类
/**
* Special operation to get a list of assignments in the gradebook that the specified student has access to. This taked into account
* externally defined assessments that may have grouping permissions applied.
*
* This should only be called if you are wanting to view the assignments that a student would see (ie if you ARE a student, or if you
* are an instructor using the student review mode)
*
* @param studentUuid
* @return a list of assignments or empty list if none/no gradebook
*/
public List<Assignment> getGradebookAssignmentsForStudent(final String studentUuid) {
final Gradebook gradebook = getGradebook(getCurrentSiteId());
final List<Assignment> assignments = getGradebookAssignments();
// NOTE: cannot do a role check here as it assumes the current user but this could have been called by an instructor (unless we add
// a new method to handle this)
// in any case the role check would just be a confirmation that the user passed in was a student.
// for each assignment we need to check if it is grouped externally and if the user has access to the group
final Iterator<Assignment> iter = assignments.iterator();
while (iter.hasNext()) {
final Assignment a = iter.next();
if (a.isExternallyMaintained()) {
if (this.gradebookExternalAssessmentService.isExternalAssignmentGrouped(gradebook.getUid(), a.getExternalId()) &&
!this.gradebookExternalAssessmentService.isExternalAssignmentVisible(gradebook.getUid(), a.getExternalId(),
studentUuid)) {
iter.remove();
}
}
}
return assignments;
}