List of usage examples for org.apache.commons.math.util MathUtils round
public static float round(float x, int scale)
From source file:org.sakaiproject.tool.assessment.integration.helper.integrated.GradebookServiceHelperImpl.java
/** * Update the grading of the assessment. * @param ag the assessment grading./*from w ww . j a va2s . c om*/ * @param g the Gradebook Service * @throws java.lang.Exception */ public void updateExternalAssessmentScore(AssessmentGradingData ag, GradebookExternalAssessmentService g) throws Exception { boolean testErrorHandling = false; //log.info("GradebookService instance=" + g); PublishedAssessmentService pubService = new PublishedAssessmentService(); GradingService gradingService = new GradingService(); PublishedAssessmentIfc pub = (PublishedAssessmentIfc) gradingService .getPublishedAssessmentByAssessmentGradingId(ag.getAssessmentGradingId().toString()); String gradebookUId = pubService.getPublishedAssessmentOwner(pub.getPublishedAssessmentId()); if (gradebookUId == null) { return; } //SAM-1562 We need to round the double score and covert to a double -DH double fScore = MathUtils.round(ag.getFinalScore(), 2); Double score = Double.valueOf(fScore).doubleValue(); log.info("rounded: " + ag.getFinalScore() + " to: " + score.toString()); g.updateExternalAssessmentScore(gradebookUId, ag.getPublishedAssessmentId().toString(), ag.getAgentId(), score.toString()); if (testErrorHandling) { throw new Exception("Encountered an error in update ExternalAssessmentScore."); } }
From source file:org.sakaiproject.tool.assessment.ui.bean.author.ItemBean.java
/** * value of question * @return score it is worth */ public double getItemScore() { return MathUtils.round(itemScore, 2); }
From source file:org.sakaiproject.tool.assessment.ui.bean.author.ItemBean.java
/** * value of question discount * @return discountit is worth */ public double getItemDiscount() { return MathUtils.round(itemDiscount, 2); }
From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.ContentsDeliveryBean.java
/** * If we display the current score, return it, otherwise an empty string. * Not currently used, provided if we need it later. * @return either, a) the current score, otherwise, b) "" (empty string) *//*w w w . j a v a2 s .c o m*/ public String getPointsDisplayString() { String pointsDisplayString = ""; if (showStudentScore) { pointsDisplayString = "" + MathUtils.round(currentScore, 2); } return pointsDisplayString; }
From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean.java
/** * String representation of the rounded points. * // w w w .jav a2 s . c om * @return String representation of the points. */ public double getPoints() { return MathUtils.round(points, 2); }
From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean.java
/** * String representation of the rounded discount. * * @return String representation of the discount. *//* ww w. j a v a 2 s . c o m*/ public double getDiscount() { return MathUtils.round(discount, 2); }
From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean.java
/** * String representation of the max points available for this question. * /*from w w w . j a v a2 s. c o m*/ * @return String representation of the max points. */ public double getRoundedMaxPoints() { return MathUtils.round(maxPoints, 2); }
From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean.java
/** * If we display the score, return it, followed by a slash. * //from ww w .j ava2 s.c o m * @return either, a) the score followed by a slash, or, b) "" (empty * string) */ public String getPointsDisplayString() { String pointsDisplayString = ""; if (showStudentQuestionScore) { pointsDisplayString = MathUtils.round(points, 2) + "/"; } return pointsDisplayString; }
From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean.java
public Double getUpdatedScore() { return MathUtils.round(itemData.getScore(), 2); }
From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.SectionContentsBean.java
public double getRoundedMaxPoints() { // only show 2 decimal places return MathUtils.round(maxPoints, 2); }