Jump to content
Graham Quince

Hide columns in Attainment table based on Year group

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...