Jump to content
Graham Quince

Markbook-like view for a student or parent

Recommended Posts

Just been experimenting with this for a school and thought others might like the idea:

assignment summary.PNG

 

<style>
    .assignmentReportsTables td,
    .assignmentReportsTables th {
        text-align: center;
        vertical-align: middle;
        line-height: 25px;
        height: 54px;
        
    }
    .assignmentReportsTables {
        font-size: 16px;
        line-height: 25px;
    }
    .hw {
        min-width: 50px;
        height: 50px;
        line-height: 25px;
        vertical-align: middle;
        overflow: hidden;
        border: 1px solid #CCCCCC;
        text-align: center;
        background: #ffffff;
        float: left;
        margin-right: 2px;
        margin-bottom: 2px;
    }
    .hw:hover {
        background: #CCCCCC;
    }
    .hw .status {
        position: relative;
        background-size: cover;
        height: 24px;
        width: 24px;
        margin-left: auto;
        margin-right: auto;
        font-weight: bold;
    }
    .hw .bottom-right {
        position: absolute;
        right: -14px;
        bottom: -1px;
        width: 15px;
        height: 15px;
        line-height: 15px;
        font-size: 13px;
        background-color: #000;
        color: #ffffff;
    }
    .hw .late {
        background: #FF0000;
    }
    .hw .absent {
        background: #000000;
    }
    .hws {
        width: 50%;
    }
    .childHeading {
        font-size: 25px;
        font-weight: bold;
        line-height: 35px;
    }
</style>

<div class="AssignmentSummary"></div>

<script>
var startOfYear = moment('1/9/2021 1:00', "D/M/YYYY H:mm").unix();    
    
    
var AssignmentSummary = arguments[0].find('.AssignmentSummary');
var user = FrogOS ? FrogOS.getUser() : self.getUser();

function getAssignments(view,child_uuid) {
    var self = this;
    var assignmentsObject = {};

    var myMarksSpace = AssignmentSummary;
    var data = {
        end_from: startOfYear,
        end_to: parseInt(moment()/1000),
        status: 'closed', 
        order: 'start desc',
    }
    if (view !== 'student') {
        data = {
            end_from: startOfYear,
            end_to: parseInt(moment()/1000),
            status: 'closed', 
            order: 'start desc',
            assigned_user: child_uuid
        }
        myMarksSpace = AssignmentSummary.find('.child_'+child_uuid);
    }
    myMarksSpace.append(
        '<table class="assignmentReportsTables table-hover table-bordered table sum_'+child_uuid+'">'+
            '<tr>'+
                '<th>Subject</th>'+
                '<th>No. of assignments</th>'+
                '<th>Average Mark</th>'+
                '<th>Late Hand In</th>'+
                '<th>Not done</th>'+
                '<th>Homeworks</th>'+
            '</tr>'+
        '</table>'
    );
    var myMarks = myMarksSpace.find('.sum_'+child_uuid);
    
    FrogOS.fdp({
        url: 'assignment/getAssigned',
        data
    }).done(function(response) {
        var homeworks = response.response.assignments;
        var SubjectsArray = [];

        $.each(homeworks, function(index,homework) {
            /*if (homework.assignment.subject.name == "Chemistry") {
                console.log(homework);
            }*/
            var subject = homework.assignment.subject.name;
            var subjectClass = subject.replace(/\s/g, "").replace("&", "");
            
            if (SubjectsArray.indexOf(subject) < 0) { // Add all unique subjects as a row
                SubjectsArray.push(subject);
                myMarks.append(
                    '<tr>'+
                        '<td>'+subject+'</td>'+
                        '<td class="'+subjectClass+'_total" >0</td>'+
                        '<td class="'+subjectClass+'_average" >0</td>'+
                        '<td class="'+subjectClass+'_late">0</td>'+
                        '<td class="'+subjectClass+'_notdone">0</td>'+
                        '<td class="'+subjectClass+'_hws hws"></td>'+
                    '</tr>'
                )
                assignmentsObject[subject] = {
                     total:0,
                     massMarks: 0,
                     totalMarked: 0,
                     late: 0,
                     notdone: 0
                }
            }; // end of all unique subjects 
        
            var lateAbsent = '';
            var completed = homework.user_info.completed;
            var duedate = homework.assignment.end;

            if (completed > duedate) {
                lateAbsent = '<div class="bottom-right late">L</div>';
                assignmentsObject[subject].late += 1;
            }
            if (homework.user_info.status == "absent") {
                lateAbsent = '<div class="bottom-right absent">A</div>';
            }
            if (homework.user_info.status == "notdone") {
                assignmentsObject[subject].notdone += 1;
            }

            assignmentsObject[subject].total += 1;
            var markscheme = '';
            if (homework.user_info.mark !== null) { // IF the homework has been marked
                if (homework.assignment.mark_scheme.name !== 'markscheme.percentage.name' ) { 
                    var grades = homework.assignment.mark_scheme.data_values.grades;
                    assignmentsObject[subject].massMarks += parseInt(grades[homework.user_info.mark]);
                }
            
                var markscheme = ' (Mark Scheme: '+homework.assignment.mark_scheme.name+')';
                if (markscheme == ' (Mark Scheme: markscheme.percentage.name)') {
                    assignmentsObject[subject].massMarks += homework.user_info.mark;
                    markscheme = ' (Mark Scheme: Percent)';
                }
                assignmentsObject[subject].totalMarked += 1;
            } else { // end of if homework marked
                homework.user_info.mark = 'N/A';
            }

            if (homework.user_info.status == 'ontime') {
                homework.user_info.status = 'ready'; // makes a tick
            }
            if (homework.user_info.status == null) {
                homework.user_info.status = 'inprogress'; // makes a grey tick
            }
        
        
            if (homework.user_info.status && homework.user_info.mark == "N/A") {
                homework.user_info.status = "notdone";
            }

            myMarks.find('.'+subjectClass+'_total').text(assignmentsObject[subject].total);
            myMarks.find('.'+subjectClass+'_average').text(parseInt(assignmentsObject[subject].massMarks/assignmentsObject[subject].totalMarked)+'%');
            if (myMarks.find('.'+subjectClass+'_average').text() == 'NaN%') {
                myMarks.find('.'+subjectClass+'_average').text('-');
            }
            myMarks.find('.'+subjectClass+'_late').text(parseInt(100*assignmentsObject[subject].late/assignmentsObject[subject].total)+'%');
            myMarks.find('.'+subjectClass+'_notdone').text(parseInt(100*assignmentsObject[subject].notdone/assignmentsObject[subject].total)+'%');

            myMarks.find('.'+subjectClass+'_hws').append(
                '<div class="hw" title="'+homework.assignment.name+markscheme+'" data-assignment-link="' + homework.assignment.link + '">'+
                    homework.user_info.mark+
                   '<div class="center status ui-svg-icon-'+homework.user_info.status+'">'+
                   lateAbsent+
                '</div>'
            );
        }) // end of $.each
    }).fail(function(e) {
        console.log("FAILED");
    });
    
}; // End of GetAssignments function    
    
