/** * Defines forms elements */ public function definition() { global $DB; $mform = $this->_form; $instance = $this->_customdata; $categoryid = $instance["category"]; $arraysubcategory = array(); $arraysubcategory[$categoryid] = get_string('selectcategory', 'mod_emarking'); $subcategories = emarking_get_subcategories($categoryid); $arraysubcategory = $arraysubcategory + $subcategories; $mform->addElement('select', 'category', get_string('category', 'mod_emarking'), $arraysubcategory); $mform->addHelpButton('category', 'categoryselect', 'mod_emarking'); $this->add_action_buttons(false, get_string('gotosubcategory', 'mod_emarking')); }
if ($isyears == 1) { $date = "YEAR"; } else { $date = "MONTH"; } $parentcategory = $DB->get_record('course_categories', array('id' => $categoryid)); // Add the emarking cost form for categories. if ($parentcategory->parent != 0) { $adduppercategoryform = new emarking_uppercategory_form(null, array("category" => $categoryid)); // If the form is cancelled redirects you to the report center. if ($datas = $adduppercategoryform->get_data()) { // Redirect to the table with all the category costs. redirect(new moodle_url("/mod/emarking/reports/costcenter.php", array("category" => $categoryid))); } } $subcategories = emarking_get_subcategories($categoryid); if (!empty($subcategories)) { // Add the emarking cost form for categories. $addsubcategoryform = new emarking_subcategory_form(null, array("category" => $categoryid)); // If the form is cancelled redirects you to the report center. if ($datas = $addsubcategoryform->get_data()) { // Redirect to the table with all the category costs. redirect(new moodle_url("/mod/emarking/reports/costcenter.php", array("category" => $categoryid))); } } $activitiesmain = emarking_get_query(array("%/{$categoryid}/%", $categoryid), "idexam, COUNT(id) AS activities, printdate", "eexam.id AS idexam,e.id AS id," . $date . "(FROM_UNIXTIME(eexam.printdate)) AS printdate", "(cc.path like ? OR cc.id = ?)", null, null, null, "printdate", "printdate ASC"); $activitiesmainchart = json_encode(emarking_array_by_date($isyears, $activitiesmain, get_string('activities', 'mod_emarking'), "printdate", "activities")); $emarkingcoursesmain = emarking_get_query(array("%/{$categoryid}/%", $categoryid), "printdate, COUNT(course) AS coursecount", "e.course AS course," . $date . "(FROM_UNIXTIME(MIN(eexam.printdate))) as printdate", "(cc.path like ? OR cc.id = ?)", "course", "printdate DESC", null, "printdate", null); $emarkingcoursesmainchart = json_encode(emarking_array_by_date($isyears, $emarkingcoursesmain, get_string('emarkingcourses', 'mod_emarking'), "printdate", "coursecount")); $meanexamlenghtmain = emarking_get_query(array("%/{$categoryid}/%", $categoryid, EMARKING_EXAM_PRINTED, EMARKING_EXAM_SENT_TO_PRINT), "printdate, AVG(pages) AS avgpages", "eexam.id as id," . $date . "(FROM_UNIXTIME(eexam.printdate)) as printdate,(eexam.totalpages+eexam.extrasheets) AS pages", "(cc.path like ? OR cc.id = ?) AND eexam.status IN (?,?)", "id", null, null, "printdate", null); $meanexamlenghtmainchart = json_encode(emarking_array_by_date($isyears, $meanexamlenghtmain, get_string('meanexamlength', 'mod_emarking'), "printdate", "avgpages"));