SIMS 7 - Assessment Result Write
The actual code to save a set of marks is very simple. In essence there is an XML
public static void SaveResult(string Result)
{
XmlDocument x = new XmlDocument();
x.LoadXml(Result);
SIMS.Processes.ThirdParty.SIMSAssessmentMessage s = new SIMSAssessmentMessage(x, SIMSAssessmentMessage.LEARNERASSESSMENTRESULT);
// Request the import
s.Import(x);
// See what it says!
ErrorMessage = s.ErrorString;
}
Definition of the Aspect XML
public static string GetResultExample(Guid AspectGuid, Guid StudentExternalID, string Result)
{
string date = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
/*DateTime dt = System.DateTime.Today;
string date = dt.Year + "-" + dt.Month + "-" + dt.Day;*/
string resultBase =
#region Sample Result
@"<?xml version=" + doubleQuote + "1.0" + doubleQuote + " encoding=" + doubleQuote + "UTF-8" + doubleQuote + " standalone=" + doubleQuote + "yes" + doubleQuote + "?>" +
@"
<SIMSAssessmentMessage xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
<Header>
<MessageType>UPDATE</MessageType>
<MessageID>390820998F7A485D8310B390D5FE39C6</MessageID>
<SourceID>MYSUPPLIER</SourceID>
<DestinationID>A7BCF7D4E4224965A153A3EDA4243601</DestinationID>
<Status>OK</Status>
</Header>
<DataObjects>" +
"\n <LearnerAssessmentResult RefId=" + doubleQuote + "MYRESULTGUID" + doubleQuote + " AssessmentComponentRefId =" + doubleQuote + "MYASPECTGUID" + doubleQuote + " LearnerPersonalRefId=" + doubleQuote + "MYLEARNERGUID" + doubleQuote + ">"
+ "\n" +
@" <SchoolInfoRefId>A7BCF7D4E4224965A153A3EDA4243601</SchoolInfoRefId>
<AchievementDate>MYRESULTDATE</AchievementDate>
<Result>MY_RESULT</Result>
<ResultStatus>R</ResultStatus>
</LearnerAssessmentResult>
</DataObjects>
</SIMSAssessmentMessage>
";
#endregion
System.Guid resultGuid = System.Guid.NewGuid();
string resultXml = resultBase.Replace("MYRESULTGUID", CleanGUID(resultGuid));
resultXml = resultXml.Replace("MY_RESULT", Result);
// Must have a supplier match
resultXml = resultXml.Replace("MYSUPPLIER", mySupplier);
//Supply the Home School Ref ID
resultXml = resultXml.Replace("A7BCF7D4E4224965A153A3EDA4243601", SIMS.Processes.ThirdParty.SIMSAssessmentMessage.SchoolRefID);
if (AspectGuid != System.Guid.Empty)
resultXml = resultXml.Replace("MYASPECTGUID", CleanGUID(AspectGuid));
//Get the GUID of a Student and replace the MYLEARNERGUID with that value
resultXml = resultXml.Replace("MYLEARNERGUID", CleanGUID(StudentExternalID));
resultXml = resultXml.Replace("MYRESULTDATE", date);
//This is used for populating Results
return resultXml;
}