$(AssignmentSummary).on('click', '.hw', function(el){
    $(this).trigger('os.app.siteviewer', {
        data: { site: el.currentTarget.dataset.assignmentLink }
    });
});

if (user.profile.type == 'student') {
    getAssignments('student',user.uuid);
} else {
    Frog.Model.api('users.getChildren').done(function(listResponse) {
        var children = listResponse.data;
        $.each(children, function(index,child) {
            AssignmentSummary.append(
                '<div class="childHeading">'+
                child.displayname+"'s Assignment Summary</div>"+
                '<div class="child_'+child.uuid+'">'+
                '</div><hr>'
            );
            getAssignments('parent',child.uuid);
       });
    });
}


</script>

I'm not sure I'll turn this into a widget as there's so many parameters to adapt - I don't think I've caught all the marking possibilities yet either.

Each individual homework tile opens the homework, I had to include markschemes in the tile's Title tag as it was possible to have a 5 in GCSE and another homework have a 5 for Effort.

I'd be interested in feedback on this, if anyone wants to try it out.

Link to comment
Share on other sites

On 24/09/2021 at 16:53, Graham Quince said:

Just been experimenting with this for a school and thought others might like the idea:

assignment summary.PNG

 

<style>
    .assignmentReportsTables td,
    .assignmentReportsTables th {
        text-align: center;
        vertical-align: middle;
        line-height: 25px;
        height: 54px;
        
    }
    .assignmentReportsTables {
        font-size: 16px;
        line-height: 25px;
    }
    .hw {
        min-width: 50px;
        height: 50px;
        line-height: 25px;
        vertical-align: middle;
        overflow: hidden;
        border: 1px solid #CCCCCC;
        text-align: center;
        background: #ffffff;
        float: left;
        margin-right: 2px;
        margin-bottom: 2px;
    }
    .hw:hover {
        background: #CCCCCC;
    }
    .hw .status {
        position: relative;
        background-size: cover;
        height: 24px;
        width: 24px;
        margin-left: auto;
        margin-right: auto;
        font-weight: bold;
    }
    .hw .bottom-right {
        position: absolute;
        right: -14px;
        bottom: -1px;
        width: 15px;
        height: 15px;
        line-height: 15px;
        font-size: 13px;
        background-color: #000;
        color: #ffffff;
    }
    .hw .late {
        background: #FF0000;
    }
    .hw .absent {
        background: #000000;
    }
    .hws {
        width: 50%;
    }
    .childHeading {
        font-size: 25px;
        font-weight: bold;
        line-height: 35px;
    }
</style>

<div class="AssignmentSummary"></div>

