forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAM-1074 Adding Delete test submission attempt feature for samigo, we…
… used this feature at Texas State Univ from 2006 till now for sakai10.4
- Loading branch information
Showing
6 changed files
with
286 additions
and
11 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
...java/org/sakaiproject/tool/assessment/ui/listener/evaluation/GrantSubmissionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/********************************************************************************** | ||
* | ||
* | ||
*********************************************************************************** | ||
* | ||
* Copyright (c) 2004, 2005, 2006 The Sakai Foundation. | ||
* | ||
* Licensed under the Educational Community License, Version 1.0 (the"License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.opensource.org/licenses/ecl1.php | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
**********************************************************************************/ | ||
|
||
|
||
|
||
package org.sakaiproject.tool.assessment.ui.listener.evaluation; | ||
|
||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
|
||
import javax.faces.event.AbortProcessingException; | ||
import javax.faces.event.ActionEvent; | ||
import javax.faces.event.ActionListener; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.sakaiproject.tool.assessment.data.dao.grading.AssessmentGradingData; | ||
import org.sakaiproject.tool.assessment.services.GradingService; | ||
import org.sakaiproject.tool.assessment.services.shared.MediaService; | ||
import org.sakaiproject.tool.assessment.ui.bean.delivery.DeliveryBean; | ||
import org.sakaiproject.tool.assessment.ui.bean.evaluation.AgentResults; | ||
import org.sakaiproject.tool.assessment.ui.bean.evaluation.TotalScoresBean; | ||
import org.sakaiproject.tool.assessment.ui.listener.delivery.DeliveryActionListener; | ||
import org.sakaiproject.tool.assessment.ui.listener.evaluation.util.EvaluationListenerUtil; | ||
import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil; | ||
import org.sakaiproject.tool.assessment.util.BeanSort; | ||
import org.sakaiproject.tool.assessment.data.dao.grading.MediaData; | ||
|
||
|
||
/** | ||
* <p> | ||
* This handles the deletion of student submission on the Score page. | ||
* </p> | ||
* <p>Description: Action Listener for deletion of student's submission on the Score page</p> | ||
* <p>Organization: Sakai Project</p> | ||
* @author Texas State University | ||
*/ | ||
|
||
public class GrantSubmissionListener | ||
implements ActionListener | ||
{ | ||
private static Log log = LogFactory.getLog(StudentScoreListener.class); | ||
private static EvaluationListenerUtil util; | ||
private static BeanSort bs; | ||
|
||
/** | ||
* Increases submissions remaining by 1. | ||
* Gives students an additional attempt. | ||
* | ||
* @param ae ActionEvent | ||
* @throws AbortProcessingException | ||
*/ | ||
public void processAction(ActionEvent ae) throws | ||
AbortProcessingException | ||
{ | ||
log.debug("GrantSubmission LISTENER."); | ||
|
||
TotalScoresBean totalScores = (TotalScoresBean) ContextUtil.lookupBean("totalScores"); | ||
String deletedStudentId = null; | ||
// delivery.setSubmissionsRemaining(delivery.getSubmissionsRemaining() + 1); | ||
|
||
String gradingIdParam = ContextUtil.lookupParam("gradingData"); | ||
Long gradingId = new Long(gradingIdParam); | ||
String publishedAssessmentId = ContextUtil.lookupParam("publishedId"); | ||
|
||
GradingService gradingService = new GradingService(); | ||
MediaService mediaService = new MediaService(); | ||
|
||
List itemGradingIds = gradingService.getItemGradingIds(gradingId); | ||
|
||
for(int i = 0; i < itemGradingIds.size(); i++){ | ||
Long itemGradingId = (Long) itemGradingIds.get(i); | ||
//for each grading item, check if question is file upload type | ||
if(gradingService.getTypeId(itemGradingId).intValue() == 6){ | ||
//if is file upload type, check if there is file uploaded | ||
ArrayList mediaDatas = gradingService.getMediaArray(itemGradingId.toString()); | ||
for(int j = 0; j < mediaDatas.size(); j++) { | ||
//if there are file(s) uploaded, delete them | ||
String mediaId = ((MediaData)mediaDatas.get(j)).getMediaId().toString(); | ||
mediaService.remove(mediaId); | ||
} | ||
} | ||
} | ||
|
||
AssessmentGradingData ag = (AssessmentGradingData) gradingService.load(gradingIdParam); | ||
Collection collectionOfOne = new ArrayList(); | ||
collectionOfOne.add(ag); | ||
gradingService.deleteAll(collectionOfOne); | ||
|
||
Collection agentList = totalScores.getAgents(); | ||
for(Iterator i = agentList.iterator(); i.hasNext();) { | ||
AgentResults a = (AgentResults)i.next(); | ||
if (a.getAssessmentGradingId().equals(gradingId)) { | ||
deletedStudentId = a.getAgentId(); | ||
i.remove(); | ||
} | ||
} | ||
|
||
ArrayList gradingList = totalScores.getAssessmentGradingList(); | ||
//Get the list of submission for this student | ||
ArrayList deletedStudentGradingList = new ArrayList(); | ||
for(int i = 0; i < gradingList.size(); i++){ | ||
if (((AssessmentGradingData)gradingList.get(i)).getAgentId().equals(deletedStudentId)) { | ||
deletedStudentGradingList.add(gradingList.get(i)); | ||
} | ||
} | ||
//Need to do a check to see if this is the only submission for that student | ||
if(deletedStudentGradingList.size() == 1){ | ||
//if deleted the last one submission of this student, reset the grading data to have no grade and notify gradebook | ||
gradingList.clear(); | ||
gradingList.add(deletedStudentGradingList.get(0)); | ||
((AssessmentGradingData)gradingList.get(0)).setFinalScore(null); | ||
} | ||
else { | ||
for(int i = 0;i < gradingList.size();i++) { | ||
if (((AssessmentGradingData)gradingList.get(i)).getAssessmentGradingId().equals(gradingId)) { | ||
gradingList.remove(i); | ||
} | ||
} | ||
} | ||
|
||
totalScores.setAssessmentGradingList(gradingList); | ||
totalScores.setAgents(agentList); | ||
|
||
gradingService.notifyDeleteToGradebook(gradingList, totalScores.getPublishedAssessment(), deletedStudentId); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/********************************************************************************** | ||
* $URL$ | ||
* $Id$ | ||
* $URL: https://source.sakaiproject.org/svn/sam/tags/sakai-10.4/samigo-services/src/java/org/sakaiproject/tool/assessment/integration/helper/integrated/GradebookServiceHelperImpl.java $ | ||
* $Id: GradebookServiceHelperImpl.java 127473 2013-07-21 00:04:12Z [email protected] $ | ||
*********************************************************************************** | ||
* | ||
* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009 The Sakai Foundation | ||
|
@@ -259,22 +259,36 @@ public void updateExternalAssessmentScore(AssessmentGradingData ag, | |
//log.info("GradebookService instance=" + g); | ||
PublishedAssessmentService pubService = new PublishedAssessmentService(); | ||
GradingService gradingService = new GradingService(); | ||
PublishedAssessmentIfc pub = (PublishedAssessmentIfc) gradingService.getPublishedAssessmentByAssessmentGradingId(ag.getAssessmentGradingId().toString()); | ||
|
||
//Following line seems just for the need of getting publishedAssessmentId | ||
//use ag.getPublishedAssessmentId() instead of pub.getPublishedAssessmentId() to | ||
//get publishedAssessmentId | ||
//comment out following 3 lines since it returns null for not submitted students which we | ||
//need not save to assessmentgrading table but will need to notify gradebook only | ||
|
||
/* PublishedAssessmentIfc pub = (PublishedAssessmentIfc) gradingService.getPublishedAssessmentByAssessmentGradingId(ag.getAssessmentGradingId().toString()); | ||
String gradebookUId = pubService.getPublishedAssessmentOwner( | ||
pub.getPublishedAssessmentId()); | ||
pub.getPublishedAssessmentId());*/ | ||
String gradebookUId = pubService.getPublishedAssessmentOwner( | ||
ag.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() ); | ||
//Will pass to null value when last submission is deleted | ||
String points = null; | ||
if(ag.getFinalScore() != null) { | ||
//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(); | ||
points = score.toString(); | ||
log.info("rounded: " + ag.getFinalScore() + " to: " + score.toString() ); | ||
} | ||
g.updateExternalAssessmentScore(gradebookUId, | ||
ag.getPublishedAssessmentId().toString(), | ||
ag.getAgentId(), score.toString()); | ||
ag.getAgentId(), points); | ||
if (testErrorHandling){ | ||
throw new Exception("Encountered an error in update ExternalAssessmentScore."); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters