Thursday, September 3, 2015

Showing student custom field data in classattendance page in PowerSchool Teachers

I was trying to display some custom field data (I will take ssis_student_nickname as an example in this article) in the classattendance.html page in PowerSchool Teachers. But, to be honest, I'm not sure about the customization syntax of PowerSchool. I couldn't make it work with this following syntax:

~([01]ssis_student_nickname)

or

~([Students.U_STUDENTSUSERFIELDS]ssis_student_nickname)

As fas as I acknowledged, the classattendance page accessing the attendance database using some javascript. So, in the end, I have to do some hack to display the custom field in that page. Here is the details:

1. Add an additional column in the page, and name it:
...
             <th align="left" class="cvDemarcation">~[text]psx.html.teachers.classattendance.students[/text]</th>
            <th class="cvDemarcation">Student Nick Name</th>
...
            <tr class="studentrow">
                <td class="cvDemarcation ssis-name">~[ATT_RecordMeetingTeacherStudentList][studentname]</td>
                <td class="cvDemarcation ssis-nickname"></td>
                <td class="cvDemarcation">[alert]</td>
                <td>&nbsp;[att_recordweekfield]</td>
            <td></td>
            </tr>
...

We will put data into ssis-nickname td tag.

2. Use tlist_sql to load the custom field data of all the students and put it into a hidden table:

<table id="ssis-ncklist" style="display:none;">
    ~[tlist_sql; SELECT s.lastfirst as lf, u.ssis_student_nickname as nckname
FROM students s INNER JOIN u_studentsuserfields u
ON s.dcid = u.STUDENTSDCID
WHERE s.enroll_status = 0; ]
<tr>
<td class="ssis-lf">~(lf)</td>
<td class="ssis-nck">~(nckname)</td>
</tr>
    [/tlist_sql]
</table>

I use this as a psudo database table and query the nickname from that (use lastfirst as keys) using jQuery.

3. Add this javascript snippet at the end of the file to manipulate the custom field data and put them into the attendance table (in step 1):

<script>
function get_nickname(ssislastfirst) {
var nickname = '';
jQuery('.ssis-lf').each(function(){
if(jQuery(this).html() == ssislastfirst) {
nickname = jQuery(this).next().html();
}
});
return nickname;
}
jQuery('.ssis-name').each(function(){
var lastfirst = jQuery(this).html();
var nickname = get_nickname(lastfirst);
jQuery(this).next().html(nickname);
});
</script>

You can find the full page here:



Awesome huh?