public void testModifyExternalGradeRecords() throws Exception { // Add an external assessment gradebookExternalAssessmentService.addExternalAssessment( GRADEBOOK_UID, EXT_ID_1, null, EXT_TITLE_1, new Double(10), new Date(), "Samigo", new Boolean(false)); // Add the external assessment score Gradebook gb = gradebookManager.getGradebook(GRADEBOOK_UID); gradebookExternalAssessmentService.updateExternalAssessmentScore( gb.getUid(), EXT_ID_1, "student1", new String("2")); // Ensure that the course grade record for student1 has been updated CourseGradeRecord cgr = gradebookManager.getStudentCourseGradeRecord(gb, "student1"); Assert.assertTrue( cgr.getPointsEarned() .equals(new Double(12))); // 10 points on internal, 2 points on external // Update the score with null points gradebookExternalAssessmentService.updateExternalAssessmentScore( gb.getUid(), EXT_ID_1, "student1", null); // Ensure that the course grade record for student1 has been updated cgr = gradebookManager.getStudentCourseGradeRecord(gb, "student1"); Assert.assertEquals( new Double(10), cgr.getPointsEarned()); // 10 points on internal, 0 points on external }
public GradebookRow(Gradebook gradebook) { this.name = gradebook.getName(); try { this.uid = URLEncoder.encode(gradebook.getUid(), "UTF-8"); } catch (UnsupportedEncodingException ex) { logger.error("Unlikely exception thrown", ex); } }
public boolean getIsLetterGrade() { if (isUserAbleToEditAssessments()) { Gradebook gb = getGradebookManager().getGradebookWithGradeMappings(getGradebookId()); if (gb != null && gb.getGrade_type() == GradebookService.GRADE_TYPE_LETTER) { return true; } return false; } return false; }
public void testUpdateMultipleScores() throws Exception { // Add an external assessment gradebookExternalAssessmentService.addExternalAssessment( GRADEBOOK_UID, EXT_ID_1, null, EXT_TITLE_1, new Double(10), new Date(), "Samigo", new Boolean(false)); // Add the external assessment score Gradebook gb = gradebookManager.getGradebook(GRADEBOOK_UID); gradebookExternalAssessmentService.updateExternalAssessmentScore( gb.getUid(), EXT_ID_1, "student1", new String("2")); // Ensure that the course grade record for student1 has been updated CourseGradeRecord cgr = gradebookManager.getStudentCourseGradeRecord(gb, "student1"); Assert.assertTrue( cgr.getPointsEarned() .equals(new Double(12))); // 10 points on internal, 2 points on external // Update multiple scores at once. Map studentUidsToScores = new HashMap(); studentUidsToScores.put("student1", null); studentUidsToScores.put("student2", new Double(4).toString()); studentUidsToScores.put("student3", new Double(5).toString()); gradebookExternalAssessmentService.updateExternalAssessmentScoresString( gb.getUid(), EXT_ID_1, studentUidsToScores); cgr = gradebookManager.getStudentCourseGradeRecord(gb, "student1"); Assert.assertTrue(cgr.getPointsEarned().equals(new Double(10))); cgr = gradebookManager.getStudentCourseGradeRecord(gb, "student2"); Assert.assertTrue(cgr.getPointsEarned().equals(new Double(4))); // Do a bogus update of a null collection of scores, a la Assignments. gradebookExternalAssessmentService.updateExternalAssessmentScoresString( gb.getUid(), EXT_ID_1, new HashMap()); cgr = gradebookManager.getStudentCourseGradeRecord(gb, "student2"); Assert.assertTrue(cgr.getPointsEarned().equals(new Double(4))); }
public String getGradeOptionSummary() { String gradeOptionSummary; Gradebook gradebook = getGradebook(); String gradeMappingName = gradebook.getSelectedGradeMapping().getName(); if (gradebook.isAssignmentsDisplayed()) { if (gradebook.isCourseGradeDisplayed()) { gradeOptionSummary = FacesUtil.getLocalizedString( "overview_grade_option_all_viewable", new String[] {gradeMappingName}); } else { gradeOptionSummary = FacesUtil.getLocalizedString("overview_grade_option_assignments_viewable"); } } else if (gradebook.isCourseGradeDisplayed()) { gradeOptionSummary = FacesUtil.getLocalizedString( "overview_grade_option_course_grade_viewable", new String[] {gradeMappingName}); } else { gradeOptionSummary = FacesUtil.getLocalizedString("overview_grade_option_none_viewable"); } return gradeOptionSummary; }
/** * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpInTransaction() */ protected void onSetUpInTransaction() throws Exception { super.onSetUpInTransaction(); gradebookFrameworkService.addGradebook(GRADEBOOK_UID, GRADEBOOK_UID); Gradebook gradebook = gradebookManager.getGradebook(GRADEBOOK_UID); // Set up a holder for enrollments, teaching assignments, and sections. integrationSupport.createCourse(GRADEBOOK_UID, GRADEBOOK_UID, false, false, false); List studentUidsList = Arrays.asList( new String[] { "student1", "student2", "student3", }); addUsersEnrollments(gradebook, studentUidsList); // Add an internal assignment Long gbId = gradebook.getId(); asn_1Id = gradebookManager.createAssignment( gbId, ASN_1, new Double(10), null, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE); // Add a score for the internal assignment List assignments = gradebookManager.getAssignments(gbId); Assignment asn = null; for (Iterator iter = assignments.iterator(); iter.hasNext(); ) { Assignment tmp = (Assignment) iter.next(); if (tmp.getName().equals(ASN_1)) { asn = tmp; break; } } List gradeRecords = new ArrayList(); gradeRecords.add(new AssignmentGradeRecord(asn, "student1", new Double(10))); gradebookManager.updateAssignmentGradeRecords(asn, gradeRecords); }
public AddGradeItemPanel(String id, final ModalWindow window) { super(id); Assignment assignment = new Assignment(); // Default released to true assignment.setReleased(true); // If no categories, then default counted to true Gradebook gradebook = businessService.getGradebook(); assignment.setCounted( GradebookService.CATEGORY_TYPE_NO_CATEGORY == gradebook.getCategory_type()); Model<Assignment> model = new Model<Assignment>(assignment); Form form = new Form("addGradeItemForm", model); AjaxButton submit = new AjaxButton("submit") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form form) { Assignment assignment = (Assignment) form.getModelObject(); Long assignmentId = null; boolean success = true; try { assignmentId = businessService.addAssignment(assignment); } catch (AssignmentHasIllegalPointsException e) { error(new ResourceModel("error.addgradeitem.points").getObject()); success = false; } catch (ConflictingAssignmentNameException e) { error(new ResourceModel("error.addgradeitem.title").getObject()); success = false; } catch (ConflictingExternalIdException e) { error(new ResourceModel("error.addgradeitem.exception").getObject()); success = false; } catch (Exception e) { error(new ResourceModel("error.addgradeitem.exception").getObject()); success = false; } if (success) { getSession() .info( MessageFormat.format( getString("notification.addgradeitem.success"), assignment.getName())); setResponsePage( getPage().getPageClass(), new PageParameters() .add(GradebookPage.CREATED_ASSIGNMENT_ID_PARAM, assignmentId)); } else { target.addChildren(form, FeedbackPanel.class); } } }; form.add(submit); form.add(new AddGradeItemPanelContent("subComponents", model)); FeedbackPanel feedback = new FeedbackPanel("addGradeFeedback") { private static final long serialVersionUID = 1L; @Override protected Component newMessageDisplayComponent( final String id, final FeedbackMessage message) { final Component newMessageDisplayComponent = super.newMessageDisplayComponent(id, message); if (message.getLevel() == FeedbackMessage.ERROR || message.getLevel() == FeedbackMessage.DEBUG || message.getLevel() == FeedbackMessage.FATAL || message.getLevel() == FeedbackMessage.WARNING) { add(AttributeModifier.replace("class", "messageError")); add(AttributeModifier.append("class", "feedback")); } else if (message.getLevel() == FeedbackMessage.INFO) { add(AttributeModifier.replace("class", "messageSuccess")); add(AttributeModifier.append("class", "feedback")); } return newMessageDisplayComponent; } }; feedback.setOutputMarkupId(true); form.add(feedback); AjaxButton cancel = new AjaxButton("cancel") { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { window.close(target); } }; form.add(cancel); add(form); }