本文整理匯總了Java中org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException類的典型用法代碼示例。如果您正苦於以下問題:Java AssessmentNotFoundException類的具體用法?Java AssessmentNotFoundException怎麽用?Java AssessmentNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AssessmentNotFoundException類屬於org.sakaiproject.service.gradebook.shared包,在下文中一共展示了AssessmentNotFoundException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAssignmentScoreComment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
public CommentDefinition getAssignmentScoreComment(final String gradebookUid, final Long assignmentId, final String studentUid) throws GradebookNotFoundException, AssessmentNotFoundException {
if (gradebookUid == null || assignmentId == null || studentUid == null) {
throw new IllegalArgumentException("null parameter passed to getAssignmentScoreComment. Values are gradebookUid:" + gradebookUid + " assignmentId:" + assignmentId + " studentUid:"+ studentUid);
}
GradebookAssignment assignment = getAssignmentWithoutStats(gradebookUid, assignmentId);
if (assignment == null) {
throw new AssessmentNotFoundException("There is no assignmentId " + assignmentId + " for gradebookUid " + gradebookUid);
}
CommentDefinition commentDefinition = null;
Comment comment = getInternalComment(gradebookUid, assignmentId, studentUid);
if (comment != null) {
commentDefinition = new CommentDefinition();
commentDefinition.setAssignmentName(assignment.getName());
commentDefinition.setCommentText(comment.getCommentText());
commentDefinition.setDateRecorded(comment.getDateRecorded());
commentDefinition.setGraderUid(comment.getGraderId());
commentDefinition.setStudentUid(comment.getStudentId());
}
return commentDefinition;
}
示例2: getAssignment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public org.sakaiproject.service.gradebook.shared.Assignment getAssignment(final String gradebookUid, final Long assignmentId) throws AssessmentNotFoundException {
if (assignmentId == null || gradebookUid == null) {
throw new IllegalArgumentException("null parameter passed to getAssignment. Values are assignmentId:"
+ assignmentId + " gradebookUid:" + gradebookUid);
}
if (!isUserAbleToViewAssignments(gradebookUid) && !currentUserHasViewOwnGradesPerm(gradebookUid)) {
log.warn("AUTHORIZATION FAILURE: User {} in gradebook {} attempted to get assignment with id {}", getUserUid(), gradebookUid, assignmentId);
throw new GradebookSecurityException();
}
GradebookAssignment assignment = getAssignmentWithoutStatsByID(gradebookUid, assignmentId);
if (assignment == null) {
throw new AssessmentNotFoundException("No gradebook item exists with gradable object id = " + assignmentId);
}
return getAssignmentDefinition(assignment);
}
示例3: getAssignmentByNameOrId
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public org.sakaiproject.service.gradebook.shared.Assignment getAssignmentByNameOrId(final String gradebookUid,
final String assignmentName) throws AssessmentNotFoundException {
org.sakaiproject.service.gradebook.shared.Assignment assignment = null;
try {
assignment = getAssignment(gradebookUid, assignmentName);
}
catch (final AssessmentNotFoundException e) {
//Don't fail on this exception
log.debug("Assessment not found by name", e);
}
if (assignment == null) {
//Try to get the assignment by id
if (NumberUtils.isCreatable(assignmentName)) {
final Long assignmentId = NumberUtils.toLong(assignmentName, -1L);
return getAssignment(gradebookUid, assignmentId);
}
}
return assignment;
}
示例4: getAssignmentScoreString
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public String getAssignmentScoreString(final String gradebookUid, final String assignmentName, final String studentUid)
throws GradebookNotFoundException, AssessmentNotFoundException {
if (gradebookUid == null || assignmentName == null || studentUid == null) {
throw new IllegalArgumentException("null parameter passed to getAssignment. Values are gradebookUid:"
+ gradebookUid + " assignmentName:" + assignmentName + " studentUid:" + studentUid);
}
final GradebookAssignment assignment = (GradebookAssignment)getHibernateTemplate().execute(new HibernateCallback() {
@Override
public Object doInHibernate(final Session session) throws HibernateException {
return getAssignmentWithoutStats(gradebookUid, assignmentName);
}
});
if (assignment == null) {
throw new AssessmentNotFoundException("There is no assignment with name " + assignmentName + " in gradebook " + gradebookUid);
}
return getAssignmentScoreString(gradebookUid, assignment.getId(), studentUid);
}
示例5: getAssignmentScoreStringByNameOrId
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public String getAssignmentScoreStringByNameOrId(final String gradebookUid, final String assignmentName, final String studentUid)
throws GradebookNotFoundException, AssessmentNotFoundException {
// TODO Auto-generated method stub
String assignment = null;
try {
assignment = getAssignmentScoreString(gradebookUid, assignmentName, studentUid);
}
catch (final AssessmentNotFoundException e) {
//Don't fail on this exception
log.debug("Assessment not found by name", e);
}
if (assignment == null) {
//Try to get the assignment by id
if (NumberUtils.isCreatable(assignmentName)) {
final Long assignmentId = NumberUtils.toLong(assignmentName, -1L);
return getAssignmentScoreString(gradebookUid, assignmentId, studentUid);
}
}
return null;
}
示例6: setAssignmentScoreString
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public void setAssignmentScoreString(final String gradebookUid, final String assignmentName, final String studentUid, final String score, final String clientServiceDescription)
throws GradebookNotFoundException, AssessmentNotFoundException {
final GradebookAssignment assignment = (GradebookAssignment)getHibernateTemplate().execute(new HibernateCallback() {
@Override
public Object doInHibernate(final Session session) throws HibernateException {
return getAssignmentWithoutStats(gradebookUid, assignmentName);
}
});
if (assignment == null) {
throw new AssessmentNotFoundException("There is no assignment with name " + assignmentName + " in gradebook " + gradebookUid);
}
setAssignmentScoreString(gradebookUid, assignment.getId(), studentUid, score, clientServiceDescription);
}
示例7: setExternalAssessmentToGradebookAssignment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public void setExternalAssessmentToGradebookAssignment(final String gradebookUid, final String externalId) {
final GradebookAssignment assignment = getExternalAssignment(gradebookUid, externalId);
if (assignment == null) {
throw new AssessmentNotFoundException("There is no assessment id=" + externalId + " in gradebook uid=" + gradebookUid);
}
assignment.setExternalAppName(null);
assignment.setExternalId(null);
assignment.setExternalInstructorLink(null);
assignment.setExternalStudentLink(null);
assignment.setExternallyMaintained(false);
getHibernateTemplate().execute((HibernateCallback<?>) session -> {
session.update(assignment);
log.info("Externally-managed assignment {} moved to Gradebook management in gradebookUid={} by userUid={}", externalId, gradebookUid, getUserUid());
return null;
});
}
示例8: updateAssignmentGradeComment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
/**
* Update (or set) the comment for a student's assignment
*
* @param assignmentId id of assignment
* @param studentUuid uuid of student
* @param comment the comment
* @return true/false
*/
public boolean updateAssignmentGradeComment(final long assignmentId, final String studentUuid,
final String comment) {
final String siteId = getCurrentSiteId();
final Gradebook gradebook = getGradebook(siteId);
try {
// could do a check here to ensure we aren't overwriting someone
// else's comment that has been updated in the interim...
this.gradebookService.setAssignmentScoreComment(gradebook.getUid(), assignmentId, studentUuid, comment);
return true;
} catch (GradebookNotFoundException | AssessmentNotFoundException | IllegalArgumentException e) {
log.error("An error occurred saving the comment. {}: {}", e.getClass(), e.getMessage());
}
return false;
}
示例9: getAssignmentGradeComment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
/**
* Get the comment for a given student assignment grade
*
* @param assignmentId id of assignment
* @param studentUuid uuid of student
* @return the comment or null if none
*/
public String getAssignmentGradeComment(final long assignmentId, final String studentUuid){
String siteId = this.getCurrentSiteId();
Gradebook gradebook = getGradebook(siteId);
try {
CommentDefinition def = this.gradebookService.getAssignmentScoreComment(gradebook.getUid(), assignmentId, studentUuid);
if(def != null){
return def.getCommentText();
}
} catch (GradebookNotFoundException | AssessmentNotFoundException e) {
log.error("An error occurred retrieving the comment. " + e.getClass() + ": " + e.getMessage());
}
return null;
}
示例10: updateAssignmentGradeComment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
/**
* Update (or set) the comment for a student's assignment
*
* @param assignmentId id of assignment
* @param studentUuid uuid of student
* @param comment the comment
* @return true/false
*/
public boolean updateAssignmentGradeComment(final long assignmentId, final String studentUuid, final String comment) {
String siteId = this.getCurrentSiteId();
Gradebook gradebook = getGradebook(siteId);
try {
//could do a check here to ensure we aren't overwriting someone else's comment that has been updated in the interim...
this.gradebookService.setAssignmentScoreComment(gradebook.getUid(), assignmentId, studentUuid, comment);
return true;
} catch (GradebookNotFoundException | AssessmentNotFoundException | IllegalArgumentException e) {
log.error("An error occurred saving the comment. " + e.getClass() + ": " + e.getMessage());
}
return false;
}
示例11: setAssignmentScoreComment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
public void setAssignmentScoreComment(final String gradebookUid, final Long assignmentId, final String studentUid, final String commentText) throws GradebookNotFoundException, AssessmentNotFoundException {
getHibernateTemplate().execute((HibernateCallback<Void>) session -> {
Comment comment = getInternalComment(gradebookUid, assignmentId, studentUid);
if (comment == null) {
comment = new Comment(studentUid, commentText, getAssignmentWithoutStats(gradebookUid, assignmentId));
} else {
comment.setCommentText(commentText);
}
comment.setGraderId(authn.getUserUid());
comment.setDateRecorded(new Date());
session.saveOrUpdate(comment);
return null;
});
}
示例12: getLowestPossibleGradeForGbItem
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public String getLowestPossibleGradeForGbItem(final String gradebookUid, final Long gradebookItemId) {
if (gradebookUid == null || gradebookItemId == null) {
throw new IllegalArgumentException("Null gradebookUid and/or gradebookItemId " +
"passed to getLowestPossibleGradeForGbItem. gradebookUid:" +
gradebookUid + " gradebookItemId:" + gradebookItemId);
}
final GradebookAssignment gbItem = getAssignmentWithoutStatsByID(gradebookUid, gradebookItemId);
if (gbItem == null) {
throw new AssessmentNotFoundException("No gradebook item found with id " + gradebookItemId);
}
final Gradebook gradebook = gbItem.getGradebook();
// double check that user has some permission to access gb items in this site
if (!isUserAbleToViewAssignments(gradebookUid) && !currentUserHasViewOwnGradesPerm(gradebookUid)) {
throw new GradebookSecurityException();
}
String lowestPossibleGrade = null;
if (gbItem.getUngraded()) {
lowestPossibleGrade = null;
} else if (gradebook.getGrade_type() == GradebookService.GRADE_TYPE_PERCENTAGE ||
gradebook.getGrade_type() == GradebookService.GRADE_TYPE_POINTS) {
lowestPossibleGrade = "0";
} else if (gbItem.getGradebook().getGrade_type() == GradebookService.GRADE_TYPE_LETTER) {
final LetterGradePercentMapping mapping = getLetterGradePercentMapping(gradebook);
lowestPossibleGrade = mapping.getGrade(0d);
}
return lowestPossibleGrade;
}
示例13: removeExternalAssessment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
/**
* @see org.sakaiproject.service.gradebook.shared.GradebookService#removeExternalAssessment(java.lang.String, java.lang.String)
*/
@Override
public void removeExternalAssessment(final String gradebookUid,
final String externalId) throws GradebookNotFoundException, AssessmentNotFoundException {
// Get the external assignment
final GradebookAssignment asn = getExternalAssignment(gradebookUid, externalId);
if(asn == null) {
throw new AssessmentNotFoundException("There is no external assessment id=" + externalId + " in gradebook uid=" + gradebookUid);
}
// We need to go through Spring's HibernateTemplate to do
// any deletions at present. See the comments to deleteGradebook
// for the details.
HibernateTemplate hibTempl = getHibernateTemplate();
hibTempl.execute((HibernateCallback<?>) session -> {
int numDeleted = session.createQuery("delete GradingEvent where gradableObject=:go").setParameter("go", asn).executeUpdate();
log.debug("Deleted {} records from gb_grading_event_t", numDeleted);
numDeleted = session.createQuery("delete AssignmentGradeRecord where gradableObject=:go").setParameter("go", asn).executeUpdate();
log.info("Deleted {} externally defined scores", numDeleted);
numDeleted = session.createQuery("delete Comment where gradableObject=:go").setParameter("go", asn).executeUpdate();
log.info("Deleted {} externally defined comments", numDeleted);
return null;
});
// Delete the assessment.
hibTempl.flush();
hibTempl.clear();
hibTempl.delete(asn);
log.info("External assessment removed from gradebookUid={}, externalId={} by userUid={}", gradebookUid, externalId, getUserUid());
}
示例14: updateExternalAssessmentComment
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public void updateExternalAssessmentComment(final String gradebookUid, final String externalId, final String studentUid, final String comment)
throws GradebookNotFoundException, AssessmentNotFoundException {
final GradebookAssignment asn = getExternalAssignment(gradebookUid, externalId);
if(asn == null) {
throw new AssessmentNotFoundException("There is no assessment id=" + externalId + " in gradebook uid=" + gradebookUid);
}
log.debug("BEGIN: Update 1 score for gradebookUid={}, external assessment={} from {}", gradebookUid, externalId, asn.getExternalAppName());
HibernateCallback<?> hc = session -> {
// Try to reduce data contention by only updating when the
// score has actually changed or property has been set forcing a db update every time.
boolean alwaysUpdate = ServerConfigurationService.getBoolean(UPDATE_SAME_SCORE_PROP, false);
CommentDefinition gradeComment = getAssignmentScoreComment(gradebookUid, asn.getId(), studentUid);
String oldComment = gradeComment != null ? gradeComment.getCommentText() : null;
if ( alwaysUpdate || (comment != null && !comment.equals(oldComment)) ||
(comment == null && oldComment != null) ) {
if(comment != null)
setAssignmentScoreComment(gradebookUid, asn.getId(), studentUid, comment);
else
setAssignmentScoreComment(gradebookUid, asn.getId(), studentUid, null);
}
return null;
};
getHibernateTemplate().execute(hc);
log.debug("END: Update 1 score for gradebookUid={}, external assessment={} from {}", gradebookUid, externalId, asn.getExternalAppName());
log.debug("External assessment comment updated in gradebookUid={}, externalId={} by userUid={}, new score={}", gradebookUid, externalId, getUserUid(), comment);
}
示例15: getExternalAssessmentCategoryId
import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; //導入依賴的package包/類
@Override
public Long getExternalAssessmentCategoryId(String gradebookUId, String externalId) {
Long categoryId = null;
final GradebookAssignment assignment = getExternalAssignment(gradebookUId, externalId);
if (assignment == null) {
throw new AssessmentNotFoundException("There is no assessment id=" + externalId + " in gradebook uid=" + gradebookUId);
}
if (assignment.getCategory() != null) {
categoryId = assignment.getCategory().getId();
}
return categoryId;
}