<script>
var startOfYear = moment('1/9/2021 1:00', "D/M/YYYY H:mm").unix();    
    
    
var AssignmentSummary = arguments[0].find('.AssignmentSummary');
var user = FrogOS ? FrogOS.getUser() : self.getUser();

function getAssignments(view,child_uuid) {
    var self = this;
    var assignmentsObject = {};

    var myMarksSpace = AssignmentSummary;
    var data = {
        end_from: startOfYear,
        end_to: parseInt(moment()/1000),
        status: 'closed', 
        order: 'start desc',
    }
    if (view !== 'student') {
        data = {
            end_from: startOfYear,
            end_to: parseInt(moment()/1000),
            status: 'closed', 
            order: 'start desc',
            assigned_user: child_uuid
        }
        myMarksSpace = AssignmentSummary.find('.child_'+child_uuid);
    }
    myMarksSpace.append(
        '<table class="assignmentReportsTables table-hover table-bordered table sum_'+child_uuid+'">'+
            '<tr>'+
                '<th>Subject</th>'+
                '<th>No. of assignments</th>'+
                '<th>Average Mark</th>'+
                '<th>Late Hand In</th>'+
                '<th>Not done</th>'+
                '<th>Homeworks</th>'+
            '</tr>'+
        '</table>'
    );
    var myMarks = myMarksSpace.find('.sum_'+child_uuid);
    
    FrogOS.fdp({
        url: 'assignment/getAssigned',
        data
    }).done(function(response) {
        var homeworks = response.response.assignments;
        var SubjectsArray = [];

        $.each(homeworks, function(index,homework) {
            /*if (homework.assignment.subject.name == "Chemistry") {
                console.log(homework);
            }*/
            var subject = homework.assignment.subject.name;
            var subjectClass = subject.replace(/\s/g, "").replace("&", "");
            
            if (SubjectsArray.indexOf(subject) < 0) { // Add all unique subjects as a row
                SubjectsArray.push(subject);
                myMarks.append(
                    '<tr>'+
                        '<td>'+subject+'</td>'+
                        '<td class="'+subjectClass+'_total" >0</td>'+
                        '<td class="'+subjectClass+'_average" >0</td>'+
                        '<td class="'+subjectClass+'_late">0</td>'+
                        '<td class="'+subjectClass+'_notdone">0</td>'+
                        '<td class="'+subjectClass+'_hws hws"></td>'+
                    '</tr>'
                )
                assignmentsObject[subject] = {
                     total:0,
                     massMarks: 0,
                     totalMarked: 0,
                     late: 0,
                     notdone: 0
                }
            }; // end of all unique subjects 
        
            var lateAbsent = '';
            var completed = homework.user_info.completed;
            var duedate = homework.assignment.end;

            if (completed > duedate) {
                lateAbsent = '<div class="bottom-right late">L</div>';
                assignmentsObject[subject].late += 1;
            }
            if (homework.user_info.status == "absent") {
                lateAbsent = '<div class="bottom-right absent">A</div>';
            }
            if (homework.user_info.status == "notdone") {
                assignmentsObject[subject].notdone += 1;
            }

            assignmentsObject[subject].total += 1;
            var markscheme = '';
            if (homework.user_info.mark !== null) { // IF the homework has been marked
                if (homework.assignment.mark_scheme.name !== 'markscheme.percentage.name' ) { 
                    var grades = homework.assignment.mark_scheme.data_values.grades;
                    assignmentsObject[subject].massMarks += parseInt(grades[homework.user_info.mark]);
                }
            
                var markscheme = ' (Mark Scheme: '+homework.assignment.mark_scheme.name+')';
                if (markscheme == ' (Mark Scheme: markscheme.percentage.name)') {
                    assignmentsObject[subject].massMarks += homework.user_info.mark;
                    markscheme = ' (Mark Scheme: Percent)';
                }
                assignmentsObject[subject].totalMarked += 1;
            } else { // end of if homework marked
                homework.user_info.mark = 'N/A';
            }

            if (homework.user_info.status == 'ontime') {
                homework.user_info.status = 'ready'; // makes a tick
            }
            if (homework.user_info.status == null) {
                homework.user_info.status = 'inprogress'; // makes a grey tick
            }
        
        
            if (homework.user_info.status && homework.user_info.mark == "N/A") {
                homework.user_info.status = "notdone";
            }

            myMarks.find('.'+subjectClass+'_total').text(assignmentsObject[subject].total);
            myMarks.find('.'+subjectClass+'_average').text(parseInt(assignmentsObject[subject].massMarks/assignmentsObject[subject].totalMarked)+'%');
            if (myMarks.find('.'+subjectClass+'_average').text() == 'NaN%') {
                myMarks.find('.'+subjectClass+'_average').text('-');
            }
            myMarks.find('.'+subjectClass+'_late').text(parseInt(100*assignmentsObject[subject].late/assignmentsObject[subject].total)+'%');
            myMarks.find('.'+subjectClass+'_notdone').text(parseInt(100*assignmentsObject[subject].notdone/assignmentsObject[subject].total)+'%');

            myMarks.find('.'+subjectClass+'_hws').append(
                '<div class="hw" title="'+homework.assignment.name+markscheme+'" data-assignment-link="' + homework.assignment.link + '">'+
                    homework.user_info.mark+
                   '<div class="center status ui-svg-icon-'+homework.user_info.status+'">'+
                   lateAbsent+
                '</div>'
            );
        }) // end of $.each
    }).fail(function(e) {
        console.log("FAILED");
    });
    
}; // End of GetAssignments function    
    
