echo local_gas_page('/index.php?id=' . $id, $pagetitle, $pageheading, $context);
 // Code for manualy activing a link in navigator.
 G\makenavigatorlinkactive($PAGE, "courseAssessment");
 echo $OUTPUT->header();
 $initjs = "var formSubmitting = false;\n        var changesHappened = false;\n        var setFormSubmitting = function () {\n            formSubmitting = true;\n        };\n        var setChanges = function () {\n            changesHappened = true;\n        };\n        window.onload = function () {\n            window.addEventListener('beforeunload', function (e) {\n                if (formSubmitting || !changesHappened) {\n                    return undefined;\n                }\n                var confirmationMessage = 'It looks like you have been editing something. '\n                        + 'If you leave before saving, your changes will be lost.';\n                (e || window.event).returnValue = confirmationMessage;\n                return confirmationMessage;\n            });\n        };\n\n        function RefreshChart() {\n            var d = [];\n            var d2 = [];\n            d.push(d2);";
 $labels = G\getattributes(current_language(), time());
 for ($i = 1; $i <= count($labels); $i++) {
     $labelname = $labels[$i - 1]->name;
     $labelid = $labels[$i - 1]->attribute_id;
     $initjs .= "d[0].push({axis: '{$labelname}', value: \$('#aveOf{$labelid}').val() });";
 }
 $initjs .= "    RadarChart.drawChart(d, []);\n                }\n                \$(document).ready(function () {\n                    \$('#myTabs a').click(function (e) {\n                        e.preventDefault()\n                        \$(this).tab('show')\n                      });\n                    \$('.rangeInput').keyup(function( event ) {\n                        id = this.id.substring(10);\n                        val = \$(this).val();\n                        if(val > 0 && val < 6)\n                            highLightDescription('descriptionRow'+id+val);\n                    });\n                    \$('.rangeInput').mouseup(function( event ) {\n                        id = this.id.substring(10);\n                        val = \$(this).val();\n                        if(val > 0 && val < 6)\n                            highLightDescription('descriptionRow'+id , val);\n                    });\n                    RefreshChart();\n                    \$('.rangeInput').keyup(function (event) {\n                        RefreshChart();\n                    });\n                    \$('.rangeInput').mouseup(function (event) {\n                        RefreshChart();\n                    });\n                });\n            var w = 200, h = 200;\n\n            var mycfg = {\n                w: w,\n                h: h,\n                maxValue: 5,\n                levels: 5,\n                ExtraWidthX: 150\n            };\n            function ShowDes(val1, val2, num) {\n                for (var i = 0; i < num; i++) {\n                    document.getElementById('attDes' + val1 + i).style.display = 'none';\n                }\n                document.getElementById('attDes' + val1 + val2).style.display = 'table';\n            }\n            function highLightDescription(id, val) {\n                newId = id + val;\n                \$('[class^=' + id + ']').removeClass('info');\n                \$('.' + newId).addClass('info');\n            }";
 echo html_writer::script($initjs);
 // Print_object($USER);.
 $cyear = date("Y");
 $csem = G\semofdate(date("d"), date("m"));
 // Getting all courses this users in enrolled in as instructor.
 $courses = G\coursesas($USER->id, "teacher");
 $act = optional_param("action", null, PARAM_TEXT);
 $choosencourse = null;
 $datasaved = false;
 // If the form submited for choosing a course.
 if ($act == "choosingCourse") {
     $choosencourse = optional_param("courseID", null, PARAM_INT);
 } else {
     if ($act == "assessment") {
         // If the form submited for assessing a course.
         $teacherid = $USER->id;
         $timetaken = time() - optional_param("AssStartTime", null, PARAM_INT);
         $courseid = optional_param("course_id", null, PARAM_INT);
         // Creating a new row for course assessment.
 // List id.
 require_login(1, false);
 // Use course 1 because this has nothing to do with an actual course, just like course 1.
 $context = context_system::instance();
 $pagetitle = get_string('pluginname', 'local_gas');
 $pageheading = get_string('pluginname', 'local_gas');
 echo local_gas_page('/index.php?id=' . $id, $pagetitle, $pageheading, $context);
 // This part added as the highlighting of the navigators was not working.
 G\makenavigatorlinkactive($PAGE, "assessment");
 echo $OUTPUT->header();
 // NextCourse: function to change the course in "Contributed Courses" Coloumn
 // HighlightDescription: highliting the value description based on the range input.
 $initjs = " var formSubmitting = false;\n                var changesHappened = false;\n                var setFormSubmitting = function () {\n                    formSubmitting = true;\n                };\n                var setChanges = function () {\n                    changesHappened = true;\n                };\n                window.onload = function () {\n                    window.addEventListener('beforeunload', function (e) {\n                        if (formSubmitting || !changesHappened) {\n                            return undefined;\n                        }\n                        var confirmationMessage = 'It looks like you have been editing something. '\n                                + 'If you leave before saving, your changes will be lost.';\n\n                        (e || window.event).returnValue = confirmationMessage; //Gecko + IE\n                        return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.\n                    });\n                };\n                function ShowDes(val1, val2, num) {\n                    for (var i = 0; i < num; i++) {\n                        document.getElementById('attDes' + val1 + i).style.display = 'none';\n                    }\n                    document.getElementById('attDes' + val1 + val2).style.display = 'table';\n                }\n                function highLightDescription(id, val) {\n\n                    newId = id + val;\n                    \$('[class^=' + id + ']').removeClass('info');\n                    \$('.' + newId).addClass('info');\n                }\n                \$(document).ready(function () {\n\n                    \$('#myTabs a').click(function (e) {\n                        e.preventDefault()\n                        \$(this).tab('show')\n                      });\n\n                    \$('.rangeInput').keyup(function( event ) {\n                        id = this.id.substring(10);\n                        val = \$(this).val();\n                        if(val > 0 && val < 6)\n                            highLightDescription('descriptionRow'+id+val);\n                    });\n\n                    \$('.rangeInput').mouseup(function( event ) {\n                        id = this.id.substring(10);\n                        val = \$(this).val();\n                        if(val > 0 && val < 6)\n                            highLightDescription('descriptionRow'+id , val);\n                    });\n                });\n\n                function nextCourse(id, counter, max){\n                    if(counter == 1){\n                        var option1={direction: 'right'};\n                        var option2={direction: 'left'};\n                    }\n                    if(counter == -1){\n                        var option1={direction: 'left'};\n                        var option2={direction: 'right'};\n                    }\n                    currentID = parseInt(\$('.'+id+':visible').attr('id'));\n                    nextID = (parseInt(currentID) + counter + max)%max;\n                    \$('#'+id+currentID).toggle('slide', option1, 300);\n                    setTimeout(function(){\n                        \$('#'+id+nextID).toggle('slide', option2, 300);\n                    }, 300);\n                }";
 echo html_writer::script($initjs);
 $act = optional_param("action", null, PARAM_TEXT);
 $currentsem = G\semofdate(date("d"), date("m"));
 $datasaved = false;
 // If the form submited to save an assessment.
 if ($act == "assessment") {
     $studentid = $USER->id;
     // Variable storing the amount of time user spent on assessment.
     $timetaken = time() - optional_param("AssStartTime", null, PARAM_INT);
     // Creating a row in assessment table.
     $assid = G\newassessment($studentid, time(), $timetaken, $currentsem, "Student");
     $rangeinput = optional_param_array("rangeInput", null, PARAM_NUMBER);
     $subattids = optional_param_array("subattID", null, PARAM_INT);
     foreach ($subattids as $subattid) {
         // Creating a row for each of the sub-attributes of assessment.
         $subattassessmentid = G\newsubattassessment($assid, $subattid, current($rangeinput), "Student");
         next($rangeinput);
         $courseid = optional_param_array("CourseIDFor{$subattid}", null, PARAM_INT);