require_once 'locallib.php'; global $DB, $CFG, $SCRIPT, $USER; // Category with courses. $categoryid = required_param('category', PARAM_INT); // Status icon. $statusicon = optional_param('status', 1, PARAM_INT); // Page action. $action = optional_param('action', 'view', PARAM_ALPHA); // Page. $page = optional_param('page', 0, PARAM_INT); $perpage = 100; // Exam id in case an exam required to be downloaded through a form. $examid = optional_param("examid", 0, PARAM_INT); // If the user is downloading a print form. $downloadform = optional_param("downloadform", false, PARAM_BOOL); emarking_verify_logo(); // Validate status (print orders or history). if ($statusicon < 1 || $statusicon > 2) { print_error(get_string("invalidstatus", "mod_emarking")); } // Validate category. if (!($category = $DB->get_record('course_categories', array('id' => $categoryid)))) { print_error(get_string('invalidcategoryid', 'mod_emarking')); } // We are in the category context. $context = context_coursecat::instance($categoryid); // User must be logged in. require_login(); if (isguestuser()) { die; }
/** * Defines forms elements */ public function definition() { global $COURSE, $DB, $CFG, $USER; $mform = $this->_form; $instance = $this->_customdata; // Exam id, in case we are in editing mode. if ($this->_instance) { $emarking = $DB->get_record('emarking', array('id' => $this->_instance)); $exam = $DB->get_record("emarking_exams", array("emarking" => $emarking->id)); $examfilename = get_string('pdffileupdate', 'mod_emarking'); } else { $emarking = null; $exam = null; $examfilename = get_string('pdffile', 'mod_emarking'); } // Verifies that the logo image set in settings is copied to regular filearea. emarking_verify_logo(); // Calculates context for validating permissions. // If we have the module available, we use it, otherwise we fallback to course. $ctx = context_course::instance($COURSE->id); // Numbers 1 to 100. Used in pages and min and max grades. $numbers1to100 = $this->get_numbers_1_to_n(100); // Numbers from 0 to 2 for extra exams and sheets. $numbers1to3 = $this->get_numbers_1_to_n(3); // Today. $date = new DateTime(); $date->setTimestamp(usertime(time())); // Expected pages for submissions. $types = $this->get_types_available($emarking); // MARKING TYPE. $mform->addElement('select', 'type', get_string('markingtype', 'mod_emarking'), $types, array("onchange" => "show_full_form()")); $mform->addHelpButton('type', 'markingtype', 'mod_emarking'); $mform->setType('type', PARAM_INT); // EXAM NAME. $mform->addElement('text', 'name', get_string('name'), array('size' => '64')); $mform->setType('name', PARAM_CLEAN); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addHelpButton('name', 'examname', 'mod_emarking'); // PRINT CONFIGURATION. $mform->addElement('header', 'print', get_string("print", "mod_emarking")); // EXAM PDF FILE(S) OR PREVIOUSLY SENT EXAM. // Check if there are any exams with no emarking activity associated. $this->standard_intro_elements(get_string('examinfo', 'mod_emarking')); $mform->addElement('hidden', 'exam', $exam ? $exam->id : 0); $mform->setType('exam', PARAM_INT); // If we are editing. if (!$this->_instance || $exam && $exam->status < EMARKING_EXAM_SENT_TO_PRINT) { $mform->addElement('filemanager', 'exam_files', $examfilename, null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 10, 'accepted_types' => array('.pdf'), 'return_types' => FILE_INTERNAL)); $mform->setType('exam_files', PARAM_FILE); $mform->addHelpButton('exam_files', 'pdffile', 'mod_emarking'); // Exam date. $examdate = $this->get_exam_date($date); $mform->addElement('date_time_selector', 'examdate', get_string('examdate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $examdate->getTimestamp(), 'optional' => false), $instance['options']); $mform->addHelpButton('examdate', 'examdate', 'mod_emarking'); if (!$this->_instance) { // IMPORT ANSWERS AND RUBRIC FROM ANOTHER EMARKING ACTIVITY. $importoptions = $DB->get_records_select_menu('emarking', 'course = :course AND type IN (' . EMARKING_TYPE_ON_SCREEN_MARKING . ')', array('course' => $COURSE->id), 'name ASC', 'id, name'); if ($importoptions) { $importoptions[0] = get_string('donotimport', 'mod_emarking'); $mform->addElement('select', 'importemarking', get_string('importemarking', 'mod_emarking'), $importoptions); $mform->addHelpButton('importemarking', 'importemarking', 'mod_emarking'); $mform->setType('importemarking', PARAM_INT); $mform->setDefault('importemarking', 0); $mform->disabledIf('exam_files', 'importemarking', 'neq', 0); } } } else { if ($emarking && ($emarking->type == EMARKING_TYPE_ON_SCREEN_MARKING || $emarking->type == EMARKING_TYPE_PRINT_ONLY || $emarking->type == EMARKING_TYPE_PRINT_SCAN)) { $mform->addElement('hidden', 'examdate', $exam->examdate); $mform->setType('examdate', PARAM_RAW); // Add message explaining why they can't change files or dates anymore. $mform->addElement('static', 'examdownloaded', get_string("pdffile", "mod_emarking"), get_string("examalreadysent", "mod_emarking")); } } // Comment for printing. $mform->addElement('textarea', 'comment', get_string('comment', 'mod_emarking'), array('rows' => 5, 'cols' => 100, 'class' => 'smalltext')); $mform->addHelpButton('comment', 'comment', 'mod_emarking'); $mform->setDefault('comment', ''); $mform->setType('comment', PARAM_TEXT); // Personalized header (using QR). $mform->addElement('checkbox', 'headerqr', get_string('headerqr', 'mod_emarking'), null, array('onChange' => 'check_qr();')); $mform->setType('headerqr', PARAM_BOOL); $mform->addHelpButton('headerqr', 'headerqr', 'mod_emarking'); $mform->setDefault('headerqr', true); // Print students list. $mform->addElement('checkbox', 'printlist', get_string('printlist', 'mod_emarking')); $mform->setType('printlist', PARAM_BOOL); $mform->addHelpButton('printlist', 'printlist', 'mod_emarking'); $mform->setAdvanced('printlist'); $mform->setDefault('printlist', false); // Extra sheets per student. $mform->addElement('select', 'extrasheets', get_string('extrasheets', 'mod_emarking'), $numbers1to3, null); $mform->addHelpButton('extrasheets', 'extrasheets', 'mod_emarking'); $mform->setAdvanced('extrasheets'); // Extra students. $mform->addElement('select', 'extraexams', get_string('extraexams', 'mod_emarking'), $numbers1to3, null); $mform->addHelpButton('extraexams', 'extraexams', 'mod_emarking'); $mform->setAdvanced('extraexams'); // Print double sided. $mform->addElement('checkbox', 'printdoublesided', get_string('printdoublesided', 'mod_emarking')); $mform->setType('printdoublesided', PARAM_BOOL); $mform->addHelpButton('printdoublesided', 'printdoublesided', 'mod_emarking'); $mform->setDefault('printdoublesided', false); $mform->setAdvanced('printdoublesided'); // Obtain parallel courses. if ($parallelcheckboxes = $this->get_parallel_courses_checkboxes($mform)) { // If there's any parallel course we add the multicourse option. $mform->addGroup($parallelcheckboxes, 'multicourse', get_string('multicourse', 'mod_emarking'), array('<br/>'), true); $mform->addHelpButton('multicourse', 'multicourse', 'mod_emarking'); $mform->setAdvanced('multicourse'); $mform->addElement('button', 'selectall', get_string('selectall', 'mod_emarking'), array('onClick' => 'selectAllCheckboxes(this.form,true);')); $mform->setAdvanced('selectall'); $mform->addElement('button', 'deselectall', get_string('selectnone', 'mod_emarking'), array('onClick' => 'selectAllCheckboxes(this.form,false);')); $mform->setAdvanced('deselectall'); $this->extrascript .= "<script>function selectAllCheckboxes(form,checked) { " . "for (var i = 0; i < form.elements.length; i++ ) { " . " if (form.elements[i].type == 'checkbox' && form.elements[i].id.indexOf('multicourse') > 0) { " . " form.elements[i].checked = checked; " . " } " . "} " . "}</script>"; } $mform->addElement('hidden', 'action', 'uploadfile'); $mform->setType('action', PARAM_ALPHA); // Enrolment methods to include in printing. if ($enrolcheckboxes = $this->get_enrolment_checkboxes($mform)) { $mform->addGroup($enrolcheckboxes, 'enrolments', get_string('includeenrolments', 'mod_emarking'), array('<br/>'), true); $mform->addHelpButton('enrolments', 'enrolments', 'mod_emarking'); $mform->setAdvanced("enrolments"); } $mform->addElement('header', 'scan', get_string('scan', "mod_emarking")); // Due date settings. $mform->addElement('html', '<div id="scanisenabled">' . get_string('scanisenabled', 'mod_emarking') . '</div>'); $mform->addElement('html', '<div id="osmisenabled">' . get_string('osmisenabled', 'mod_emarking') . '</div>'); // MARKERS TRAINING. $mform->addElement('header', 'markerstraining', get_string('type_markers_training', 'mod_emarking')); $mform->setExpanded('markerstraining'); $delphidate = new DateTime(); $delphidate->setTimestamp(usertime(time())); $delphidate->modify("+1 week"); // Delphi agreement date settings. $mform->addElement('date_time_selector', 'firststagedate', get_string('firststagedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $delphidate->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('firststagedate', 'firststagedate', 'mod_emarking'); $mform->disabledIf('firststagedate', 'type', 'neq', '2'); $delphidate->modify("+1 week"); // Delphi agreement date settings. $mform->addElement('date_time_selector', 'secondstagedate', get_string('secondstagedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $delphidate->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('secondstagedate', 'secondstagedate', 'mod_emarking'); $mform->disabledIf('secondstagedate', 'type', 'neq', '2'); // Expected pages for submissions. $agreements = array("0" => get_string('agreementflexibility00', 'mod_emarking'), "0.2" => get_string('agreementflexibility20', 'mod_emarking'), "0.4" => get_string('agreementflexibility40', 'mod_emarking')); // MARKING TYPE. $mform->addElement('select', 'agreementflexibility', get_string('agreementflexibility', 'mod_emarking'), $agreements); $mform->addHelpButton('agreementflexibility', 'agreementflexibility', 'mod_emarking'); $mform->setType('agreementflexibility', PARAM_INT); $mform->addElement('header', 'osm', get_string('onscreenmarking', "mod_emarking")); // Students can see peers answers. $ynoptions = array(0 => get_string('no'), 1 => get_string('yespeerisanonymous', 'mod_emarking')); $mform->addElement('select', 'peervisibility', get_string('viewpeers', 'mod_emarking'), $ynoptions); $mform->addHelpButton('peervisibility', 'viewpeers', 'mod_emarking'); $mform->setDefault('peervisibility', 0); $mform->setType('peervisibility', PARAM_INT); $mform->disabledIf('peervisibility', 'type', 'eq', '2'); // Expected pages for submissions. $mform->addElement('hidden', 'totalpages', 0); $mform->setType('totalpages', PARAM_INT); // Anonymous eMarking setting. $anonymousoptions = array(EMARKING_ANON_STUDENT => get_string('studentanonymous_markervisible', 'mod_emarking'), EMARKING_ANON_BOTH => get_string('studentanonymous_markeranonymous', 'mod_emarking'), EMARKING_ANON_NONE => get_string('studentvisible_markervisible', 'mod_emarking'), EMARKING_ANON_MARKER => get_string('studentvisible_markeranonymous', 'mod_emarking')); $mform->addElement('select', 'anonymous', get_string('anonymous', 'mod_emarking'), $anonymousoptions); $mform->addHelpButton('anonymous', 'anonymous', 'mod_emarking'); $mform->setDefault('anonymous', 0); $mform->setType('anonymous', PARAM_INT); // Justice perception eMarking setting. $justiceoptions = array(EMARKING_JUSTICE_DISABLED => get_string('justicedisabled', 'mod_emarking'), EMARKING_JUSTICE_PER_SUBMISSION => get_string('justicepersubmission', 'mod_emarking'), EMARKING_JUSTICE_PER_CRITERION => get_string('justicepercriterion', 'mod_emarking')); $mform->addElement('select', 'justiceperception', get_string('justiceperception', 'mod_emarking'), $justiceoptions); $mform->addHelpButton('justiceperception', 'justiceperception', 'mod_emarking'); $mform->setDefault('justiceperception', 0); $mform->setType('justiceperception', PARAM_INT); $mform->disabledIf('justiceperception', 'type', 'eq', '2'); // Feedback $mform->addElement('text', 'keywords', get_string('keywords', 'mod_emarking'), array('size' => '64')); $mform->addHelpButton('keywords', 'keywords', 'mod_emarking'); $mform->setDefault('keywords', 'keyword1,keyword2,sentence1'); $mform->setType('keywords', PARAM_TEXT); $mform->disabledIf('keywords', 'type', 'eq', '2'); $mform->addElement('checkbox', 'linkrubric', get_string('linkrubric', 'mod_emarking')); $mform->addHelpButton('linkrubric', 'linkrubric', 'mod_emarking'); $mform->addElement('checkbox', 'collaborativefeatures', get_string('collaborativefeatures', 'mod_emarking')); $mform->addHelpButton('collaborativefeatures', 'collaborativefeatures', 'mod_emarking'); // Answer key $mform->addElement('filepicker', 'answerkeyfile', get_string('answerkeyfile', 'mod_emarking'), null, array('accepted_types' => array('.pdf'))); $mform->setAdvanced('answerkeyfile'); // Custom marks. $mform->addElement('textarea', 'custommarks', get_string('specificmarks', 'mod_emarking'), array('rows' => 5, 'cols' => 100, 'class' => 'smalltext')); $mform->addHelpButton('custommarks', 'specificmarks', 'mod_emarking'); $mform->setDefault('custommarks', ''); $mform->setType('custommarks', PARAM_TEXT); $mform->setAdvanced('custommarks'); // Due date settings. $mform->addElement('checkbox', 'enableduedate', get_string('enableduedate', 'mod_emarking')); $mform->setAdvanced('enableduedate'); $mform->addElement('date_time_selector', 'markingduedate', get_string('markingduedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('markingduedate', 'markingduedate', 'mod_emarking'); $mform->setAdvanced('markingduedate'); $mform->disabledIf('markingduedate', 'enableduedate'); // Regrade settings, dates and enabling. $mform->addElement('checkbox', 'regraderestrictdates', get_string('regraderestrictdates', 'mod_emarking')); $mform->addHelpButton('regraderestrictdates', 'regraderestrictdates', 'mod_emarking'); $mform->setAdvanced('regraderestrictdates'); $mform->addElement('date_time_selector', 'regradesopendate', get_string('regradesopendate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('regradesopendate', 'regradesopendate', 'mod_emarking'); $mform->setAdvanced('regradesopendate'); $mform->disabledIf('regradesopendate', 'regraderestrictdates'); $date->modify('+2 months'); $mform->addElement('date_time_selector', 'regradesclosedate', get_string('regradesclosedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('regradesclosedate', 'regradesclosedate', 'mod_emarking'); $mform->setAdvanced('regradesclosedate'); $mform->disabledIf('regradesclosedate', 'regraderestrictdates'); // Get all users with permission to grade in emarking. $chkmarkers = $this->get_markers_checkboxes($mform, $ctx); if ($chkmarkers) { // Due date settings. $mform->addElement("static", "qualitycontroldescription", get_string("qualitycontrol", "mod_emarking"), get_string("qualitycontroldescription", "mod_emarking")); $mform->setAdvanced('qualitycontroldescription'); $mform->addElement('checkbox', 'qualitycontrol', get_string('enablequalitycontrol', 'mod_emarking')); $mform->addHelpButton('qualitycontrol', 'enablequalitycontrol', 'mod_emarking'); $mform->setAdvanced('qualitycontrol'); $mform->disabledIf('qualitycontrol', 'type', 'eq', '2'); // Add markers group as checkboxes. $mform->addGroup($chkmarkers, 'markers', get_string('markersqualitycontrol', 'mod_emarking'), array('<br />'), false); $mform->addHelpButton('markers', 'markersqualitycontrol', 'mod_emarking'); $mform->setType('markers', PARAM_INT); $mform->disabledIf('markers', 'qualitycontrol'); $mform->setAdvanced('markers'); $mform->disabledIf('markers', 'type', 'eq', '2'); } // Add standard grading elements. $mform->addElement('header', 'modstandardgrade', get_string('grade')); // If supports grades and grades arent being handled via ratings. $mform->addElement('select', 'grademin', get_string('grademin', 'grades'), $numbers1to100); $mform->setDefault('grademin', 1); $mform->addElement('select', 'grade', get_string('grademax', 'grades'), $numbers1to100); $mform->setDefault('grade', 7); if (count($this->current->_advancedgradingdata['areas']) == 1) { // If there is just one gradable area (most cases), display just the selector // without its name to make UI simplier. $areadata = reset($this->current->_advancedgradingdata['areas']); $areaname = key($this->current->_advancedgradingdata['areas']); // Regrade settings, dates and enabling. $mform->addElement('hidden', 'advancedgradingmethod_' . $areaname, 'rubric'); $mform->setType('advancedgradingmethod_' . $areaname, PARAM_ALPHA); } else { throw new Exception("The emarking module should not define more than one grading area"); } $mform->addElement('select', 'gradecat', get_string('gradecategoryonmodform', 'grades'), grade_get_categories_menu($COURSE->id, $this->_outcomesused)); $mform->addHelpButton('gradecat', 'gradecategoryonmodform', 'grades'); $mform->setAdvanced('gradecat'); $mform->disabledIf('gradecat', 'type', 'eq', '2'); // Regrade settings, dates and enabling. $mform->addElement('checkbox', 'adjustslope', get_string('adjustslope', 'mod_emarking')); $mform->addHelpButton('adjustslope', 'adjustslope', 'mod_emarking'); $mform->setAdvanced('adjustslope'); $mform->disabledIf('adjustslope', 'type', 'eq', '2'); $mform->addElement('text', 'adjustslopegrade', get_string('adjustslopegrade', 'mod_emarking'), array('size' => '5')); $mform->setType('adjustslopegrade', PARAM_FLOAT); $mform->setDefault('adjustslopegrade', 0); $mform->addHelpButton('adjustslopegrade', 'adjustslopegrade', 'mod_emarking'); $mform->disabledIf('adjustslopegrade', 'adjustslope'); $mform->setAdvanced('adjustslopegrade'); $mform->disabledIf('adjustslopegrade', 'type', 'eq', '2'); $mform->addElement('text', 'adjustslopescore', get_string('adjustslopescore', 'mod_emarking'), array('size' => '5')); $mform->setType('adjustslopescore', PARAM_FLOAT); $mform->setDefault('adjustslopescore', 0); $mform->addHelpButton('adjustslopescore', 'adjustslopescore', 'mod_emarking'); $mform->disabledIf('adjustslopescore', 'adjustslope'); $mform->setAdvanced('adjustslopescore'); $mform->disabledIf('adjustslopescore', 'type', 'eq', '2'); // Add standard elements, common to all modules. $this->standard_coursemodule_elements(); // Regrade settings, dates and enabling. $mform->addElement('hidden', 'heartbeatenabled', true); $mform->setType('heartbeatenabled', PARAM_BOOL); $mform->addElement('hidden', 'downloadrubricpdf', true); $mform->setType('downloadrubricpdf', PARAM_BOOL); // If we are in editing mode we can not change the type anymore. if ($this->_instance) { $mform->freeze($this->get_elements_to_freeze($emarking, $exam, $mform)); } // Add standard buttons, common to all modules. $this->add_action_buttons(); }
/** * Defines forms elements */ public function definition() { global $COURSE, $DB, $CFG, $USER; $mform = $this->_form; $instance = $this->_customdata; // Exam id, in case we are in editing mode $examid = 0; $exam = null; $emarking = null; if ($this->_instance) { $emarking = $DB->get_record('emarking', array('id' => $this->_instance)); $exam = $DB->get_record("emarking_exams", array("emarking" => $emarking->id)); if ($exam) { $examid = $exam->id; } } // Verifies that the logo image set in settings is copied to regular filearea emarking_verify_logo(); // Calculates context for validating permissions // If we have the module available, we use it, otherwise we fallback to course $ctx = context_course::instance($COURSE->id); if ($this->current && $this->current->coursemodule) { $cm = get_coursemodule_from_id('emarking', $this->current->module, $COURSE->id); if ($cm) { $ctx = context_module::instance($cm->id); } } // Numbers 1 to 100. Used in pages and min and max grades $numbers1to100 = array(); for ($i = 0; $i <= 100; $i++) { $numbers1to100[] = $i; } // Numbers from 0 to 2 for extra exams and sheets $numberarray = array(); for ($j = 0; $j < 3; $j++) { $numberarray[$j] = $j; } // Today $date = new DateTime(); $date->setTimestamp(usertime(time())); // Expected pages for submissions $types = array(); if (!$this->_instance || $emarking && $emarking->type != EMARKING_TYPE_MARKER_TRAINING) { $types[EMARKING_TYPE_PRINT_ONLY] = get_string('type_print_only', 'mod_emarking'); $types[EMARKING_TYPE_PRINT_SCAN] = get_string('type_print_scan', 'mod_emarking'); $types[EMARKING_TYPE_NORMAL] = get_string('type_normal', 'mod_emarking'); } if (!$this->_instance || $emarking && $emarking->type == EMARKING_TYPE_MARKER_TRAINING) { $types[EMARKING_TYPE_MARKER_TRAINING] = get_string('type_markers_training', 'mod_emarking'); } // 3 => get_string('type_student_training', 'mod_emarking'), // 4 => get_string('type_peer_review', 'mod_emarking') // MARKING TYPE $mform->addElement('select', 'type', get_string('markingtype', 'mod_emarking'), $types, array("onchange" => "showFullForm()")); $mform->addHelpButton('type', 'markingtype', 'mod_emarking'); $mform->setType('type', PARAM_INT); // EXAM NAME $mform->addElement('text', 'name', get_string("examname", "mod_emarking"), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEAN); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addHelpButton('name', 'examname', 'mod_emarking'); if ($exam && $exam->status >= EMARKING_EXAM_SENT_TO_PRINT) { $mform->freeze('name'); } // PRINT CONFIGURATION $mform->addElement('header', 'print', get_string("print", "mod_emarking")); // EXAM PDF FILE(S) OR PREVIOUSLY SENT EXAM // Check if there are any exams with no emarking activity associated $availableexams = $DB->get_records("emarking_exams", array("course" => $COURSE->id, "emarking" => 0)); if ($CFG->version > 2014111008) { $this->standard_intro_elements(get_string('examinfo', 'mod_emarking')); } else { $this->add_intro_editor(); } $examsarray = array(); if ($availableexams && !$exam) { $examsarray[0] = get_string("no"); foreach ($availableexams as $avexam) { $examsarray[$avexam->id] = $avexam->name; } // Expected pages for submissions $mform->addElement('select', 'exam', get_string('orsentexam', 'mod_emarking'), $examsarray, array("onchange" => "previousExamUpdate();")); $mform->addHelpButton('exam', 'orsentexam', 'mod_emarking'); $mform->setDefault('exam', 0); $mform->setType('exam', PARAM_INT); $mform->disabledIf('exam', 'type', 'eq', '2'); } else { if ($exam) { $mform->addElement('hidden', 'exam', $exam->id); $mform->setType('exam', PARAM_INT); } else { $mform->addElement('hidden', 'exam', 0); $mform->setType('exam', PARAM_INT); } } $examfilename = get_string('pdffile', 'mod_emarking'); // If we are editing, we if ($exam && $exam->status < EMARKING_EXAM_SENT_TO_PRINT || !$this->_instance) { if ($this->_instance) { $examfilename = get_string('pdffileupdate', 'mod_emarking'); } else { $examfilename = get_string('pdffile', 'mod_emarking'); } $mform->addElement('filemanager', 'exam_files', $examfilename, null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 10, 'accepted_types' => array('.pdf'), 'return_types' => FILE_INTERNAL)); $mform->setType('exam_files', PARAM_FILE); $mform->addHelpButton('exam_files', 'pdffile', 'mod_emarking'); $examdate = new DateTime(); $examdate->setTimestamp(usertime(time())); $examdate->modify('+2 days'); $examdate->modify('+10 minutes'); $examw = date("w", $date->getTimestamp()); // Sundays and saturdays shouldn't be selected by default if ($examw == 0) { $examdate->modify('+1 days'); } if ($examw == 6) { $examdate->modify('+2 days'); } // Exam date $mform->addElement('date_time_selector', 'examdate', get_string('examdate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $examdate->getTimestamp(), 'optional' => false), $instance['options']); $mform->addHelpButton('examdate', 'examdate', 'mod_emarking'); if ($exam && $exam->status >= EMARKING_EXAM_SENT_TO_PRINT) { $mform->freeze('examdate'); $mform->freeze('exam_files'); } } else { // Add message explaining why they can't change files or dates anymore $mform->addElement('static', 'examdownloaded', get_string("pdffile", "mod_emarking"), get_string("examalreadysent", "mod_emarking")); } // Print students list $mform->addElement('checkbox', 'printlist', get_string('printlist', 'mod_emarking')); $mform->setType('printlist', PARAM_BOOL); $mform->addHelpButton('printlist', 'printlist', 'mod_emarking'); $mform->setAdvanced('printlist'); $mform->setDefault('printlist', false); // print double sided $mform->addElement('checkbox', 'printdoublesided', get_string('printdoublesided', 'mod_emarking')); $mform->setType('printdoublesided', PARAM_BOOL); $mform->addHelpButton('printdoublesided', 'printdoublesided', 'mod_emarking'); $mform->setDefault('printdoublesided', false); $mform->setAdvanced('printdoublesided'); // Personalized header (using QR) $mform->addElement('checkbox', 'headerqr', get_string('headerqr', 'mod_emarking')); $mform->setType('headerqr', PARAM_BOOL); $mform->addHelpButton('headerqr', 'headerqr', 'mod_emarking'); $mform->setDefault('headerqr', true); $mform->disabledIf('headerqr', 'printdoublesided', 'checked'); $mform->setAdvanced('headerqr'); // Extra sheets per student $mform->addElement('select', 'extrasheets', get_string('extrasheets', 'mod_emarking'), $numberarray, null); $mform->addHelpButton('extrasheets', 'extrasheets', 'mod_emarking'); $mform->setAdvanced('extrasheets'); // Extra students $mform->addElement('select', 'extraexams', get_string('extraexams', 'mod_emarking'), $numberarray, null); $mform->addHelpButton('extraexams', 'extraexams', 'mod_emarking'); $mform->setAdvanced('extraexams'); // Obtain parallel courses if ($parallelcourses = emarking_get_parallel_courses($COURSE)) { // Add a checkbox for each parallel course $checkboxes = array(); foreach ($parallelcourses as $course) { $checkboxes[] = $mform->createElement('checkbox', $course->shortname, null, $course->fullname, 'checked'); } // If there's any parallel course we add the multicourse option if (count($checkboxes) > 0) { $mform->addGroup($checkboxes, 'multicourse', get_string('multicourse', 'mod_emarking'), array('<br/>'), true); $mform->addHelpButton('multicourse', 'multicourse', 'mod_emarking'); $mform->setAdvanced('multicourse'); if ($examid == 0) { $mform->addElement('button', 'selectall', get_string('selectall', 'mod_emarking'), array('onClick' => 'selectAllCheckboxes(this.form,true);')); $mform->setAdvanced('selectall'); $mform->addElement('button', 'deselectall', get_string('selectnone', 'mod_emarking'), array('onClick' => 'selectAllCheckboxes(this.form,false);')); $mform->setAdvanced('deselectall'); } else { foreach ($parallelcourses as $cid => $course) { $selected = false; if ($examid > 0 && ($parallel = $DB->get_record('emarking_exams', array('file' => $exam->file, 'course' => $cid)))) { $selected = true; } $mform->setType("multicourse[{$course->shortname}]", PARAM_BOOL); if ($selected) { $mform->setDefault("multicourse[{$course->shortname}]", true); } } } } $this->extraScript .= "<script>function selectAllCheckboxes(form,checked) { " . "for (var i = 0; i < form.elements.length; i++ ) { " . " if (form.elements[i].type == 'checkbox' && form.elements[i].id.indexOf('multiseccion') > 0) { " . " form.elements[i].checked = checked; " . " } " . "} " . "}</script>"; } $mform->addElement('hidden', 'action', 'uploadfile'); $mform->setType('action', PARAM_ALPHA); // Enrolment methods to include in printing $enrolcheckboxes = array(); $enrolavailables = $this->getAvailableEnrolments(); foreach ($enrolavailables as $enrolment) { $enrolcheckboxes[] = $mform->createElement('checkbox', $enrolment, null, get_string('enrol' . $enrolment, 'mod_emarking'), 'checked'); } $mform->addGroup($enrolcheckboxes, 'enrolments', get_string('enrolments', 'mod_emarking'), array('<br/>'), true); $mform->addHelpButton('enrolments', 'enrolments', 'mod_emarking'); $mform->setAdvanced("enrolments"); // If we are editing, we use the previous enrolments if ($examid > 0 && isset($exam->enrolments)) { $enrolincludes = explode(",", $exam->enrolments); foreach ($enrolincludes as $enroldefault) { if (in_array($enroldefault, $enrolavailables)) { $mform->setDefault("enrolments[{$enroldefault}]", true); } } // If we are creating a new one, the default comes from the plugin settings } else { if ($CFG->emarking_enrolincludes && strlen($CFG->emarking_enrolincludes) > 1) { $enrolincludes = explode(",", $CFG->emarking_enrolincludes); foreach ($enrolincludes as $enroldefault) { if (in_array($enroldefault, $enrolavailables)) { $mform->setDefault("enrolments[{$enroldefault}]", true); } } } } $mform->addElement('header', 'scan', get_string('scan', "mod_emarking")); // Due date settings $mform->addElement('html', '<div id="scanisenabled">' . get_string('scanisenabled', 'mod_emarking') . '</div>'); $mform->addElement('html', '<div id="osmisenabled">' . get_string('osmisenabled', 'mod_emarking') . '</div>'); // MARKERS TRAINING $mform->addElement('header', 'markerstraining', get_string('type_markers_training', 'mod_emarking')); $mform->setExpanded('markerstraining'); $delphidate = new DateTime(); $delphidate->setTimestamp(usertime(time())); $delphidate->modify("+1 week"); // Delphi agreement date settings $mform->addElement('date_time_selector', 'firststagedate', get_string('firststagedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $delphidate->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('firststagedate', 'firststagedate', 'mod_emarking'); $mform->disabledIf('firststagedate', 'type', 'neq', '2'); $delphidate->modify("+1 week"); // Delphi agreement date settings $mform->addElement('date_time_selector', 'secondstagedate', get_string('secondstagedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $delphidate->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('secondstagedate', 'secondstagedate', 'mod_emarking'); $mform->disabledIf('secondstagedate', 'type', 'neq', '2'); // Expected pages for submissions $agreements = array("0" => get_string('agreementflexibility00', 'mod_emarking'), "0.2" => get_string('agreementflexibility20', 'mod_emarking'), "0.4" => get_string('agreementflexibility40', 'mod_emarking')); // 3 => get_string('type_student_training', 'mod_emarking'), // 4 => get_string('type_peer_review', 'mod_emarking') // MARKING TYPE $mform->addElement('select', 'agreementflexibility', get_string('agreementflexibility', 'mod_emarking'), $agreements); $mform->addHelpButton('agreementflexibility', 'agreementflexibility', 'mod_emarking'); $mform->setType('agreementflexibility', PARAM_INT); $mform->addElement('header', 'osm', get_string('onscreenmarking', "mod_emarking")); // Students can see peers answers $ynoptions = array(0 => get_string('no'), 1 => get_string('yespeerisanonymous', 'mod_emarking')); $mform->addElement('select', 'peervisibility', get_string('viewpeers', 'mod_emarking'), $ynoptions); $mform->addHelpButton('peervisibility', 'viewpeers', 'mod_emarking'); $mform->setDefault('peervisibility', 0); $mform->setType('peervisibility', PARAM_INT); $mform->disabledIf('peervisibility', 'type', 'eq', '2'); // Expected pages for submissions $mform->addElement('hidden', 'totalpages', 0); $mform->setType('totalpages', PARAM_INT); // Anonymous eMarking setting $anonymousoptions = array(EMARKING_ANON_STUDENT => get_string('studentanonymous_markervisible', 'mod_emarking'), EMARKING_ANON_BOTH => get_string('studentanonymous_markeranonymous', 'mod_emarking'), EMARKING_ANON_NONE => get_string('studentvisible_markervisible', 'mod_emarking'), EMARKING_ANON_MARKER => get_string('studentvisible_markeranonymous', 'mod_emarking')); if (has_capability('mod/emarking:manageanonymousmarking', $ctx)) { $mform->addElement('select', 'anonymous', get_string('anonymous', 'mod_emarking'), $anonymousoptions); $mform->addHelpButton('anonymous', 'anonymous', 'mod_emarking'); } else { $mform->addElement('hidden', 'anonymous'); } $mform->setDefault('anonymous', 0); $mform->setType('anonymous', PARAM_INT); // Justice perception eMarking setting $justiceoptions = array(EMARKING_JUSTICE_DISABLED => get_string('justicedisabled', 'mod_emarking'), EMARKING_JUSTICE_PER_SUBMISSION => get_string('justicepersubmission', 'mod_emarking'), EMARKING_JUSTICE_PER_CRITERION => get_string('justicepercriterion', 'mod_emarking')); $mform->addElement('select', 'justiceperception', get_string('justiceperception', 'mod_emarking'), $justiceoptions); $mform->addHelpButton('justiceperception', 'justiceperception', 'mod_emarking'); $mform->setDefault('justiceperception', 0); $mform->setType('justiceperception', PARAM_INT); $mform->disabledIf('justiceperception', 'type', 'eq', '2'); $mform->addElement('checkbox', 'linkrubric', get_string('linkrubric', 'mod_emarking')); $mform->addHelpButton('linkrubric', 'linkrubric', 'mod_emarking'); $mform->addElement('checkbox', 'collaborativefeatures', get_string('collaborativefeatures', 'mod_emarking')); $mform->addHelpButton('collaborativefeatures', 'collaborativefeatures', 'mod_emarking'); // Custom marks if (has_capability('mod/emarking:managespecificmarks', $ctx)) { $mform->addElement('textarea', 'custommarks', get_string('specificmarks', 'mod_emarking'), array('rows' => 5, 'cols' => 100, 'class' => 'smalltext')); $mform->addHelpButton('custommarks', 'specificmarks', 'mod_emarking'); } else { $mform->addElement('hidden', 'custommarks'); } $mform->setDefault('custommarks', ''); $mform->setType('custommarks', PARAM_TEXT); $mform->setAdvanced('custommarks'); // Due date settings $mform->addElement('checkbox', 'enableduedate', get_string('enableduedate', 'mod_emarking')); $mform->setAdvanced('enableduedate'); $mform->addElement('date_time_selector', 'markingduedate', get_string('markingduedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('markingduedate', 'markingduedate', 'mod_emarking'); $mform->setAdvanced('markingduedate'); $mform->disabledIf('markingduedate', 'enableduedate'); // Regrade settings, dates and enabling $mform->addElement('checkbox', 'regraderestrictdates', get_string('regraderestrictdates', 'mod_emarking')); $mform->addHelpButton('regraderestrictdates', 'regraderestrictdates', 'mod_emarking'); $mform->setAdvanced('regraderestrictdates'); $mform->addElement('date_time_selector', 'regradesopendate', get_string('regradesopendate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('regradesopendate', 'regradesopendate', 'mod_emarking'); $mform->setAdvanced('regradesopendate'); $mform->disabledIf('regradesopendate', 'regraderestrictdates'); $date->modify('+2 months'); $mform->addElement('date_time_selector', 'regradesclosedate', get_string('regradesclosedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('regradesclosedate', 'regradesclosedate', 'mod_emarking'); $mform->setAdvanced('regradesclosedate'); $mform->disabledIf('regradesclosedate', 'regraderestrictdates'); // Due date settings $mform->addElement("static", "qualitycontroldescription", get_string("qualitycontrol", "mod_emarking"), get_string("qualitycontroldescription", "mod_emarking")); $mform->addElement('checkbox', 'qualitycontrol', get_string('enablequalitycontrol', 'mod_emarking')); $mform->addHelpButton('qualitycontrol', 'enablequalitycontrol', 'mod_emarking'); $mform->setAdvanced('qualitycontrol'); $mform->disabledIf('qualitycontrol', 'type', 'eq', '2'); // Get all users with permission to grade in emarking $markers = get_enrolled_users($ctx, 'mod/emarking:grade'); $chkmarkers = array(); foreach ($markers as $marker) { $chkmarkers[] = $mform->createElement('checkbox', 'marker-' . $marker->id, null, $marker->firstname . " " . $marker->lastname); } // Add markers group as checkboxes $mform->addGroup($chkmarkers, 'markers', get_string('markersqualitycontrol', 'mod_emarking'), array('<br />'), false); $mform->addHelpButton('markers', 'markersqualitycontrol', 'mod_emarking'); $mform->setType('markers', PARAM_INT); $mform->disabledIf('markers', 'qualitycontrol'); $mform->setAdvanced('markers'); $mform->disabledIf('markers', 'type', 'eq', '2'); // ------------------------------------------------------------------------------- // add standard grading elements... if (!$this->_features->rating || $this->_features->gradecat) { $mform->addElement('header', 'modstandardgrade', get_string('grade')); } // if supports grades and grades arent being handled via ratings if (!$this->_features->rating) { $mform->addElement('select', 'grademin', get_string('grademin', 'grades'), $numbers1to100); $mform->setDefault('grademin', 1); $mform->addElement('select', 'grade', get_string('grademax', 'grades'), $numbers1to100); $mform->setDefault('grade', 7); } if ($this->_features->advancedgrading and !empty($this->current->_advancedgradingdata['methods']) and !empty($this->current->_advancedgradingdata['areas'])) { if (count($this->current->_advancedgradingdata['areas']) == 1) { // if there is just one gradable area (most cases), display just the selector // without its name to make UI simplier $areadata = reset($this->current->_advancedgradingdata['areas']); $areaname = key($this->current->_advancedgradingdata['areas']); // Regrade settings, dates and enabling $mform->addElement('hidden', 'advancedgradingmethod_' . $areaname, 'rubric'); $mform->setType('advancedgradingmethod_' . $areaname, PARAM_ALPHA); /* * $mform->addElement('select', 'advancedgradingmethod_' . $areaname, get_string('gradingmethod', 'core_grading'), array( * null => "sIMPLE GRADING", * 'rubric' => "Rubrica" * )); * $mform->addHelpButton('advancedgradingmethod_' . $areaname, 'gradingmethod', 'core_grading'); * $mform->setAdvanced('advancedgradingmethod_' . $areaname); * $mform->disabledIf('advancedgradingmethod_' . $areaname, 'type', 'eq', '2'); */ } else { throw new Exception("The emarking module should not define more than one grading area"); } } if ($this->_features->gradecat) { $mform->addElement('select', 'gradecat', get_string('gradecategoryonmodform', 'grades'), grade_get_categories_menu($COURSE->id, $this->_outcomesused)); $mform->addHelpButton('gradecat', 'gradecategoryonmodform', 'grades'); $mform->setAdvanced('gradecat'); $mform->disabledIf('gradecat', 'type', 'eq', '2'); } // Regrade settings, dates and enabling $mform->addElement('checkbox', 'adjustslope', get_string('adjustslope', 'mod_emarking')); $mform->addHelpButton('adjustslope', 'adjustslope', 'mod_emarking'); $mform->setAdvanced('adjustslope'); $mform->disabledIf('adjustslope', 'type', 'eq', '2'); $mform->addElement('text', 'adjustslopegrade', get_string('adjustslopegrade', 'mod_emarking'), array('size' => '5')); $mform->setType('adjustslopegrade', PARAM_FLOAT); $mform->setDefault('adjustslopegrade', 0); $mform->addHelpButton('adjustslopegrade', 'adjustslopegrade', 'mod_emarking'); $mform->disabledIf('adjustslopegrade', 'adjustslope'); $mform->setAdvanced('adjustslopegrade'); $mform->disabledIf('adjustslopegrade', 'type', 'eq', '2'); $mform->addElement('text', 'adjustslopescore', get_string('adjustslopescore', 'mod_emarking'), array('size' => '5')); $mform->setType('adjustslopescore', PARAM_FLOAT); $mform->setDefault('adjustslopescore', 0); $mform->addHelpButton('adjustslopescore', 'adjustslopescore', 'mod_emarking'); $mform->disabledIf('adjustslopescore', 'adjustslope'); $mform->setAdvanced('adjustslopescore'); $mform->disabledIf('adjustslopescore', 'type', 'eq', '2'); // ------------------------------------------------------------------------------- // add standard elements, common to all modules $this->standard_coursemodule_elements(); // Regrade settings, dates and enabling $mform->addElement('hidden', 'heartbeatenabled', true); $mform->setType('heartbeatenabled', PARAM_BOOL); $mform->addElement('hidden', 'downloadrubricpdf', true); $mform->setType('downloadrubricpdf', PARAM_BOOL); // If we are in editing mode we can not change the type anymore if ($this->_instance) { $freeze = array(); if ($emarking->type == EMARKING_TYPE_NORMAL) { $freeze[] = 'qualitycontrol'; } if ($exam && $exam->status >= EMARKING_EXAM_SENT_TO_PRINT) { $freeze[] = 'printlist'; $freeze[] = 'printdoublesided'; $freeze[] = 'headerqr'; $freeze[] = 'extrasheets'; $freeze[] = 'extraexams'; $freeze[] = 'enrolments'; if ($mform->elementExists('multicourse')) { $freeze[] = 'multicourse'; } } $mform->freeze($freeze); } // ------------------------------------------------------------------------------- // add standard buttons, common to all modules $this->add_action_buttons(); }
function definition() { global $DB, $CFG; // Verifies that the global configurated logo exists, and if it's new it copies it // to a normal space within Moodle's filesystem emarking_verify_logo(); $mform = $this->_form; $instance = $this->_customdata; $cmid = $instance['cmid']; $courseid = $instance['courseid']; $examid = $instance['examid']; // Multicourse // Get the course record to get the shortname $course = $DB->get_record('course', array('id' => $courseid)); $exam = $DB->get_record('emarking_exams', array('id' => $examid)); // Exam id goes hidden $mform->addElement('hidden', 'id', $examid); $mform->setType('id', PARAM_INT); // Course module id goes hidden as well $mform->addElement('hidden', 'cm', $cmid); $mform->setType('cm', PARAM_INT); // Course id goes hidden as well $mform->addElement('hidden', 'course', $courseid); $mform->setType('course', PARAM_INT); // Exam totalpages goes hidden as well $mform->addElement('hidden', 'totalpages'); $mform->setType('totalpages', PARAM_INT); $mform->addElement('header', 'exam_title', get_string('examinfo', 'mod_emarking')); $mform->addElement('static', 'coursename', get_string('course'), $course->fullname); // Exam name $mform->addElement('text', 'name', get_string('examname', 'mod_emarking')); $mform->addRule('name', get_string('required'), 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 50), 'maxlength', 50, 'client'); $mform->setType('name', PARAM_TEXT); $mform->addHelpButton('name', 'examname', 'mod_emarking'); $date = new DateTime(); $date->setTimestamp(usertime(time())); $date->modify('+2 days'); $date->modify('+10 minutes'); // Exam date $mform->addElement('date_time_selector', 'examdate', get_string('examdate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), $instance['options']); $mform->addRule('examdate', get_string('filerequiredpdf', 'mod_emarking'), 'required', null, 'client'); $mform->addHelpButton('examdate', 'examdate', 'mod_emarking'); // Exam PDF file $mform->addElement('filemanager', 'exam_files', get_string('pdffile', 'mod_emarking'), null, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 10, 'accepted_types' => array('.pdf'), 'return_types' => FILE_INTERNAL)); //if ($examid == 0) //se omite el if, ya que al editar el examen emite error $mform->addRule('exam_files', get_string('filerequiredtosendnewprintorder', 'mod_emarking'), 'required', null, 'client'); $mform->setType('exam_files', PARAM_FILE); $mform->addHelpButton('exam_files', 'pdffile', 'mod_emarking'); // eMarking configuration $mform->addElement('header', 'emarking_title', get_string('emarking', 'mod_emarking')); // Personalized header (using QR) $mform->addElement('checkbox', 'headerqr', get_string('headerqr', 'mod_emarking')); // $mform->addElement('hidden','headerqr'); $mform->setType('headerqr', PARAM_BOOL); $mform->addHelpButton('headerqr', 'headerqr', 'mod_emarking'); $mform->setDefault('headerqr', true); // Enrolment methods to include in printing $enrolcheckboxes = array(); $enrolavailables = array(); $enrolments = enrol_get_instances($courseid, true); $flag = 0; foreach ($enrolments as $enrolment) { if ($enrolment->enrol == "meta") { if ($flag == 0) { $flag = 1; $enrolavailables[] = $enrolment->enrol; $enrolcheckboxes[] = $mform->createElement('checkbox', $enrolment->enrol, null, get_string('enrol' . $enrolment->enrol, 'mod_emarking'), 'checked'); } } else { $enrolavailables[] = $enrolment->enrol; $enrolcheckboxes[] = $mform->createElement('checkbox', $enrolment->enrol, null, get_string('enrol' . $enrolment->enrol, 'mod_emarking'), 'checked'); } } $mform->addGroup($enrolcheckboxes, 'enrolments', get_string('includestudentsinexam', 'mod_emarking'), array('<br/>'), true); if ($CFG->emarking_enrolincludes && strlen($CFG->emarking_enrolincludes) > 1) { $enrolincludes = explode(",", $CFG->emarking_enrolincludes); foreach ($enrolincludes as $enroldefault) { if (in_array($enroldefault, $enrolavailables)) { $mform->setDefault("enrolments[{$enroldefault}]", true); } } } if ($CFG->emarking_enableprintingrandom) { // Print Random $mform->addElement('checkbox', 'printrandom', get_string('printrandom', 'mod_emarking')); $mform->setType('printrandom', PARAM_BOOL); $mform->addHelpButton('printrandom', 'printrandom', 'mod_emarking'); $mform->setDefault('printrandom', false); } if ($CFG->emarking_enableprintinglist) { // Print Random $mform->addElement('checkbox', 'printlist', get_string('printlist', 'mod_emarking')); $mform->setType('printlist', PARAM_BOOL); $mform->addHelpButton('printlist', 'printlist', 'mod_emarking'); $mform->setDefault('printlist', false); } // Copy center instructions $mform->addElement('header', 'exam_title', get_string('copycenterinstructions', 'mod_emarking')); // Numbers from 0 to 14 for extra exams and sheets $numberarray = array(); for ($j = 0; $j < 3; $j++) { $numberarray[$j] = $j; } // Extra sheets per student $mform->addElement('select', 'extrasheets', get_string('extrasheets', 'mod_emarking'), $numberarray, null); $mform->addHelpButton('extrasheets', 'extrasheets', 'mod_emarking'); // Extra students $mform->addElement('select', 'extraexams', get_string('extraexams', 'mod_emarking'), $numberarray, null); $mform->addHelpButton('extraexams', 'extraexams', 'mod_emarking'); // print double sided // $mform->addElement('checkbox','printdoublesided',get_string('printdoublesided', 'mod_emarking'))); $mform->addElement('hidden', 'printdoublesided'); $mform->setType('printdoublesided', PARAM_BOOL); // $mform->addHelpButton('printdoublesided', 'printdoublesided', 'mod_emarking'); $mform->setDefault('printdoublesided', false); // Obtain parallel courses if ($seccionesparalelas = emarking_get_parallel_courses($course, null, $CFG->emarking_parallelregex)) { // Add a checkbox for each parallel course $checkboxes = array(); foreach ($seccionesparalelas as $cid => $course) { $checkboxes[] = $mform->createElement('checkbox', $course->shortname, null, $course->fullname, 'checked'); } // If there's any parallel course we add the multicourse option if (count($checkboxes) > 0) { $mform->addGroup($checkboxes, 'multisecciones', get_string('multicourse', 'mod_emarking'), array('<br/>'), true); $mform->addHelpButton('multisecciones', 'multicourse', 'mod_emarking'); if ($examid == 0) { $mform->addElement('button', 'selectall', get_string('selectall', 'mod_emarking'), array('onClick' => 'selectAllCheckboxes(this.form,true);')); $mform->addElement('button', 'deselectall', get_string('selectnone', 'mod_emarking'), array('onClick' => 'selectAllCheckboxes(this.form,false);')); } else { foreach ($seccionesparalelas as $cid => $course) { $selected = false; if ($examid > 0 && ($parallel = $DB->get_record('emarking_exams', array('file' => $exam->file, 'course' => $cid)))) { $selected = true; } $mform->setType("multisecciones[{$course->shortname}]", PARAM_BOOL); if ($selected) { $mform->setDefault("multisecciones[{$course->shortname}]", true); } } } } $this->extraScript .= "<script>function selectAllCheckboxes(form,checked) { " . "for (var i = 0; i < form.elements.length; i++ ) { " . " if (form.elements[i].type == 'checkbox' && form.elements[i].id.indexOf('multiseccion') > 0) { " . " form.elements[i].checked = checked; " . " } " . "} " . "}</script>"; } $mform->addElement('hidden', 'action', 'uploadfile'); $mform->setType('action', PARAM_ALPHA); // buttons $this->add_action_buttons(true, get_string('submit')); }
/** * Defines forms elements */ public function definition() { global $COURSE, $DB, $CFG; $mform = $this->_form; // Verifies that the logo image set in settings is copied to regular filearea emarking_verify_logo(); // Calculates context for validating permissions // If we have the module available, we use it, otherwise we fallback to course $ctx = context_course::instance($COURSE->id); if ($this->current && $this->current->coursemodule) { $cm = get_coursemodule_from_id('emarking', $this->current->module, $COURSE->id); if ($cm) { $ctx = context_module::instance($cm->id); } } // ------------------------------------------------------------------------------- // Adding the "general" fieldset, where all the common settings are showed $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field $mform->addElement('text', 'name', get_string('name'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEAN); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addHelpButton('name', 'modulename', 'mod_emarking'); // Adding the standard "intro" and "introformat" fields $this->add_intro_editor(); // ------------------------------------------------------------------------------- // Adding modules for eMarking process $date = new DateTime(); $date->setTimestamp(usertime(time())); // Due date settings $mform->addElement('checkbox', 'enableduedate', get_string('enableduedate', 'mod_emarking')); $mform->addElement('date_time_selector', 'markingduedate', get_string('markingduedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('markingduedate', 'markingduedate', 'mod_emarking'); $mform->disabledIf('markingduedate', 'enableduedate'); // Expected pages for submissions $pages = array(); for ($i = 0; $i <= 100; $i++) { $pages[] = $i; } $mform->addElement('select', 'totalpages', get_string('totalpages', 'mod_emarking'), $pages); $mform->addHelpButton('totalpages', 'totalpages', 'mod_emarking'); $mform->setDefault('totalpages', 0); $mform->setType('totalpages', PARAM_INT); // Anonymous eMarking setting $ynoptions = array(0 => get_string('no'), 1 => get_string('yes')); if (has_capability('mod/emarking:manageanonymousmarking', $ctx)) { $mform->addElement('select', 'anonymous', get_string('anonymous', 'mod_emarking'), $ynoptions); $mform->addHelpButton('anonymous', 'anonymous', 'mod_emarking'); } else { $mform->addElement('hidden', 'anonymous'); } $mform->setDefault('anonymous', 0); $mform->setType('anonymous', PARAM_INT); // Students can see peers answers $mform->addElement('select', 'peervisibility', get_string('viewpeers', 'mod_emarking'), $ynoptions); $mform->addHelpButton('peervisibility', 'viewpeers', 'mod_emarking'); $mform->setDefault('peervisibility', 0); $mform->setType('peervisibility', PARAM_INT); // Custom marks if (has_capability('mod/emarking:managespecificmarks', $ctx)) { $mform->addElement('textarea', 'custommarks', get_string('specificmarks', 'mod_emarking'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext')); $mform->addHelpButton('custommarks', 'specificmarks', 'mod_emarking'); } else { $mform->addElement('hidden', 'custommarks'); } $mform->setDefault('custommarks', ''); $mform->setType('custommarks', PARAM_TEXT); // Regrade settings, dates and enabling $mform->addElement('checkbox', 'regraderestrictdates', get_string('regraderestrictdates', 'mod_emarking')); $mform->addHelpButton('regraderestrictdates', 'regraderestrictdates', 'mod_emarking'); $mform->addElement('date_time_selector', 'regradesopendate', get_string('regradesopendate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('regradesopendate', 'regradesopendate', 'mod_emarking'); $mform->disabledIf('regradesopendate', 'regraderestrictdates'); $date->modify('+2 months'); $mform->addElement('date_time_selector', 'regradesclosedate', get_string('regradesclosedate', 'mod_emarking'), array('startyear' => date('Y'), 'stopyear' => date('Y') + 1, 'step' => 5, 'defaulttime' => $date->getTimestamp(), 'optional' => false), null); $mform->addHelpButton('regradesclosedate', 'regradesclosedate', 'mod_emarking'); $mform->disabledIf('regradesclosedate', 'regraderestrictdates'); // ------------------------------------------------------------------------------- // add standard elements, common to all modules $this->standard_coursemodule_elements(); // ------------------------------------------------------------------------------- // add standard grading elements... if (!$this->_features->rating || $this->_features->gradecat) { $mform->addElement('header', 'modstandardgrade', get_string('grade')); } $grades = array(); for ($i = 0; $i <= 100; $i++) { $grades[] = $i; } // if supports grades and grades arent being handled via ratings if (!$this->_features->rating) { $mform->addElement('select', 'grade', get_string('grademax', 'grades'), $pages); $mform->setDefault('grade', 7); $mform->addElement('select', 'grademin', get_string('grademin', 'grades'), $pages); $mform->setDefault('grademin', 1); } if ($this->_features->advancedgrading and !empty($this->current->_advancedgradingdata['methods']) and !empty($this->current->_advancedgradingdata['areas'])) { if (count($this->current->_advancedgradingdata['areas']) == 1) { // if there is just one gradable area (most cases), display just the selector // without its name to make UI simplier $areadata = reset($this->current->_advancedgradingdata['areas']); $areaname = key($this->current->_advancedgradingdata['areas']); $mform->addElement('select', 'advancedgradingmethod_' . $areaname, get_string('gradingmethod', 'core_grading'), array('rubric' => "Rubrica")); $mform->addHelpButton('advancedgradingmethod_' . $areaname, 'gradingmethod', 'core_grading'); } else { throw new Exception("The emarking module should not define more than one grading area"); } } if ($this->_features->gradecat) { $mform->addElement('select', 'gradecat', get_string('gradecategoryonmodform', 'grades'), grade_get_categories_menu($COURSE->id, $this->_outcomesused)); $mform->addHelpButton('gradecat', 'gradecategoryonmodform', 'grades'); } // Regrade settings, dates and enabling $mform->addElement('checkbox', 'adjustslope', get_string('adjustslope', 'mod_emarking')); $mform->addHelpButton('adjustslope', 'adjustslope', 'mod_emarking'); $mform->addElement('select', 'adjustslopegrade', get_string('adjustslopegrade', 'mod_emarking'), $grades); $mform->setDefault('adjustslopegrade', 0); $mform->addHelpButton('adjustslopegrade', 'adjustslopegrade', 'mod_emarking'); $mform->disabledIf('adjustslopegrade', 'adjustslope'); $mform->addElement('text', 'adjustslopescore', get_string('adjustslopescore', 'mod_emarking'), array('size' => '64')); $mform->setType('adjustslopescore', PARAM_FLOAT); $mform->setDefault('adjustslopescore', null); $mform->addHelpButton('adjustslopescore', 'adjustslopescore', 'mod_emarking'); $mform->disabledIf('adjustslopescore', 'adjustslope'); // ------------------------------------------------------------------------------- // Experimental features $mform->addElement('header', 'experimental', get_string('experimental', 'mod_emarking')); // Regrade settings, dates and enabling $mform->addElement('checkbox', 'heartbeatenabled', get_string('heartbeatenabled', 'mod_emarking')); $mform->addHelpButton('heartbeatenabled', 'heartbeatenabled', 'mod_emarking'); $mform->addElement('checkbox', 'downloadrubricpdf', get_string('downloadrubricpdf', 'mod_emarking')); $mform->addHelpButton('downloadrubricpdf', 'downloadrubricpdf', 'mod_emarking'); $mform->addElement('checkbox', 'linkrubric', get_string('linkrubric', 'mod_emarking')); $mform->addHelpButton('linkrubric', 'linkrubric', 'mod_emarking'); $mform->addElement('checkbox', 'collaborativefeatures', get_string('collaborativefeatures', 'mod_emarking')); $mform->addHelpButton('collaborativefeatures', 'collaborativefeatures', 'mod_emarking'); $mform->addElement('checkbox', 'experimentalgroups', get_string('experimentalgroups', 'mod_emarking')); $mform->addHelpButton('experimentalgroups', 'experimentalgroups', 'mod_emarking'); // ------------------------------------------------------------------------------- // add standard buttons, common to all modules $this->add_action_buttons(); }