$(AssignmentSummary).on('click', '.hw', function(el){
    $(this).trigger('os.app.siteviewer', {
        data: { site: el.currentTarget.dataset.assignmentLink }
    });
});

if (user.profile.type == 'student') {
    getAssignments('student',user.uuid);
} else {
    Frog.Model.api('users.getChildren').done(function(listResponse) {
        var children = listResponse.data;
        $.each(children, function(index,child) {
            AssignmentSummary.append(
                '<div class="childHeading">'+
                child.displayname+"'s Assignment Summary</div>"+
                '<div class="child_'+child.uuid+'">'+
                '</div><hr>'
            );
            getAssignments('parent',child.uuid);
       });
    });
}


</script>

I'm not sure I'll turn this into a widget as there's so many parameters to adapt - I don't think I've caught all the marking possibilities yet either.

Each individual homework tile opens the homework, I had to include markschemes in the tile's Title tag as it was possible to have a 5 in GCSE and another homework have a 5 for Effort.

I'd be interested in feedback on this, if anyone wants to try it out.

I assume this could be seen by parents??

Just had a quick look i can see its potential... but its a bit ruff round the edges!! 😜

Link to comment
Share on other sites

What might be nice is a slightly different version that can be linked to the select user widget.... im thinking a quick way for pastoral to to see the overview of work done on Frog by a random student!!

Link to comment
Share on other sites

20 hours ago, ADT said:

What might be nice is a slightly different version that can be linked to the select user widget.... im thinking a quick way for pastoral to to see the overview of work done on Frog by a random student!!

The things I do for you:

<style>
    .assignmentReportsTables td,
    .assignmentReportsTables th {
        text-align: center;
        vertical-align: middle;
        line-height: 25px;
        height: 54px;
        
    }
    .assignmentReportsTables {
        font-size: 16px;
        line-height: 25px;
    }
    .hw {
        min-width: 50px;
        height: 50px;
        line-height: 25px;
        vertical-align: middle;
        overflow: hidden;
        border: 1px solid #CCCCCC;
        text-align: center;
        background: #ffffff;
        float: left;
        margin-right: 2px;
        margin-bottom: 2px;
    }
    .hw:hover {
        background: #CCCCCC;
    }
    .hw .status {
        position: relative;
        background-size: cover;
        height: 24px;
        width: 24px;
        margin-left: auto;
        margin-right: auto;
        font-weight: bold;
    }
    .hw .bottom-right {
        position: absolute;
        right: -14px;
        bottom: -1px;
        width: 15px;
        height: 15px;
        line-height: 15px;
        font-size: 13px;
        background-color: #000;
        color: #ffffff;
    }
    .hw .late {
        background: #FF0000;
    }
    .hw .absent {
        background: #000000;
    }
    .hws {
        width: 50%;
    }
    .childHeading {
        font-size: 25px;
        font-weight: bold;
        line-height: 35px;
    }
</style>

<div class="AssignmentSummary"></div>

<script>
var startOfYear = moment('1/9/2021 1:00', "D/M/YYYY H:mm").unix();    
    
    
var AssignmentSummary = arguments[0].find('.AssignmentSummary');
var user = FrogOS ? FrogOS.getUser() : self.getUser();

