Jump to content

Hide columns in Attainment table based on Year group


Graham Quince

Recommended Posts

Some schools use different aspects in SIMS for target grades and predicted grades and it can end up with the Attainment Table widget having to have both columns visible with no information in for the wrong key stages.  I've just sorted this code which I thought I'd share:

<div class="attainCSS"></div>

<script>
var user = FrogOS ? FrogOS.getUser() : this.getUser(); 
    var year1011 = false,
        year789 = false;
    user.groups.each(function(index,group) {
        if (group.name == 'Year 10' || group.name == 'Year 11') {
            year1011 = true;
        }
        if (group.name == 'Year 7' || group.name == 'Year 8' || group.name == 'Year 9') {
            year789 = true;
        }
    })

    if (year1011 == true) {
        $('.attainCSS').html(
            '<style>'+
                '.attainmenttable th:nth-child(2),'+
                '.attainmenttable th:nth-child(3),'+
                '.attainmenttable td:nth-child(2),'+
                '.attainmenttable td:nth-child(3) {'+
                     'display: none !important;'+
                '}'+
            '</style>'
        );
    }
    if (year789 == true) {
        $('.attainCSS').html(
            '<style>'+
                '.attainmenttable th:nth-child(5),'+
                '.attainmenttable th:nth-child(6),'+
                '.attainmenttable td:nth-child(5),'+
                '.attainmenttable td:nth-child(6) {'+
                    'display: none !important;'+
                '}'+
            '</style>'
        );
    }

</script>

Truth be told, I could probably write this neater, but when placed in an HTML widget on the student dashboard will set a variable based on the year group name and then write CSS onto the page to hide any instances of the empty columns in the widget.  And because My Learning loads into MyFrog by loading in FrogLearn's dashboard first, the HTML should also hide the columns in the app.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...