SIMS 7 - Sample Code - Prior Attainment in Census
Overview of Example
Example Call
List<PriorAtt> prat = SIMSInterface.Priorattainment.GetPriorAttainment();
json = Newtonsoft.Json.JsonConvert.SerializeObject(prat, Formatting.Indented);
System.IO.File.WriteAllText(Path.Combine(OutputFolder, "prat.json"), json);
Output Class
public class PriorAtt
{
public string censusPriorAttainmentPersonId { get; set; }
public string mathsHighestGradeCode { get; set; }
public string mathsHighestGradeDescription { get; set; }
public string mathsPriorAttainmentCode { get; set; }
public string mathsPriorAttainmentDescription { get; set; }
public string mathsFundingExemptionCode { get; set; }
public string mathsFundingExemptionDescription { get; set; }
// Englishpublic
public string englishHighestGradeCode { get; set; }
public string englishHighestGradeDescription { get; set; }
//string englishHighestGradeLangCode = censusPriorAttainment.EnglishHighestGradeLang.Code;
//string englishHighestGradeLangDescription = censusPriorAttainment.EnglishHighestGradeLang.Description;
public string englishPriorAttainmentCode { get; set; }
public string englishPriorAttainmentDescription { get; set; }
public string englishFundingExemptionCode { get; set; }
public string englishFundingExemptionDescription { get; set; }
}
Code Sample
public static List<PriorAtt> GetPriorAttainment()
{
// census prior attainment
// reference SchoolCensusProcesses & Entities and Lookups
List<PriorAtt> priorAttList = new List<PriorAtt>();
SIMS.Processes.LookupCache.Populate();
SIMS.Processes.CensusImportPriorAttainment censusImportPriorAttainment = new CensusImportPriorAttainment();
censusImportPriorAttainment.PopulatePriorAttainments("2022");
foreach (CensusPriorAttainment censusPriorAttainment in censusImportPriorAttainment.PriorAttainmentList.Value)
{
PriorAtt PA = new PriorAtt();
PA.censusPriorAttainmentPersonId = censusPriorAttainment.PersonId.ToString();
// Maths
PA.mathsHighestGradeCode = censusPriorAttainment.MathsHighestGrade.Code;
PA.mathsHighestGradeDescription = censusPriorAttainment.MathsHighestGrade.Description;
PA.mathsPriorAttainmentCode = censusPriorAttainment.MathsPriorAttainmentCode.Code;
PA.mathsPriorAttainmentDescription = censusPriorAttainment.MathsPriorAttainmentCode.Description;
PA.mathsFundingExemptionCode = censusPriorAttainment.MathsFundingExemption.Code;
PA.mathsFundingExemptionDescription = censusPriorAttainment.MathsFundingExemption.Description;
// English
PA.englishHighestGradeCode = censusPriorAttainment.EnglishHighestGrade.Code;
PA.englishHighestGradeDescription = censusPriorAttainment.EnglishHighestGrade.Description;
//PA.englishHighestGradeLangCode = censusPriorAttainment.EnglishHighestGradeLang.Code;
//PA.englishHighestGradeLangDescription = censusPriorAttainment.EnglishHighestGradeLang.Description;
PA.englishPriorAttainmentCode = censusPriorAttainment.EnglishPriorAttainmentCode.Code;
PA.englishPriorAttainmentDescription = censusPriorAttainment.EnglishPriorAttainmentCode.Description;
PA.englishFundingExemptionCode = censusPriorAttainment.EnglishFundingExemption.Code;
PA.englishFundingExemptionDescription = censusPriorAttainment.EnglishFundingExemption.Description;
priorAttList.Add(PA);
}
return priorAttList;
}
Example Output
[
{
"censusPriorAttainmentPersonId": "12108",
"mathsHighestGradeCode": "5",
"mathsHighestGradeDescription": "5 - Grade 5",
"mathsPriorAttainmentCode": "1",
"mathsPriorAttainmentDescription": "Achieved by end year 11",
"mathsFundingExemptionCode": "N",
"mathsFundingExemptionDescription": "No exemption",
"englishHighestGradeCode": "8",
"englishHighestGradeDescription": "8 - Grade 8",
"englishPriorAttainmentCode": "1",
"englishPriorAttainmentDescription": "Achieved by end year 11",
"englishFundingExemptionCode": "N",
"englishFundingExemptionDescription": "No exemption"
},