SIMS 7 - Sample Code - Course Manager Introduction
Overview of Example
Example Call
List<CourseDetails> csd = SIMSInterface.CourseManagerFull.GetCourseDetailsList();
json = Newtonsoft.Json.JsonConvert.SerializeObject(csd, Formatting.Indented);
System.IO.File.WriteAllText(Path.Combine(OutputFolder, "coursedetails.json"), json);
Output Class
public class ClassLink
{
public string Class { get; set; }
public string Teacher { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
}
public class ClassStudent
{
public string Name { get; set; }
public int PersonID { get; set; }
public string Surname { get; set; }
public string Forename { get; set; }
public string Class { get; set; }
}
public class CourseDetails
{
public string Description { get; set; }
public string ShortName { get; set; }
public string NormalDuration { get; set; }
public string ContinuityTollerance { get; set; }
public string CompletenessTollerance { get; set; }
public string QN { get; set; }
public string Subject { get; set; }
public string Level { get; set; }
public List<ClassLink> Classes = new List<ClassLink>();
public List<ClassStudent> Students = new List<ClassStudent>();
}
Code Sample
public static List<CourseDetails> GetCourseDetailsList()
{
SIMS.Processes.CurrCache.Populate();
DateTime start = new DateTime(2022, 8, 1);
DateTime end = new DateTime(2024, 7, 31);
List<CourseDetails> courseDetailsList = new List<CourseDetails>();
SIMS.Processes.MaintainCourseBrowse mcb = new SIMS.Processes.MaintainCourseBrowse();
mcb.PopulateCoursesforSIMSforNewCM("", "", "<Any>", "", "", "ENG", "", "none", start, end);
foreach (SIMS.Entities.MaintainCourseBrowse c in mcb.MaintainCourseBrowses.Value)
{
CourseDetails courseDetails = new CourseDetails();
courseDetails.ShortName = c.ShortName;
courseDetails.Description = c.Description;
courseDetails.Subject = c.Subject;
courseDetails.QN = c.La_OR_Qan;
SIMS.Processes.CourseManagerMaintainCourseDetail cmd = new SIMS.Processes.CourseManagerMaintainCourseDetail();
cmd.PopulateforSIMS(c.CourseIdAttribute.Value, start, end);
courseDetails.CompletenessTollerance = cmd.CourseManagerCourse.CompletionTolerance.ToString();
courseDetails.ContinuityTollerance = cmd.CourseManagerCourse.ContinuityTolerance.ToString();
courseDetails.NormalDuration = cmd.CourseManagerCourse.NormalCourseDuration.ToString();
courseDetails.QN = c.La_OR_Qan;
foreach (SIMS.Entities.CourseManager_CourseMember m in cmd.CourseManagerCourse.CourseMembers.Value)
{
ClassStudent cs = new ClassStudent();
cs.Surname = m.Surname;
cs.Forename = m.Forename;
cs.PersonID = m.PersonID;
cs.Class = m.ClassGroup;
courseDetails.Students.Add(cs);
}
courseDetailsList.Add(courseDetails);
}
return courseDetailsList;
}
Example Output
[
{
"Classes": [],
"Students": [
{
"Name": null,
"PersonID": 12773,
"Surname": "Altenburg",
"Forename": "Fieda",
"Class": "11z/Ag1 *"
},
{
"Name": null,
"PersonID": 12773,
"Surname": "Altenburg",
"Forename": "Fieda",
"Class": "11z/Ag1 *"
},
{
"Name": null,
"PersonID": 11355,
"Surname": "Yanosh",
"Forename": "Irdu",
"Class": "13D/Ar1 *"
}
],
"Description": "Art (GCE2Y)",
"ShortName": "Ar/GCE2Y",
"NormalDuration": null,
"ContinuityTollerance": null,
"CompletenessTollerance": null,
"QN": "60144567/3510",
"Subject": "Art",
"Level": null
}
]