Skip to content

Commit

Permalink
SAM-2263: The student cannot retake a linear access assessment from t…
Browse files Browse the repository at this point in the history
…he begining

git-svn-id: https://source.sakaiproject.org/svn/sam/trunk@133598 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
karentsao committed Jan 23, 2014
1 parent e0cb48c commit 5110216
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public void fillComponents(UIContainer tofill, ViewParameters viewparams,
delivery.setTimeLimit("0");
delivery.setBeginAssessment(true);

delivery.setNumberRetake(-1);
delivery.setActualNumberRetake(-1);

// set path
delivery.setContextPath(httpServletRequest.getContextPath());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3150,8 +3150,12 @@ public String checkBeforeProceed(boolean isSubmitForGrade, boolean isFromTimer,
return "safeToProceed";
}

GradingService gradingService = new GradingService();
int numberRetake = gradingService.getNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString());
if (numberRetake == -1 || actualNumberRetake == -1) {
GradingService gradingService = new GradingService();
numberRetake = gradingService.getNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString());
actualNumberRetake = gradingService.getActualNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString());
}

log.debug("check 7");
// check 7: any submission attempt left?
if (!getHasSubmissionLeft(totalSubmitted, numberRetake)){
Expand Down Expand Up @@ -3450,12 +3454,14 @@ public void setAssessmentGradingId(Long assessmentGradingId)
public String updateTimeLimit(String timeLimit) {
boolean acceptLateSubmission = AssessmentAccessControlIfc.
ACCEPT_LATE_SUBMISSION.equals(publishedAssessment.getAssessmentAccessControl().getLateHandling());
GradingService gradingService = new GradingService();
numberRetake = gradingService.getNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString());
log.debug("numberRetake = " + numberRetake);
actualNumberRetake = gradingService.getActualNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString());
log.debug("actualNumberRetake =" + actualNumberRetake);

if (numberRetake == -1 || actualNumberRetake == -1) {
GradingService gradingService = new GradingService();
numberRetake = gradingService.getNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString());
log.debug("numberRetake = " + numberRetake);
actualNumberRetake = gradingService.getActualNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString());
log.debug("actualNumberRetake =" + actualNumberRetake);
}

if (!("previewAssessment").equals(actionString) && actualNumberRetake >= numberRetake && beginTime != null) {
if (dueDate != null && !acceptLateSubmission) {
int timeBeforeDue = Math.round((dueDate.getTime() - beginTime.getTime())/1000.0f);
Expand Down Expand Up @@ -3686,5 +3692,21 @@ public String getRecURL()
return recURL;
}


public void setNumberRetake(int numberRetake) {
this.numberRetake = numberRetake;
}

public int getNumberRetake() {
return numberRetake;
}

public void setActualNumberRetake(int actualNumberRetake) {
this.actualNumberRetake = actualNumberRetake;
}

public int getActualNumberRetake() {
return actualNumberRetake;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ else if (action == DeliveryBean.TAKE_ASSESSMENT_VIA_URL) {
// get the position of last question which has ben answered/viewed by the student
log.debug("before partIndex = " + delivery.getPartIndex());
log.debug("before questionIndex = " + delivery.getQuestionIndex());
setPosition(delivery);
setPosition(delivery, publishedAssessment, ae);
log.debug("after partIndex = " + delivery.getPartIndex());
log.debug("after questionIndex = " + delivery.getQuestionIndex());

Expand All @@ -256,8 +256,23 @@ else if (action == DeliveryBean.TAKE_ASSESSMENT_VIA_URL) {
delivery.setPageContents(getPageContents(publishedAssessment, delivery, itemGradingHash, publishedAnswerHash));
}

private void setPosition(DeliveryBean delivery) {
private void setPosition(DeliveryBean delivery, PublishedAssessmentFacade publishedAssessment, ActionEvent ae) {
GradingService gradingService = new GradingService();
if (ae != null && ae.getComponent().getId().startsWith("beginAssessment")) {
if (delivery.getNumberRetake() == -1 || delivery.getActualNumberRetake() == -1) {
delivery.setNumberRetake(gradingService.getNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString()));
log.debug("numberRetake = " + delivery.getNumberRetake());
delivery.setActualNumberRetake(gradingService.getActualNumberRetake(publishedAssessment.getPublishedAssessmentId(), AgentFacade.getAgentString()));
log.debug("actualNumberRetake =" + delivery.getActualNumberRetake());
}

if (delivery.getActualNumberRetake() == delivery.getNumberRetake() - 1) {
delivery.setPartIndex(0);
delivery.setQuestionIndex(0);
return;
}
}

AssessmentGradingData assessmentGradingData = delivery.getAssessmentGrading();
log.debug("assessmentGradingData.getAssessmentGradingId() = " + assessmentGradingData.getAssessmentGradingId());
if (assessmentGradingData.getLastVisitedPart() != null && assessmentGradingData.getLastVisitedQuestion() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ public void processAction(ActionEvent ae) throws
bean.setTimeElapseAfterFileUpload(null);
bean.setLastTimer(0);
bean.setTimeLimit("0");
bean.setNumberRetake(-1);
bean.setActualNumberRetake(-1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public void doPost(HttpServletRequest req, HttpServletResponse res)
delivery.setLastTimer(0);
delivery.setTimeLimit("0");
delivery.setBeginAssessment(true);

delivery.setNumberRetake(-1);
delivery.setActualNumberRetake(-1);

// set path
delivery.setContextPath(req.getContextPath());
Expand Down Expand Up @@ -170,7 +173,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse res)
}

log.debug("*** agentIdString: "+agentIdString);

String nextAction = delivery.checkFromViaUrlLogin();
log.debug("nextAction="+nextAction);
if (isAuthorized){
Expand Down

0 comments on commit 5110216

Please sign in to comment.