© 2018 Capita Business Services Ltd. All rights reserved.

Capita Education Software Solutions is a trading name of Capita Business Services Ltd. Our Registered office is 30 Berners Street, London, W1T 3LR and our registered number is 02299747. Further information about Capita plc can be found in our legal statement.

SIMS 7 - Session Attendance changes Summer 24 code sample

The purpose of this article is to show the improved 3rd party API attendance model which supports the planned 1/8/24 changes to attendance from the DfE.

Session Code class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace SIMSAttendanceDemo.DataClasses
{

    [XmlRoot(ElementName = "SessionAttendanceExtended")]
    public class SessionAttendanceExtended
    {

        [XmlElement(ElementName = "PersonID")]
        public int PersonID { get; set; }

        [XmlElement(ElementName = "BaseGroupID")]
        public int? BaseGroupID { get; set; }

        [XmlElement(ElementName = "AttendanceDate")]
        public DateTime? AttendanceDate { get; set; }

        [XmlElement(ElementName = "SessionName")]
        public string SessionName { get; set; }

        [XmlElement(ElementName = "AttendanceMark")]
        public string AttendanceMark { get; set; }

        [XmlElement(ElementName = "Minute")]
        public int? Minute { get; set; }

        [XmlElement(ElementName = "Comments")]
        public string Comments { get; set; }
        [XmlIgnore]
        [XmlElement(ElementName = "AttendanceMarkSubCode")]
        public object AttendanceMarkSubCode { get; set; }

        [XmlElement(ElementName = "StatutoryComment")]
        public string StatutoryComment { get; set; }
    }

    [XmlRoot(ElementName = "SessionAttendancesExtended")]
    public class SessionAttendancesExtended
    {

        [XmlElement(ElementName = "SessionAttendanceExtended")]
        public List<SessionAttendanceExtended> SessionAttendanceExtended { get; set; }

}
}

The read marks and save marks would expect the same structure.

Get a set of attendance marks

private static List<DataClasses.SessionAttendanceExtended> SessionAttendanceReadTestPerson()
{
  List<DataClasses.SessionAttendanceExtended> list = new List<DataClasses.SessionAttendanceExtended>();
  string SessionMarks = TPAR.GetXmlSessionAttendancesExtendedV3(StudentId, 0, (DateTime)StartDate, (DateTime)EndDate);
  XmlSerializer serializer = new XmlSerializer(typeof(DataClasses.SessionAttendancesExtended));
  using (StringReader reader = new StringReader(SessionMarks))
  {
    var test = (DataClasses.SessionAttendancesExtended)serializer.Deserialize(reader);
    list = test.SessionAttendanceExtended;
  }
  return list;
}

Then update them, firstly to a B code without a statutory explanation which fails to save, followed by the setting of a statutory explanation and successful save.

            if (TPAR == null)
            {
                TPAR = new SIMS.Processes.TPAttendanceRead();
                TPAW = new SIMS.Processes.TPAttendanceWrite();
            }
            SetIds();
        
            SetCodes();

            List<DataClasses.SessionAttendanceExtended>  personList = SessionAttendanceReadTestPerson();
            #region Basic session Test
            // We have the set of session marks for a person for a period of time.
            // Change all the marks to the B code.
            // My database is hacked to bring forward the changes of 1/8/24.
            foreach (DataClasses.SessionAttendanceExtended m in personList)
            {
                m.AttendanceMark = "B";
            }  
            if (!SessionMarkSaveTest(personList))  // SHould fail because of no stat exp.
            {
                DumpErrors();
                foreach (DataClasses.SessionAttendanceExtended m in personList)
                {
                    m.StatutoryComment = "Testing";  // Add the required statutory exp.
                }
                if (SessionMarkSaveTest(personList))
                {
                    Console.WriteLine("Correct Save");
                }
                else
                {
                    Console.WriteLine("Failed to Save");
                    DumpErrors();
                }

            }
            else
            {
                Console.WriteLine("Incorrect Save");
            }