function getAssignments(view,child_uuid) {

    var self = this;
    var assignmentsObject = {};

    AssignmentSummary.empty();
    var data = {
        end_from: startOfYear,
        end_to: parseInt(moment()/1000),
        status: 'closed', 
        order: 'start desc',
    }
    if (view !== 'student') {
        data = {
            end_from: startOfYear,
            end_to: parseInt(moment()/1000),
            status: 'closed', 
            order: 'start desc',
            assigned_user: child_uuid
        }
    }
    AssignmentSummary.append(
        '<table class="assignmentReportsTables table-hover table-bordered table sum_'+child_uuid+'">'+
            '<tr>'+
                '<th>Subject</th>'+
                '<th>No. of assignments</th>'+
                '<th>Average Mark</th>'+
                '<th>Late Hand In</th>'+
                '<th>Not done</th>'+
                '<th>Homeworks</th>'+
            '</tr>'+
        '</table>'
    );
    var myMarks = AssignmentSummary.find('.sum_'+child_uuid);
    
    FrogOS.fdp({
        url: 'assignment/getAssigned',
        data
    }).done(function(response) {
        var homeworks = response.response.assignments;
        var SubjectsArray = [];

        $.each(homeworks, function(index,homework) {

            var subject = homework.assignment.subject.name;
            var subjectClass = subject.replace(/\s/g, "").replace("&", "");
            
            if (SubjectsArray.indexOf(subject) < 0) { // Add all unique subjects as a row
                SubjectsArray.push(subject);
                myMarks.append(
                    '<tr>'+
                        '<td>'+subject+'</td>'+
                        '<td class="'+subjectClass+'_total" >0</td>'+
                        '<td class="'+subjectClass+'_average" >0</td>'+
                        '<td class="'+subjectClass+'_late">0</td>'+
                        '<td class="'+subjectClass+'_notdone">0</td>'+
                        '<td class="'+subjectClass+'_hws hws"></td>'+
                    '</tr>'
                )
                assignmentsObject[subject] = {
                     total:0,
                     massMarks: 0,
                     totalMarked: 0,
                     late: 0,
                     notdone: 0
                }
            }; // end of all unique subjects 
        
            var lateAbsent = '';
            var completed = homework.user_info.completed;
            var duedate = homework.assignment.end;

            if (completed > duedate) {
                lateAbsent = '<div class="bottom-right late">L</div>';
                assignmentsObject[subject].late += 1;
            }
            if (homework.user_info.status == "absent") {
                lateAbsent = '<div class="bottom-right absent">A</div>';
            }
            if (homework.user_info.status == "notdone") {
                assignmentsObject[subject].notdone += 1;
            }

            assignmentsObject[subject].total += 1;
            var markscheme = '';
            if (homework.user_info.mark !== null) { // IF the homework has been marked
                if (homework.assignment.mark_scheme.name !== 'markscheme.percentage.name' ) { 
                    var grades = homework.assignment.mark_scheme.data_values.grades;
                    assignmentsObject[subject].massMarks += parseInt(grades[homework.user_info.mark]);
                }
            
                var markscheme = ' (Mark Scheme: '+homework.assignment.mark_scheme.name+')';
                if (markscheme == ' (Mark Scheme: markscheme.percentage.name)') {
                    assignmentsObject[subject].massMarks += homework.user_info.mark;
                    markscheme = ' (Mark Scheme: Percent)';
                }
                assignmentsObject[subject].totalMarked += 1;
            } else { // end of if homework marked
                homework.user_info.mark = 'N/A';
            }

            if (homework.user_info.status == 'ontime') {
                homework.user_info.status = 'ready'; // makes a tick
            }
            if (homework.user_info.status == null) {
                homework.user_info.status = 'inprogress'; // makes a grey tick
            }
        
        
            if (homework.user_info.status && homework.user_info.mark == "N/A") {
                homework.user_info.status = "notdone";
            }

            myMarks.find('.'+subjectClass+'_total').text(assignmentsObject[subject].total);
            myMarks.find('.'+subjectClass+'_average').text(parseInt(assignmentsObject[subject].massMarks/assignmentsObject[subject].totalMarked)+'%');
            if (myMarks.find('.'+subjectClass+'_average').text() == 'NaN%') {
                myMarks.find('.'+subjectClass+'_average').text('-');
            }
            myMarks.find('.'+subjectClass+'_late').text(parseInt(100*assignmentsObject[subject].late/assignmentsObject[subject].total)+'%');
            myMarks.find('.'+subjectClass+'_notdone').text(parseInt(100*assignmentsObject[subject].notdone/assignmentsObject[subject].total)+'%');

            myMarks.find('.'+subjectClass+'_hws').append(
                '<div class="hw" title="'+homework.assignment.name+markscheme+'" data-assignment-link="' + homework.assignment.link + '">'+
                    homework.user_info.mark+
                   '<div class="center status ui-svg-icon-'+homework.user_info.status+'">'+
                   lateAbsent+
                '</div>'
            );
        }) // end of $.each
    }).fail(function(e) {
        console.log("FAILED");
    });
    
}; // End of GetAssignments function    
    
$(AssignmentSummary).on('click', '.hw', function(el){
    $(this).trigger('os.app.siteviewer', {
        data: { site: el.currentTarget.dataset.assignmentLink }
    });
});

if (user.profile.type == 'student') {
    getAssignments('student',user.uuid);
} else {

    $('div[data-content-uuid="SELECT_USER_WIDGET_CONTENT_UUID"]').on('broadcast.selectedUser',function(el, ev) {
        getAssignments('parent',ev.model.uuid);
    });

}


</script>

 

  • Like 1
Link to comment
Share on other sites

21 hours ago, Graham Quince said:

The things I do for you:

