© 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 - Achievement Management API Calls

Positive behaviour is the alternative name given to achievements in SIMS (C/F negative behaviour for 'conduct').

The example below shows how behaviour can be modified within SIMS.

using SIMS.Processes;
using SIMS.Entities;

private static bool ModifyPositiveBehaviour()
        {

            SIMS.Processes.StudentCache.Populate();

            // get current acad year dates
            DateTime startDate = SIMS.Entities.StudentCache.CurrentAcademicYear.StartDate;
            DateTime endDate = SIMS.Entities.StudentCache.CurrentAcademicYear.EndDate;
            bool success = true;
            // add your points here
            int additionalPoints = 0;

            // load Chris Aaron in the the GA dataset
            SIMS.Processes.MaintainBehaviourDetails process = new MaintainBehaviourDetails();
            process.LoadBehaviourDetails(new PersonID(12105));  

            SIMS.Entities.PositiveBehaviour behaviourToUpdate = null;
            
            // iterate through the achievement collection to find the one for editing
            foreach (SIMS.Entities.PositiveBehaviour positiveBehaviour in process.StudentBehaviour.PositiveBehaviours)
            {
                // this years achievements
                if (positiveBehaviour.EventDate > startDate)
                {
                    // entities may be null so check'em
                    if (!positiveBehaviour.ActivityTypeAttribute.IsNull)
                    {
                        string posBehaviourActivityTypeAttributeValue = positiveBehaviour.ActivityTypeAttribute.Value.ToString();
                    }

                    string posBehaviourRecordedByAttributeLegalFullName = positiveBehaviour.RecordedByAttribute.LegalFullName.ToString();
                    string posBehaviourRecordedByAttributeID = positiveBehaviour.RecordedByAttribute.ID.ToString();

                    // the Acheivement Type and its associated points
                    string positiveBehaviourBehaviourTypeDescription = positiveBehaviour.BehaviourType.DescriptionAttribute.Value;
                    int positiveBehaviourBehaviourTypePoints = positiveBehaviour.BehaviourType.PointsAttribute.Value;
                }      
                
                behaviourToUpdate = new PositiveBehaviour(positiveBehaviour);
                break;
            }
            
            process.LoadBehaviour(behaviourToUpdate, true);
            process.Behaviour.Comments = "Postive Behaviour Test Comments modified using test bed";
            // add points to the existing Achievement type points. 
            process.Behaviour.CurrentStudentLink.EventPoints = process.Behaviour.CurrentStudentLink.EventPoints + additionalPoints;
            
            process.UpdatePositiveBehaviour(behaviourToUpdate);

            if (process.Behaviour.Valid())
            {
                try
                {
                    process.SaveBehaviouralDetails();
                }
                catch (System.Exception exception)
                {
                    success = false;
                    //ManageLogging.LogMessage("Could not save positive/negative behaviour in BehaviourTestCase.ModifyBehaviour()", exception.Message);
                    MessageBox.Show("Could not save positive/negative behaviour in BehaviourTestCase.ModifyBehaviour()");
                    MessageBox.Show(exception.Message);
                }
            }
            else
            {
                success = false;
                //ManageLogging.LogMessage("Could not modify positive/negative behaviour in BehaviourTestCase.ModifyBehaviour() due to validation errors", "");
                //CommonSIMS.WriteErrorsToLog(process.Behaviour.ValidationErrors);
            }

            return success;
        }

 

Please check that the entity is valid before trying to save it.

Please also consider processing error messages in 'process.Behaviour.ValidationErrors'.