/**
  * @runInSeparateProcess
  */
 public function test_student_courses()
 {
     $this->resetAfterTest(true);
     $user = $this->getDataGenerator()->create_user();
     $row = array();
     $row['user_id'] = $user->id;
     $row['email'] = null;
     $row['timestamp'] = time();
     G\addvaliduser($row);
     $this->setUser($user);
     $course = $this->getDataGenerator()->create_course();
     $cohort = $this->getDataGenerator()->create_cohort(array('idnumber' => 1234.56789));
     cohort_add_member($cohort->id, $user->id);
     G\addtermid('1234');
     $enrol = enrol_get_plugin('cohort');
     $instance = array();
     $instance['name'] = 'name';
     $instance['status'] = ENROL_INSTANCE_ENABLED;
     // Enable it.
     $instance['customint1'] = $cohort->id;
     // Used to store the cohort id.
     $instance['roleid'] = $enrol->get_config('roleid');
     // Default role for cohort enrol which is usually student.
     $instance['customint2'] = 0;
     // Optional group id.
     $enrol->add_instance($course, $instance);
     $trace = new null_progress_trace();
     enrol_cohort_sync($trace, $course->id);
     $trace->finished();
     $courses = G\coursesas($user->id, 'student');
     $courseids = array();
     foreach ($courses as $newcourse) {
         array_push($courseids, $newcourse->id);
     }
     $this->assertContains($course->id, $courseids);
 }
 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.
         $assid = G\newassessment($teacherid, time(), $timetaken, $csem, "Teacher", $courseid);
         $rangeinput = optional_param_array("rangeInput", null, PARAM_NUMBER);
Esempio n. 3
0
         if (count($courseid) > 0) {
             foreach ($courseid as $cids) {
                 $ccradio = optional_param("CourseRadio{$subattid}{$cids}", null, PARAM_INT);
                 $ccvalue = 0;
                 if ($ccradio != null) {
                     $ccvalue = $ccradio;
                 }
                 // Creating a row in ContributedCourses table for each of courses having impact on improvement of sub-attribute.
                 G\newcontributedcourse($subattassessmentid, $cids, $ccvalue);
             }
         }
     }
     $datasaved = true;
 }
 // Getting the courses user enroled in in current year and semester.
 $courses = G\coursesas($USER->id, "student");
 ?>
 <div style="margin-bottom: 0px; width:1100px;" class='block_course_overview  block'>
     <div class="header">
         <div class="title">
             <h2><i class='fa fa-question-circle'></i> Assessment</h2>
         </div>
     </div>
     <div class='content'>
         <?php 
 if ($datasaved) {
     echo "<div class='alert alert-success'><b>" . get_string('savedmes', 'local_gas') . "</b></div>";
 }
 ?>
         <form action='student.php' method='post' onsubmit="setFormSubmitting()">
             <input type='hidden' value='assessment' name='action'>