<style>
    .assignmentReportsTables td,
    .assignmentReportsTables th {
        text-align: center;
        vertical-align: middle;
        line-height: 25px;
        height: 54px;
        
    }
    .assignmentReportsTables {
        font-size: 16px;
        line-height: 25px;
    }
    .hw {
        min-width: 50px;
        height: 50px;
        line-height: 25px;
        vertical-align: middle;
        overflow: hidden;
        border: 1px solid #CCCCCC;
        text-align: center;
        background: #ffffff;
        float: left;
        margin-right: 2px;
        margin-bottom: 2px;
    }
    .hw:hover {
        background: #CCCCCC;
    }
    .hw .status {
        position: relative;
        background-size: cover;
        height: 24px;
        width: 24px;
        margin-left: auto;
        margin-right: auto;
        font-weight: bold;
    }
    .hw .bottom-right {
        position: absolute;
        right: -14px;
        bottom: -1px;
        width: 15px;
        height: 15px;
        line-height: 15px;
        font-size: 13px;
        background-color: #000;
        color: #ffffff;
    }
    .hw .late {
        background: #FF0000;
    }
    .hw .absent {
        background: #000000;
    }
    .hws {
        width: 50%;
    }
    .childHeading {
        font-size: 25px;
        font-weight: bold;
        line-height: 35px;
    }
</style>

<div class="AssignmentSummary"></div>

<script>
var startOfYear = moment('1/9/2021 1:00', "D/M/YYYY H:mm").unix();    
    
    
var AssignmentSummary = arguments[0].find('.AssignmentSummary');
var user = FrogOS ? FrogOS.getUser() : self.getUser();

function getAssignments(view,child_uuid) {

    var self = this;
    var assignmentsObject = {};

    AssignmentSummary.empty();
    var data = {
        end_from: startOfYear,
        end_to: parseInt(moment()/1000),
        status: 'closed', 
        order: 'start desc',
    }
    if (view !== 'student') {
        data = {
            end_from: startOfYear,
            end_to: parseInt(moment()/1000),
            status: 'closed', 
            order: 'start desc',
            assigned_user: child_uuid
        }
    }
    AssignmentSummary.append(
        '<table class="assignmentReportsTables table-hover table-bordered table sum_'+child_uuid+'">'+
            '<tr>'+
                '<th>Subject</th>'+
                '<th>No. of assignments</th>'+
                '<th>Average Mark</th>'+
                '<th>Late Hand In</th>'+
                '<th>Not done</th>'+
                '<th>Homeworks</th>'+
            '</tr>'+
        '</table>'
    );
    var myMarks = AssignmentSummary.find('.sum_'+child_uuid);
    
    FrogOS.fdp({
        url: 'assignment/getAssigned',
        data
    }).done(function(response) {
        var homeworks = response.response.assignments;
        var SubjectsArray = [];

        $.each(homeworks, function(index,homework) {

            var subject = homework.assignment.subject.name;
            var subjectClass = subject.replace(/\s/g, "").replace("&", "");
            
            if (SubjectsArray.indexOf(subject) < 0) { // Add all unique subjects as a row
                SubjectsArray.push(subject);
                myMarks.append(
                    '<tr>'+
                        '<td>'+subject+'</td>'+
                        '<td class="'+subjectClass+'_total" >0</td>'+
                        '<td class="'+subjectClass+'_average" >0</td>'+
                        '<td class="'+subjectClass+'_late">0</td>'+
                        '<td class="'+subjectClass+'_notdone">0</td>'+
                        '<td class="'+subjectClass+'_hws hws"></td>'+
                    '</tr>'
                )
                assignmentsObject[subject] = {
                     total:0,
                     massMarks: 0,
                     totalMarked: 0,
                     late: 0,
                     notdone: 0
                }
            }; // end of all unique subjects 
        
            var lateAbsent = '';
            var completed = homework.user_info.completed;
            var duedate = homework.assignment.end;

            if (completed > duedate) {
                lateAbsent = '<div class="bottom-right late">L</div>';
                assignmentsObject[subject].late += 1;
            }
            if (homework.user_info.status == "absent") {
                lateAbsent = '<div class="bottom-right absent">A</div>';
            }
            if (homework.user_info.status == "notdone") {
                assignmentsObject[subject].notdone += 1;
            }

            assignmentsObject[subject].total += 1;
            var markscheme = '';
            if (homework.user_info.mark !== null) { // IF the homework has been marked
                if (homework.assignment.mark_scheme.name !== 'markscheme.percentage.name' ) { 
                    var grades = homework.assignment.mark_scheme.data_values.grades;
                    assignmentsObject[subject].massMarks += parseInt(grades[homework.user_info.mark]);
                }
            
                var markscheme = ' (Mark Scheme: '+homework.assignment.mark_scheme.name+')';
                if (markscheme == ' (Mark Scheme: markscheme.percentage.name)') {
                    assignmentsObject[subject].massMarks += homework.user_info.mark;
                    markscheme = ' (Mark Scheme: Percent)';
                }
                assignmentsObject[subject].totalMarked += 1;
            } else { // end of if homework marked
                homework.user_info.mark = 'N/A';
            }

            if (homework.user_info.status == 'ontime') {
                homework.user_info.status = 'ready'; // makes a tick
            }
            if (homework.user_info.status == null) {
                homework.user_info.status = 'inprogress'; // makes a grey tick
            }
        
        
            if (homework.user_info.status && homework.user_info.mark == "N/A") {
                homework.user_info.status = "notdone";
            }

            myMarks.find('.'+subjectClass+'_total').text(assignmentsObject[subject].total);
            myMarks.find('.'+subjectClass+'_average').text(parseInt(assignmentsObject[subject].massMarks/assignmentsObject[subject].totalMarked)+'%');
            if (myMarks.find('.'+subjectClass+'_average').text() == 'NaN%') {
                myMarks.find('.'+subjectClass+'_average').text('-');
            }
            myMarks.find('.'+subjectClass+'_late').text(parseInt(100*assignmentsObject[subject].late/assignmentsObject[subject].total)+'%');
            myMarks.find('.'+subjectClass+'_notdone').text(parseInt(100*assignmentsObject[subject].notdone/assignmentsObject[subject].total)+'%');

            myMarks.find('.'+subjectClass+'_hws').append(
                '<div class="hw" title="'+homework.assignment.name+markscheme+'" data-assignment-link="' + homework.assignment.link + '">'+
                    homework.user_info.mark+
                   '<div class="center status ui-svg-icon-'+homework.user_info.status+'">'+
                   lateAbsent+
                '</div>'
            );
        }) // end of $.each
    }).fail(function(e) {
        console.log("FAILED");
    });
    
}; // End of GetAssignments function    
    
