Hi, I am trying to create a widget that is able to pull the Total Positive Behaviour Points into a variable, the end result is we will use an if statement to display a specific image depending on a number of points the student has.
I have started by testing with the HTML widget. using the below code to see if I can use the behaviour.getBehaviourTotals API to get the total points this year for the user, however, it is not working.
<script>
var $ap,user;
//Create a div, and give it a unique ID
$ap = $("div", {
id: Frog.Utilities.generateSimpleID()
}
);
$ap.html(
'<b>Your House Points:</b>'+
'<table clase="table" id="your_points">'+
'<tr>'+
"<th>This Year</th>"+
'</tr>'+
'</table>'
);
// Use Frog's API to get the logged in student
user = FrogOS.getUser();
// Use Frog's API to get Behaviour points
Frog.Model
.api('behaviour.getBehaviourTotals',{
Student_uuid: user.uuid,
}).done(function(behaviourResponse){
behaviourResponse.data.pos.year(function(work){
$ap.find('tbody')
.append(
'<tr>'+
'<td>'+
data.pos.year+
'</td>'+
'</tr>'
);
});
});
arguments[0].append($ap);
</script>
any advice appreciated.
Phil