SIMS 7 - Behaviour Management API Calls
Negative behaviour is the alternative name given to Behaviour in SIMS (C/F positive behaviour for 'achievement').
The example below shows how behaviour can be modified within SIMS.
private static bool ModifyNegativeBehaviour()
{
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 = 7;
// load Chris Aaron in the the GA dataset
MaintainBehaviourDetails process = new MaintainBehaviourDetails();
process.LoadBehaviourDetails(new PersonID(12105));
NegativeBehaviour behaviourToUpdate = null;
// iterate through the behaviour collection to find the one for editing
foreach (NegativeBehaviour negativeBehaviour in process.StudentBehaviour.NegativeBehaviours)
{
// this years achievements
if (negativeBehaviour.EventDate > startDate)
{
// entities may be null so check'em
if (!negativeBehaviour.ActivityTypeAttribute.IsNull)
{
string negBehaviourActivityTypeAttributeValue = negativeBehaviour.ActivityTypeAttribute.Value.ToString();
}
string negBehaviourRecordedByAttributeLegalFullName = negativeBehaviour.RecordedByAttribute.LegalFullName.ToString();
string negBehaviourRecordedByAttributeID = negativeBehaviour.RecordedByAttribute.ID.ToString();
//string negativeBehaviourEventTimeAttibute = negativeBehaviour.EventTimeAttibute.Value.Description;
//string negativeBehaviourLocationSubjectAttribute = negativeBehaviour.LocationSubjectAttribute.Value.Description;
// the Acheivement Type and its associated points
string negativeBehaviourBehaviourTypeDescription = negativeBehaviour.BehaviourType.DescriptionAttribute.Value;
int negativeBehaviourBehaviourTypePoints = negativeBehaviour.BehaviourType.PointsAttribute.Value;
}
behaviourToUpdate = new NegativeBehaviour(negativeBehaviour);
break;
}
process.LoadBehaviour(behaviourToUpdate, true);
process.Behaviour.Comments = "Negative Behaviour Test Comments modified using test bed";
// add points to the existing Behaviour type points.
process.Behaviour.CurrentStudentLink.EventPoints = process.Behaviour.CurrentStudentLink.EventPoints + additionalPoints;
process.UpdateNegativeBehaviour(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'.