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'.