Skip to content

Commit

Permalink
update the content of assignment conversion to the latest version of …
Browse files Browse the repository at this point in the history
…that in post-2-4 branch

git-svn-id: https://source.sakaiproject.org/svn/assignment/trunk@40117 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
zqian committed Jan 15, 2008
1 parent 306afa2 commit 6167e69
Show file tree
Hide file tree
Showing 16 changed files with 1,748 additions and 160 deletions.
5 changes: 5 additions & 0 deletions assignment/assignment-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@
<artifactId>commons-dbcp</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**********************************************************************************
* $URL: $
* $Id: $
***********************************************************************************
*
* Copyright (c) 2003, 2004, 2005, 2006, 2007 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.assignment.impl.conversion.api;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
* @author ieb
*/
public interface SchemaConversionHandler
{

/**
* Retrievs a single source object form a ResultSet, returns null if the
* source record does not require conversion the result set was produiced
* from selectRecord SQL
*
* @param id
* @param rs
* @return
* @throws SQLException
*/
Object getSource(String id, ResultSet rs) throws SQLException;

/**
* Converts the source object and populates the preapred statement, the
* prepared statement is from getUpdateRecord.
*
* @param id
* @param source
* @param updateRecord
* @throws SQLException
*/
boolean convertSource(String id, Object source, PreparedStatement updateRecord)
throws SQLException;

/**
* Validate that the source object before conversion is the same as the
* result object, after conversion, re-read from the database
*
* @param id
* the ID of the record
* @param source
* the source object created by the same implementation
* @param result
* the result object created by the same implementation
* @throws Exception
* if the result is not equivalent to the source, at which point the
* whole transaction will be rolled back
*/
void validate(String id, Object source, Object result) throws Exception;

/**
* Get the source object for the validation record
* @param id
* @param rs
* @return
* @throws SQLException
*/
Object getValidateSource(String id, ResultSet rs) throws SQLException;

/**
* Get the db driver
* @return
*/
String getDbDriver();

/**
* Set the db driver string
* @param dbDriver
* @return
*/
void setDbDriver(String dbDriver);

}
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,6 @@ public interface SerializableSubmissionAccess
*/
public void setReviewStatus(String reviewStatus);

/**
* @return the scaled_grade
*/
public String getScaled_grade();

/**
* @param scaled_grade the scaled_grade to set
*/
public void setScaled_grade(String scaled_grade);

/**
* @return the submitted
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class AssignmentSubmissionAccess implements SerializableSubmissionAccess,
.getLog(AssignmentSubmissionAccess.class);

private SAXParserFactory parserFactory;
private SAXSerializablePropertiesAccess saxSerializableProperties = new SAXSerializablePropertiesAccess();
protected SAXSerializablePropertiesAccess saxSerializableProperties = new SAXSerializablePropertiesAccess();

protected String id = null;

Expand Down Expand Up @@ -103,8 +103,6 @@ public class AssignmentSubmissionAccess implements SerializableSubmissionAccess,

protected String reviewStatus = null;

protected String scaled_grade = null;

protected String submitted = null;

protected List<String> submittedattachments = new ArrayList<String>();
Expand Down Expand Up @@ -142,7 +140,7 @@ public String toXml()

submission.setAttribute("id", this.id);
submission.setAttribute("context", this.context);
submission.setAttribute("scaled_grade", this.scaled_grade);
submission.setAttribute("scaled_grade", this.grade);
submission.setAttribute("assignment", this.assignment);
submission.setAttribute("datesubmitted", this.datesubmitted);
submission.setAttribute("datereturned", this.datereturned);
Expand Down Expand Up @@ -351,9 +349,46 @@ else if ("submission".equals(qName))
setDatereturned(StringUtil.trimToNull(attributes.getValue("datereturned")));
setDatesubmitted(StringUtil.trimToNull(attributes.getValue("datesubmitted")));
setFeedbackcomment(StringUtil.trimToNull(attributes.getValue("feedbackcomment")));
setFeedbackcomment_html(StringUtil.trimToNull(attributes.getValue("feedbackcomment-html")));
if (StringUtil.trimToNull(attributes.getValue("feedbackcomment-html")) != null)
{
setFeedbackcomment_html(StringUtil.trimToNull(attributes.getValue("feedbackcomment-html")));
}
else if (StringUtil.trimToNull(attributes.getValue("feedbackcomment-formatted")) != null)
{
setFeedbackcomment_html(StringUtil.trimToNull(attributes.getValue("feedbackcomment-formatted")));
}
setFeedbacktext(StringUtil.trimToNull(attributes.getValue("feedbacktext")));
setFeedbacktext_html(StringUtil.trimToNull(attributes.getValue("feedbacktext-html")));

if (StringUtil.trimToNull(attributes.getValue("feedbacktext-html")) != null)
{
setFeedbacktext_html(StringUtil.trimToNull(attributes.getValue("feedbacktext-html")));
}
else if (StringUtil.trimToNull(attributes.getValue("feedbacktext-formatted")) != null)
{
setFeedbacktext_html(StringUtil.trimToNull(attributes.getValue("feedbacktext-formatted")));
}


// get grade
String grade = StringUtil.trimToNull(attributes.getValue("scaled_grade"));
if (grade == null)
{
grade = StringUtil.trimToNull(attributes.getValue("grade"));
if (grade != null)
{
try
{
Integer.parseInt(grade);
// for the grades in points, multiple those by 10
grade = grade + "0";
}
catch (Exception e)
{
}
}
}
setGrade(grade);

setGraded(StringUtil.trimToNull(attributes.getValue("graded")));
setGradereleased(StringUtil.trimToNull(attributes.getValue("gradereleased")));
setLastmod(StringUtil.trimToNull(attributes.getValue("lastmod")));
Expand Down Expand Up @@ -398,7 +433,6 @@ else if ("submission".equals(qName))
setReviewReport(StringUtil.trimToNull(attributes.getValue("reviewReport")));
setReviewScore(StringUtil.trimToNull(attributes.getValue("reviewScore")));
setReviewStatus(StringUtil.trimToNull(attributes.getValue("reviewStatus")));
setScaled_grade(StringUtil.trimToNull(attributes.getValue("scaled_grade")));
setSubmitted(StringUtil.trimToNull(attributes.getValue("submitted")));

// submittedtext and submittedtext_html are base-64
Expand Down Expand Up @@ -743,25 +777,6 @@ public void setReviewStatus(String reviewStatus)
this.reviewStatus = reviewStatus;
}


/* (non-Javadoc)
* @see org.sakaiproject.assignment.impl.conversion.impl.SerializableSubmissionAccess#getScaled_grade()
*/
public String getScaled_grade()
{
return scaled_grade;
}


/* (non-Javadoc)
* @see org.sakaiproject.assignment.impl.conversion.impl.SerializableSubmissionAccess#setScaled_grade(java.lang.String)
*/
public void setScaled_grade(String scaled_grade)
{
this.scaled_grade = scaled_grade;
}


/* (non-Javadoc)
* @see org.sakaiproject.assignment.impl.conversion.impl.SerializableSubmissionAccess#getSubmitted()
*/
Expand Down Expand Up @@ -894,3 +909,4 @@ public SerializableEntity getSerializableProperties()
}

}

Loading

0 comments on commit 6167e69

Please sign in to comment.