$(AssignmentSummary).on('click', '.hw', function(el){
    $(this).trigger('os.app.siteviewer', {
        data: { site: el.currentTarget.dataset.assignmentLink }
    });
});

if (user.profile.type == 'student') {
    getAssignments('student',user.uuid);
} else {

    $('div[data-content-uuid="SELECT_USER_WIDGET_CONTENT_UUID"]').on('broadcast.selectedUser',function(el, ev) {
        getAssignments('parent',ev.model.uuid);
    });

}


</script>

 

Keep you in a job.... :P  

Thanks mate!!

  • Thanks 1
Link to comment
Share on other sites

23 hours ago, Graham Quince said:

The things I do for you:

<style>
    .assignmentReportsTables td,
    .assignmentReportsTables th {
        text-align: center;
        vertical-align: middle;
        line-height: 25px;
        height: 54px;
        
    }
    .assignmentReportsTables {
        font-size: 16px;
        line-height: 25px;
    }
    .hw {
        min-width: 50px;
        height: 50px;
        line-height: 25px;
        vertical-align: middle;
        overflow: hidden;
        border: 1px solid #CCCCCC;
        text-align: center;
        background: #ffffff;
        float: left;
        margin-right: 2px;
        margin-bottom: 2px;
    }
    .hw:hover {
        background: #CCCCCC;
    }
    .hw .status {
        position: relative;
        background-size: cover;
        height: 24px;
        width: 24px;
        margin-left: auto;
        margin-right: auto;
        font-weight: bold;
    }
    .hw .bottom-right {
        position: absolute;
        right: -14px;
        bottom: -1px;
        width: 15px;
        height: 15px;
        line-height: 15px;
        font-size: 13px;
        background-color: #000;
        color: #ffffff;
    }
    .hw .late {
        background: #FF0000;
    }
    .hw .absent {
        background: #000000;
    }
    .hws {
        width: 50%;
    }
    .childHeading {
        font-size: 25px;
        font-weight: bold;
        line-height: 35px;
    }
</style>

<div class="AssignmentSummary"></div>

<script>
var startOfYear = moment('1/9/2021 1:00', "D/M/YYYY H:mm").unix();    
    
    
var AssignmentSummary = arguments[0].find('.AssignmentSummary');
var user = FrogOS ? FrogOS.getUser() : self.getUser();

