Skip to content

Commit

Permalink
Merge pull request sakaiproject#118 from plukasew/SAM-2076
Browse files Browse the repository at this point in the history
SAM-2076 Samigo records latest score when highest score is selected in settings
  • Loading branch information
ottenhoff committed Jan 27, 2015
2 parents d36ee39 + edbb91f commit d7508e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,16 @@ public void prepareAgentResultList(TotalScoresBean bean, PublishedAssessmentData
PublishedAccessControl ac = (PublishedAccessControl) p.getAssessmentAccessControl();
if (ac.getUnlimitedSubmissions()!=null && !ac.getUnlimitedSubmissions().booleanValue()){
if (ac.getSubmissionsAllowed().intValue() == 1) {
bean.setAllSubmissions(TotalScoresBean.LAST_SUBMISSION);
((QuestionScoresBean) ContextUtil.lookupBean("questionScores")).setAllSubmissions(TotalScoresBean.LAST_SUBMISSION);
((HistogramScoresBean) ContextUtil.lookupBean("histogramScores")).setAllSubmissions(TotalScoresBean.LAST_SUBMISSION);
// although the assessment is currently set to allow one submission, multiple submissions may still exist. Set
// the bean to display either the latest or the highest score, as defined in the assessment settings.
Integer scoringType = p.getEvaluationModel().getScoringType();
String scoringTypeStr = scoringType != null ? scoringType.toString() : TotalScoresBean.LAST_SUBMISSION;
if (TotalScoresBean.LAST_SUBMISSION.equals(scoringTypeStr) || TotalScoresBean.HIGHEST_SUBMISSION.equals(scoringTypeStr))
{
bean.setAllSubmissions(scoringTypeStr);
((QuestionScoresBean) ContextUtil.lookupBean("questionScores")).setAllSubmissions(scoringTypeStr);
((HistogramScoresBean) ContextUtil.lookupBean("histogramScores")).setAllSubmissions(scoringTypeStr);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2272,20 +2272,16 @@ public Object doInHibernate(Session session)

List l = getHibernateTemplate().executeFind(eval_model);
HashMap scoringTypeMap = new HashMap();
HashMap subissionAllowedMap = new HashMap();
Iterator iter = l.iterator();
while (iter.hasNext()) {
Object o[] = (Object[]) iter.next();
scoringTypeMap.put(o[0], o[1]);
subissionAllowedMap.put(o[0], o[2]);
}

// The sorting for each column will be done in the action listener.
ArrayList assessmentList = new ArrayList();
Long currentid = new Long("0");
Integer scoringOption = EvaluationModelIfc.LAST_SCORE; // use Last as
Integer submissionAllowed = null;
boolean multiSubmissionAllowed = false;

// now go through the last_list, and get the first entry in the list for
// each publishedAssessment, if
Expand All @@ -2302,25 +2298,14 @@ public Object doInHibernate(Session session)
// I use Last as default because it is what set above
scoringOption = EvaluationModelIfc.LAST_SCORE;
}
if (subissionAllowedMap.get(a.getPublishedAssessmentId()) != null) {
submissionAllowed = (Integer) subissionAllowedMap.get(a.getPublishedAssessmentId());
}
else {
submissionAllowed = null;
}
if (submissionAllowed != null) {
if (submissionAllowed.intValue() == 1) {
scoringOption = EvaluationModelIfc.LAST_SCORE;
}
}

if (EvaluationModelIfc.LAST_SCORE.equals(scoringOption)) {
if (!a.getPublishedAssessmentId().equals(currentid) || allAssessments) {
AssessmentGradingData f = a;

if (!a.getPublishedAssessmentId().equals(currentid)) {
f.setIsRecorded(true);
a.setIsRecorded(true);
}
assessmentList.add(f);
assessmentList.add(a);
currentid = a.getPublishedAssessmentId();
}
}
Expand All @@ -2329,6 +2314,7 @@ public Object doInHibernate(Session session)
// now go through the highest_list ,and get the first entry in the list
// for each publishedAssessment.

currentid = 0L;
for (int i = 0; i < highest_list.size(); i++) {
AssessmentGradingData a = (AssessmentGradingData) highest_list
.get(i);
Expand All @@ -2341,38 +2327,21 @@ public Object doInHibernate(Session session)
// I use Last as default because it is what set above
scoringOption = EvaluationModelIfc.LAST_SCORE;
}
if (subissionAllowedMap.get(a.getPublishedAssessmentId()) != null) {
submissionAllowed = (Integer) subissionAllowedMap.get(a.getPublishedAssessmentId());
}
else {
submissionAllowed = null;
}
if (submissionAllowed != null) {
if (submissionAllowed.intValue() > 1) {
multiSubmissionAllowed = true;
}
else {
multiSubmissionAllowed = false;
}
}
else {
multiSubmissionAllowed = true;
}

if (multiSubmissionAllowed && (EvaluationModelIfc.HIGHEST_SCORE.equals(scoringOption))) {
if (EvaluationModelIfc.HIGHEST_SCORE.equals(scoringOption)) {
if (!a.getPublishedAssessmentId().equals(currentid) || allAssessments) {
AssessmentGradingData f = a;

if (!a.getPublishedAssessmentId().equals(currentid)) {
f.setIsRecorded(true);
a.setIsRecorded(true);
}
assessmentList.add(f);
assessmentList.add(a);
currentid = a.getPublishedAssessmentId();
}
}

if (EvaluationModelIfc.AVERAGE_SCORE.equals(scoringOption)) {
AssessmentGradingData f = a;
assessmentList.add(f);

assessmentList.add(a);
}

}
Expand Down

0 comments on commit d7508e1

Please sign in to comment.