function getAssignments(view,child_uuid) {

    var self = this;
    var assignmentsObject = {};

    AssignmentSummary.empty();
    var data = {
        end_from: startOfYear,
        end_to: parseInt(moment()/1000),
        status: 'closed', 
        order: 'start desc',
    }
    if (view !== 'student') {
        data = {
            end_from: startOfYear,
            end_to: parseInt(moment()/1000),
            status: 'closed', 
            order: 'start desc',
            assigned_user: child_uuid
        }
    }
    AssignmentSummary.append(
        '<table class="assignmentReportsTables table-hover table-bordered table sum_'+child_uuid+'">'+
            '<tr>'+
                '<th>Subject</th>'+
                '<th>No. of assignments</th>'+
                '<th>Average Mark</th>'+
                '<th>Late Hand In</th>'+
                '<th>Not done</th>'+
                '<th>Homeworks</th>'+
            '</tr>'+
        '</table>'
    );
    var myMarks = AssignmentSummary.find('.sum_'+child_uuid);
    
    FrogOS.fdp({
        url: 'assignment/getAssigned',
        data
    }).done(function(response) {
        var homeworks = response.response.assignments;
        var SubjectsArray = [];

        $.each(homeworks, function(index,homework) {

            var subject = homework.assignment.subject.name;
            var subjectClass = subject.replace(/\s/g, "").replace("&", "");
            
            if (SubjectsArray.indexOf(subject) < 0) { // Add all unique subjects as a row
                SubjectsArray.push(subject);
                myMarks.append(
                    '<tr>'+
                        '<td>'+subject+'</td>'+
                        '<td class="'+subjectClass+'_total" >0</td>'+
                        '<td class="'+subjectClass+'_average" >0</td>'+
                        '<td class="'+subjectClass+'_late">0</td>'+
                        '<td class="'+subjectClass+'_notdone">0</td>'+
                        '<td class="'+subjectClass+'_hws hws"></td>'+
                    '</tr>'
                )
                assignmentsObject[subject] = {
                     total:0,
                     massMarks: 0,
                     totalMarked: 0,
                     late: 0,
                     notdone: 0
                }
            }; // end of all unique subjects 
        
            var lateAbsent = '';
            var completed = homework.user_info.completed;
            var duedate = homework.assignment.end;

            if (completed > duedate) {
                lateAbsent = '<div class="bottom-right late">L</div>';
                assignmentsObject[subject].late += 1;
            }
            if (homework.user_info.status == "absent") {
                lateAbsent = '<div class="bottom-right absent">A</div>';
            }
            if (homework.user_info.status == "notdone") {
                assignmentsObject[subject].notdone += 1;
            }

            assignmentsObject[subject].total += 1;
            var markscheme = '';
            if (homework.user_info.mark !== null) { // IF the homework has been marked
                if (homework.assignment.mark_scheme.name !== 'markscheme.percentage.name' ) { 
                    var grades = homework.assignment.mark_scheme.data_values.grades;
                    assignmentsObject[subject].massMarks += parseInt(grades[homework.user_info.mark]);
                }
            
                var markscheme = ' (Mark Scheme: '+homework.assignment.mark_scheme.name+')';
                if (markscheme == ' (Mark Scheme: markscheme.percentage.name)') {
                    assignmentsObject[subject].massMarks += homework.user_info.mark;
                    markscheme = ' (Mark Scheme: Percent)';
                }
                assignmentsObject[subject].totalMarked += 1;
            } else { // end of if homework marked
                homework.user_info.mark = 'N/A';
            }

            if (homework.user_info.status == 'ontime') {
                homework.user_info.status = 'ready'; // makes a tick
            }
            if (homework.user_info.status == null) {
                homework.user_info.status = 'inprogress'; // makes a grey tick
            }
        
        
            if (homework.user_info.status && homework.user_info.mark == "N/A") {
                homework.user_info.status = "notdone";
            }

            myMarks.find('.'+subjectClass+'_total').text(assignmentsObject[subject].total);
            myMarks.find('.'+subjectClass+'_average').text(parseInt(assignmentsObject[subject].massMarks/assignmentsObject[subject].totalMarked)+'%');
            if (myMarks.find('.'+subjectClass+'_average').text() == 'NaN%') {
                myMarks.find('.'+subjectClass+'_average').text('-');
            }
            myMarks.find('.'+subjectClass+'_late').text(parseInt(100*assignmentsObject[subject].late/assignmentsObject[subject].total)+'%');
            myMarks.find('.'+subjectClass+'_notdone').text(parseInt(100*assignmentsObject[subject].notdone/assignmentsObject[subject].total)+'%');

            myMarks.find('.'+subjectClass+'_hws').append(
                '<div class="hw" title="'+homework.assignment.name+markscheme+'" data-assignment-link="' + homework.assignment.link + '">'+
                    homework.user_info.mark+
                   '<div class="center status ui-svg-icon-'+homework.user_info.status+'">'+
                   lateAbsent+
                '</div>'
            );
        }) // end of $.each
    }).fail(function(e) {
        console.log("FAILED");
    });
    
}; // End of GetAssignments function    
    
$(AssignmentSummary).on('click', '.hw', function(el){
    $(this).trigger('os.app.siteviewer', {
        data: { site: el.currentTarget.dataset.assignmentLink }
    });
});

if (user.profile.type == 'student') {
    getAssignments('student',user.uuid);
} else {

    $('div[data-content-uuid="SELECT_USER_WIDGET_CONTENT_UUID"]').on('broadcast.selectedUser',function(el, ev) {
        getAssignments('parent',ev.model.uuid);
    });

}


</script>

 

Yeah that didn't work?

Link to comment
Share on other sites

5 minutes ago, Graham Quince said:

Send me a message to where it is.  Did you set the UUID?

You really need to make these things more explicit........  I did have a quick look thinking there had to be somewhere to "point" the code........  on second inspection i've spotted it and fixed it!!

Really shouldn't try teaching and Frogging at the same time!! 🤪

  • Haha 1
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...