ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/imscp/mod_form.php000064400000006534152267012350023101 0ustar00. /** * This file contains the forms to create and edit an instance of this module * * @package mod_imscp * @copyright 2009 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/course/moodleform_mod.php'); require_once($CFG->libdir.'/filelib.php'); /** * IMS CP configuration form * * @package mod_imscp * @copyright 2009 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_imscp_mod_form extends moodleform_mod { /** * Define the form - called by parent constructor */ public function definition() { global $CFG, $DB; $mform = $this->_form; $config = get_config('imscp'); // Title and description. $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size' => '48')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(); // IMS-CP file upload. $mform->addElement('header', 'content', get_string('contentheader', 'imscp')); $mform->setExpanded('content', true); $mform->addElement('filepicker', 'package', get_string('packagefile', 'imscp'), null, ['accepted_types' => ['application/zip', '.imscc']]); $options = array('-1' => get_string('all'), '0' => get_string('no'), '1' => '1', '2' => '2', '5' => '5', '10' => '10', '20' => '20'); $mform->addElement('select', 'keepold', get_string('keepold', 'imscp'), $options); $mform->setDefault('keepold', $config->keepold); $mform->setAdvanced('keepold', $config->keepold_adv); $this->standard_coursemodule_elements(); $this->add_action_buttons(); } /** * Perform minimal validation on the settings form * @param array $data * @param array $files */ public function validation($data, $files) { if ($errors = parent::validation($data, $files)) { return $errors; } if (!$this->get_draft_files('package')) { if (!$this->current->instance) { $errors['package'] = get_string('required'); return $errors; } } return $errors; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/url/mod_form.php000064400000021174152267015260022570 0ustar00. /** * URL configuration form * * @package mod_url * @copyright 2009 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; require_once ($CFG->dirroot.'/course/moodleform_mod.php'); require_once($CFG->dirroot.'/mod/url/locallib.php'); class mod_url_mod_form extends moodleform_mod { function definition() { global $CFG, $DB; $mform = $this->_form; $config = get_config('url'); //------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'48')); $mform->addHelpButton('name', 'name', 'url'); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size'=>'60'), array('usefilepicker'=>true)); $mform->setType('externalurl', PARAM_RAW_TRIMMED); $mform->addRule('externalurl', null, 'required', null, 'client'); $this->standard_intro_elements(); $element = $mform->getElement('introeditor'); $attributes = $element->getAttributes(); $attributes['rows'] = 5; $element->setAttributes($attributes); //------------------------------------------------------- $mform->addElement('header', 'optionssection', get_string('appearance')); if ($this->current->instance) { $options = resourcelib_get_displayoptions(explode(',', $config->displayoptions), $this->current->display); } else { $options = resourcelib_get_displayoptions(explode(',', $config->displayoptions)); } if (count($options) == 1) { $mform->addElement('hidden', 'display'); $mform->setType('display', PARAM_INT); reset($options); $mform->setDefault('display', key($options)); } else { $mform->addElement('select', 'display', get_string('displayselect', 'url'), $options); $mform->setDefault('display', $config->display); $mform->addHelpButton('display', 'displayselect', 'url'); } if (array_key_exists(RESOURCELIB_DISPLAY_POPUP, $options)) { $mform->addElement('text', 'popupwidth', get_string('popupwidth', 'url'), array('size'=>3)); if (count($options) > 1) { $mform->hideIf('popupwidth', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP); } $mform->setType('popupwidth', PARAM_INT); $mform->setDefault('popupwidth', $config->popupwidth); $mform->addElement('text', 'popupheight', get_string('popupheight', 'url'), array('size'=>3)); if (count($options) > 1) { $mform->hideIf('popupheight', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP); } $mform->setType('popupheight', PARAM_INT); $mform->setDefault('popupheight', $config->popupheight); } if (array_key_exists(RESOURCELIB_DISPLAY_AUTO, $options) or array_key_exists(RESOURCELIB_DISPLAY_EMBED, $options) or array_key_exists(RESOURCELIB_DISPLAY_FRAME, $options)) { $mform->addElement('checkbox', 'printintro', get_string('printintro', 'url')); $mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_POPUP); $mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_OPEN); $mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_NEW); $mform->setDefault('printintro', $config->printintro); } //------------------------------------------------------- if ($config->allowvariables) { $mform->addElement('header', 'parameterssection', get_string('parametersheader', 'url')); $mform->addElement('static', 'parametersinfo', '', get_string('parametersheader_help', 'url')); if (empty($this->current->parameters)) { $parcount = 5; } else { $parcount = 5 + count((array)unserialize_array($this->current->parameters)); $parcount = ($parcount > 100) ? 100 : $parcount; } $options = url_get_variable_options($config); for ($i = 0; $i < $parcount; $i++) { $parameter = "parameter_$i"; $variable = "variable_$i"; $pargroup = "pargoup_$i"; $group = [ $mform->createElement('text', $parameter, '', ['size' => '12']), $mform->createElement('selectgroups', $variable, '', $options), ]; $mform->addGroup($group, $pargroup, get_string('parameterinfo', 'url'), ' ', false); $mform->setType($parameter, PARAM_RAW); } } //------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------- $this->add_action_buttons(); } function data_preprocessing(&$default_values) { if (!empty($default_values['displayoptions'])) { $displayoptions = (array) unserialize_array($default_values['displayoptions']); if (isset($displayoptions['printintro'])) { $default_values['printintro'] = $displayoptions['printintro']; } if (!empty($displayoptions['popupwidth'])) { $default_values['popupwidth'] = $displayoptions['popupwidth']; } if (!empty($displayoptions['popupheight'])) { $default_values['popupheight'] = $displayoptions['popupheight']; } } if (!empty($default_values['parameters'])) { $parameters = (array) unserialize_array($default_values['parameters']); $i = 0; foreach ($parameters as $parameter=>$variable) { $default_values['parameter_'.$i] = $parameter; $default_values['variable_'.$i] = $variable; $i++; } } } function validation($data, $files) { $errors = parent::validation($data, $files); // Validating Entered url, we are looking for obvious problems only, // teachers are responsible for testing if it actually works. // This is not a security validation!! Teachers are allowed to enter "javascript:alert(666)" for example. // NOTE: do not try to explain the difference between URL and URI, people would be only confused... if (!empty($data['externalurl'])) { $url = $data['externalurl']; if (preg_match('|^/|', $url)) { // links relative to server root are ok - no validation necessary } else if (preg_match('|^[a-z]+://|i', $url) or preg_match('|^https?:|i', $url) or preg_match('|^ftp:|i', $url)) { // normal URL if (!url_appears_valid_url($url)) { $errors['externalurl'] = get_string('invalidurl', 'url'); } } else if (preg_match('|^[a-z]+:|i', $url)) { // general URI such as teamspeak, mailto, etc. - it may or may not work in all browsers, // we do not validate these at all, sorry } else { // invalid URI, we try to fix it by adding 'http://' prefix, // relative links are NOT allowed because we display the link on different pages! if (!url_appears_valid_url('http://'.$url)) { $errors['externalurl'] = get_string('invalidurl', 'url'); } } } return $errors; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/folder/mod_form.php000064400000011635152267033100023233 0ustar00. /** * Folder configuration form * * @package mod_folder * @copyright 2009 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once ($CFG->dirroot.'/course/moodleform_mod.php'); class mod_folder_mod_form extends moodleform_mod { function definition() { global $CFG; $mform = $this->_form; $config = get_config('folder'); //------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'48')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(); //------------------------------------------------------- $mform->addElement('header', 'content', get_string('contentheader', 'folder')); $mform->addElement('filemanager', 'files', get_string('files'), null, array('subdirs'=>1, 'accepted_types'=>'*')); $mform->addElement('select', 'display', get_string('display', 'mod_folder'), array(FOLDER_DISPLAY_PAGE => get_string('displaypage', 'mod_folder'), FOLDER_DISPLAY_INLINE => get_string('displayinline', 'mod_folder'))); $mform->addHelpButton('display', 'display', 'mod_folder'); if (!$this->courseformat->has_view_page()) { $mform->setConstant('display', FOLDER_DISPLAY_PAGE); $mform->hardFreeze('display'); } $mform->setExpanded('content'); // Adding option to show sub-folders expanded or collapsed by default. $mform->addElement('advcheckbox', 'showexpanded', get_string('showexpanded', 'folder')); $mform->addHelpButton('showexpanded', 'showexpanded', 'mod_folder'); $mform->setDefault('showexpanded', $config->showexpanded); // Adding option to enable downloading archive of folder. $mform->addElement('advcheckbox', 'showdownloadfolder', get_string('showdownloadfolder', 'folder')); $mform->addHelpButton('showdownloadfolder', 'showdownloadfolder', 'mod_folder'); $mform->setDefault('showdownloadfolder', true); // Adding option to enable viewing of individual files. $mform->addElement('advcheckbox', 'forcedownload', get_string('forcedownload', 'folder')); $mform->addHelpButton('forcedownload', 'forcedownload', 'mod_folder'); $mform->setDefault('forcedownload', true); //------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------- $this->add_action_buttons(); //------------------------------------------------------- $mform->addElement('hidden', 'revision'); $mform->setType('revision', PARAM_INT); $mform->setDefault('revision', 1); } function data_preprocessing(&$default_values) { if ($this->current->instance) { // editing existing instance - copy existing files into draft area $draftitemid = file_get_submitted_draft_itemid('files'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_folder', 'content', 0, array('subdirs'=>true)); $default_values['files'] = $draftitemid; } } function validation($data, $files) { $errors = parent::validation($data, $files); // Completion: Automatic on-view completion can not work together with // "display inline" option if (empty($errors['completion']) && array_key_exists('completion', $data) && $data['completion'] == COMPLETION_TRACKING_AUTOMATIC && !empty($data['completionview']) && $data['display'] == FOLDER_DISPLAY_INLINE) { $errors['completion'] = get_string('noautocompletioninline', 'mod_folder'); } return $errors; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/lesson/mod_form.php000064400000055101152267036760023276 0ustar00. /** * Form to define a new instance of lesson or edit an instance. * It is used from /course/modedit.php. * * @package mod_lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late **/ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot.'/course/moodleform_mod.php'); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); class mod_lesson_mod_form extends moodleform_mod { protected $course = null; public function __construct($current, $section, $cm, $course) { $this->course = $course; parent::__construct($current, $section, $cm, $course); } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function mod_lesson_mod_form($current, $section, $cm, $course) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($current, $section, $cm, $course); } function definition() { global $CFG, $COURSE, $DB, $OUTPUT; $mform = $this->_form; $lessonconfig = get_config('mod_lesson'); $mform->addElement('header', 'general', get_string('general', 'form')); /** Legacy slideshow width element to maintain backwards compatibility */ $mform->addElement('hidden', 'width'); $mform->setType('width', PARAM_INT); $mform->setDefault('width', $lessonconfig->slideshowwidth); /** Legacy slideshow height element to maintain backwards compatibility */ $mform->addElement('hidden', 'height'); $mform->setType('height', PARAM_INT); $mform->setDefault('height', $lessonconfig->slideshowheight); /** Legacy slideshow background color element to maintain backwards compatibility */ $mform->addElement('hidden', 'bgcolor'); $mform->setType('bgcolor', PARAM_TEXT); $mform->setDefault('bgcolor', $lessonconfig->slideshowbgcolor); /** Legacy media popup width element to maintain backwards compatibility */ $mform->addElement('hidden', 'mediawidth'); $mform->setType('mediawidth', PARAM_INT); $mform->setDefault('mediawidth', $lessonconfig->mediawidth); /** Legacy media popup height element to maintain backwards compatibility */ $mform->addElement('hidden', 'mediaheight'); $mform->setType('mediaheight', PARAM_INT); $mform->setDefault('mediaheight', $lessonconfig->mediaheight); /** Legacy media popup close button element to maintain backwards compatibility */ $mform->addElement('hidden', 'mediaclose'); $mform->setType('mediaclose', PARAM_BOOL); $mform->setDefault('mediaclose', $lessonconfig->mediaclose); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(); // Appearance. $mform->addElement('header', 'appearancehdr', get_string('appearance')); $filemanageroptions = array(); $filemanageroptions['filetypes'] = '*'; $filemanageroptions['maxbytes'] = $this->course->maxbytes; $filemanageroptions['subdirs'] = 0; $filemanageroptions['maxfiles'] = 1; $mform->addElement('filemanager', 'mediafile', get_string('mediafile', 'lesson'), null, $filemanageroptions); $mform->addHelpButton('mediafile', 'mediafile', 'lesson'); $mform->setAdvanced('mediafile', $lessonconfig->mediafile_adv); $mform->addElement('selectyesno', 'progressbar', get_string('progressbar', 'lesson')); $mform->addHelpButton('progressbar', 'progressbar', 'lesson'); $mform->setDefault('progressbar', $lessonconfig->progressbar); $mform->setAdvanced('progressbar', $lessonconfig->progressbar_adv); $mform->addElement('selectyesno', 'ongoing', get_string('ongoing', 'lesson')); $mform->addHelpButton('ongoing', 'ongoing', 'lesson'); $mform->setDefault('ongoing', $lessonconfig->ongoing); $mform->setAdvanced('ongoing', $lessonconfig->ongoing_adv); $mform->addElement('selectyesno', 'displayleft', get_string('displayleftmenu', 'lesson')); $mform->addHelpButton('displayleft', 'displayleftmenu', 'lesson'); $mform->setDefault('displayleft', $lessonconfig->displayleftmenu); $mform->setAdvanced('displayleft', $lessonconfig->displayleftmenu_adv); $options = array(); for($i = 100; $i >= 0; $i--) { $options[$i] = $i.'%'; } $mform->addElement('select', 'displayleftif', get_string('displayleftif', 'lesson'), $options); $mform->addHelpButton('displayleftif', 'displayleftif', 'lesson'); $mform->setDefault('displayleftif', $lessonconfig->displayleftif); $mform->setAdvanced('displayleftif', $lessonconfig->displayleftif_adv); $mform->addElement('selectyesno', 'slideshow', get_string('slideshow', 'lesson')); $mform->addHelpButton('slideshow', 'slideshow', 'lesson'); $mform->setDefault('slideshow', $lessonconfig->slideshow); $mform->setAdvanced('slideshow', $lessonconfig->slideshow_adv); $numbers = array(); for ($i = 20; $i > 1; $i--) { $numbers[$i] = $i; } $mform->addElement('select', 'maxanswers', get_string('maximumnumberofanswersbranches', 'lesson'), $numbers); $mform->setDefault('maxanswers', $lessonconfig->maxanswers); $mform->setAdvanced('maxanswers', $lessonconfig->maxanswers_adv); $mform->setType('maxanswers', PARAM_INT); $mform->addHelpButton('maxanswers', 'maximumnumberofanswersbranches', 'lesson'); $mform->addElement('selectyesno', 'feedback', get_string('displaydefaultfeedback', 'lesson')); $mform->addHelpButton('feedback', 'displaydefaultfeedback', 'lesson'); $mform->setDefault('feedback', $lessonconfig->defaultfeedback); $mform->setAdvanced('feedback', $lessonconfig->defaultfeedback_adv); // Get the modules. if ($mods = get_course_mods($COURSE->id)) { $modinstances = array(); foreach ($mods as $mod) { // Get the module name and then store it in a new array. if ($module = get_coursemodule_from_instance($mod->modname, $mod->instance, $COURSE->id)) { // Exclude this lesson, if it's already been saved. if (!isset($this->_cm->id) || $this->_cm->id != $mod->id) { $modinstances[$mod->id] = get_string('pluginname', $mod->modname) . ' - ' . format_string( $module->name, true, [ 'context' => $this->context, ], ); } } } asort($modinstances); // Sort by module name. $modinstances=array(0=>get_string('none'))+$modinstances; $mform->addElement('select', 'activitylink', get_string('activitylink', 'lesson'), $modinstances); $mform->addHelpButton('activitylink', 'activitylink', 'lesson'); $mform->setDefault('activitylink', 0); $mform->setAdvanced('activitylink', $lessonconfig->activitylink_adv); } // Availability. $mform->addElement('header', 'availabilityhdr', get_string('availability')); $mform->addElement('date_time_selector', 'available', get_string('available', 'lesson'), array('optional'=>true)); $mform->setDefault('available', 0); $mform->addElement('date_time_selector', 'deadline', get_string('deadline', 'lesson'), array('optional'=>true)); $mform->setDefault('deadline', 0); // Time limit. $mform->addElement('duration', 'timelimit', get_string('timelimit', 'lesson'), array('optional' => true)); $mform->addHelpButton('timelimit', 'timelimit', 'lesson'); $mform->setAdvanced('timelimit', $lessonconfig->timelimit_adv); $mform->setDefault('timelimit', $lessonconfig->timelimit); $mform->addElement('selectyesno', 'usepassword', get_string('usepassword', 'lesson')); $mform->addHelpButton('usepassword', 'usepassword', 'lesson'); $mform->setDefault('usepassword', $lessonconfig->password); $mform->setAdvanced('usepassword', $lessonconfig->password_adv); $mform->addElement('passwordunmask', 'password', get_string('password', 'lesson')); $mform->setDefault('password', ''); $mform->setAdvanced('password', $lessonconfig->password_adv); $mform->setType('password', PARAM_RAW); $mform->hideIf('password', 'usepassword', 'eq', 0); $mform->hideIf('passwordunmask', 'usepassword', 'eq', 0); // Dependent on. if ($this->current && isset($this->current->dependency) && $this->current->dependency) { $mform->addElement('header', 'dependencyon', get_string('prerequisitelesson', 'lesson')); $mform->addElement('static', 'warningobsolete', get_string('warning', 'lesson'), get_string('prerequisiteisobsolete', 'lesson')); $options = array(0 => get_string('none')); if ($lessons = get_all_instances_in_course('lesson', $COURSE)) { foreach ($lessons as $lesson) { if ($lesson->id != $this->_instance) { $options[$lesson->id] = format_string($lesson->name, true); } } } $mform->addElement('select', 'dependency', get_string('dependencyon', 'lesson'), $options); $mform->addHelpButton('dependency', 'dependencyon', 'lesson'); $mform->setDefault('dependency', 0); $mform->addElement('text', 'timespent', get_string('timespentminutes', 'lesson')); $mform->setDefault('timespent', 0); $mform->setType('timespent', PARAM_INT); $mform->disabledIf('timespent', 'dependency', 'eq', 0); $mform->addElement('checkbox', 'completed', get_string('completed', 'lesson')); $mform->setDefault('completed', 0); $mform->disabledIf('completed', 'dependency', 'eq', 0); $mform->addElement('text', 'gradebetterthan', get_string('gradebetterthan', 'lesson')); $mform->setDefault('gradebetterthan', 0); $mform->setType('gradebetterthan', PARAM_INT); $mform->disabledIf('gradebetterthan', 'dependency', 'eq', 0); } else { $mform->addElement('hidden', 'dependency', 0); $mform->setType('dependency', PARAM_INT); $mform->addElement('hidden', 'timespent', 0); $mform->setType('timespent', PARAM_INT); $mform->addElement('hidden', 'completed', 0); $mform->setType('completed', PARAM_INT); $mform->addElement('hidden', 'gradebetterthan', 0); $mform->setType('gradebetterthan', PARAM_INT); $mform->setConstants(array('dependency' => 0, 'timespent' => 0, 'completed' => 0, 'gradebetterthan' => 0)); } // Allow to enable offline lessons only if the Mobile services are enabled. if ($CFG->enablemobilewebservice) { $mform->addElement('selectyesno', 'allowofflineattempts', get_string('allowofflineattempts', 'lesson')); $mform->addHelpButton('allowofflineattempts', 'allowofflineattempts', 'lesson'); $mform->setDefault('allowofflineattempts', 0); $mform->setAdvanced('allowofflineattempts'); $mform->disabledIf('allowofflineattempts', 'timelimit[number]', 'neq', 0); $mform->addElement('static', 'allowofflineattemptswarning', '', $OUTPUT->notification(get_string('allowofflineattempts_help', 'lesson'), 'warning')); $mform->setAdvanced('allowofflineattemptswarning'); } else { $mform->addElement('hidden', 'allowofflineattempts', 0); $mform->setType('allowofflineattempts', PARAM_INT); } // Flow control. $mform->addElement('header', 'flowcontrol', get_string('flowcontrol', 'lesson')); $mform->addElement('selectyesno', 'modattempts', get_string('modattempts', 'lesson')); $mform->addHelpButton('modattempts', 'modattempts', 'lesson'); $mform->setDefault('modattempts', $lessonconfig->modattempts); $mform->setAdvanced('modattempts', $lessonconfig->modattempts_adv); $mform->addElement('selectyesno', 'review', get_string('displayreview', 'lesson')); $mform->addHelpButton('review', 'displayreview', 'lesson'); $mform->setDefault('review', $lessonconfig->displayreview); $mform->setAdvanced('review', $lessonconfig->displayreview_adv); $numbers = array('0' => get_string('unlimited')); for ($i = 10; $i > 0; $i--) { $numbers[$i] = $i; } $mform->addElement('select', 'maxattempts', get_string('maximumnumberofattempts', 'lesson'), $numbers); $mform->addHelpButton('maxattempts', 'maximumnumberofattempts', 'lesson'); $mform->setDefault('maxattempts', $lessonconfig->maximumnumberofattempts); $mform->setAdvanced('maxattempts', $lessonconfig->maximumnumberofattempts_adv); $defaultnextpages = array(); $defaultnextpages[0] = get_string('normal', 'lesson'); $defaultnextpages[LESSON_UNSEENPAGE] = get_string('showanunseenpage', 'lesson'); $defaultnextpages[LESSON_UNANSWEREDPAGE] = get_string('showanunansweredpage', 'lesson'); $mform->addElement('select', 'nextpagedefault', get_string('actionaftercorrectanswer', 'lesson'), $defaultnextpages); $mform->addHelpButton('nextpagedefault', 'actionaftercorrectanswer', 'lesson'); $mform->setDefault('nextpagedefault', $lessonconfig->defaultnextpage); $mform->setAdvanced('nextpagedefault', $lessonconfig->defaultnextpage_adv); $numbers = array(); for ($i = 100; $i >= 0; $i--) { $numbers[$i] = $i; } $mform->addElement('select', 'maxpages', get_string('numberofpagestoshow', 'lesson'), $numbers); $mform->addHelpButton('maxpages', 'numberofpagestoshow', 'lesson'); $mform->setDefault('maxpages', $lessonconfig->numberofpagestoshow); $mform->setAdvanced('maxpages', $lessonconfig->numberofpagestoshow_adv); // Grade. $this->standard_grading_coursemodule_elements(); // No header here, so that the following settings are displayed in the grade section. $mform->addElement('selectyesno', 'practice', get_string('practice', 'lesson')); $mform->addHelpButton('practice', 'practice', 'lesson'); $mform->setDefault('practice', $lessonconfig->practice); $mform->setAdvanced('practice', $lessonconfig->practice_adv); $mform->addElement('selectyesno', 'custom', get_string('customscoring', 'lesson')); $mform->addHelpButton('custom', 'customscoring', 'lesson'); $mform->setDefault('custom', $lessonconfig->customscoring); $mform->setAdvanced('custom', $lessonconfig->customscoring_adv); $mform->addElement('selectyesno', 'retake', get_string('retakesallowed', 'lesson')); $mform->addHelpButton('retake', 'retakesallowed', 'lesson'); $mform->setDefault('retake', $lessonconfig->retakesallowed); $mform->setAdvanced('retake', $lessonconfig->retakesallowed_adv); $options = array(); $options[0] = get_string('usemean', 'lesson'); $options[1] = get_string('usemaximum', 'lesson'); $mform->addElement('select', 'usemaxgrade', get_string('handlingofretakes', 'lesson'), $options); $mform->addHelpButton('usemaxgrade', 'handlingofretakes', 'lesson'); $mform->setDefault('usemaxgrade', $lessonconfig->handlingofretakes); $mform->setAdvanced('usemaxgrade', $lessonconfig->handlingofretakes_adv); $mform->hideIf('usemaxgrade', 'retake', 'eq', '0'); $numbers = array(); for ($i = 100; $i >= 0; $i--) { $numbers[$i] = $i; } $mform->addElement('select', 'minquestions', get_string('minimumnumberofquestions', 'lesson'), $numbers); $mform->addHelpButton('minquestions', 'minimumnumberofquestions', 'lesson'); $mform->setDefault('minquestions', $lessonconfig->minimumnumberofquestions); $mform->setAdvanced('minquestions', $lessonconfig->minimumnumberofquestions_adv); //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- // buttons $this->add_action_buttons(); } /** * Enforce defaults here * * @param array $defaultvalues Form defaults * @return void **/ public function data_preprocessing(&$defaultvalues) { if (isset($defaultvalues['conditions'])) { $conditions = unserialize_object($defaultvalues['conditions']); $defaultvalues['timespent'] = $conditions->timespent ?? 0; $defaultvalues['completed'] = !empty($conditions->completed); $defaultvalues['gradebetterthan'] = $conditions->gradebetterthan ?? 0; } // Set up the completion checkbox which is not part of standard data. $suffix = $this->get_suffix(); $completiontimespentenabledel = 'completiontimespentenabled' . $suffix; $completiontimespentel = 'completiontimespent' . $suffix; $defaultvalues[$completiontimespentenabledel] = !empty($defaultvalues[$completiontimespentel]) ? 1 : 0; if ($this->current->instance) { // Editing existing instance - copy existing files into draft area. $draftitemid = file_get_submitted_draft_itemid('mediafile'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_lesson', 'mediafile', 0, array('subdirs'=>0, 'maxbytes' => $this->course->maxbytes, 'maxfiles' => 1)); $defaultvalues['mediafile'] = $draftitemid; } } /** * Enforce validation rules here * * @param object $data Post data to validate * @return array **/ function validation($data, $files) { $errors = parent::validation($data, $files); // Check open and close times are consistent. if ($data['available'] != 0 && $data['deadline'] != 0 && $data['deadline'] < $data['available']) { $errors['deadline'] = get_string('closebeforeopen', 'lesson'); } if (!empty($data['usepassword']) && empty($data['password'])) { $errors['password'] = get_string('emptypassword', 'lesson'); } return $errors; } /** * Display module-specific activity completion rules. * Part of the API defined by moodleform_mod * @return array Array of string IDs of added items, empty array if none */ public function add_completion_rules() { $mform = $this->_form; $suffix = $this->get_suffix(); $completionendreachedel = 'completionendreached' . $suffix; $mform->addElement( 'checkbox', $completionendreachedel, '', get_string('completionendreached', 'lesson') ); // Enable this completion rule by default. $mform->setDefault($completionendreachedel, 1); $group = []; $completiontimespentenabledel = 'completiontimespentenabled' . $suffix; $group[] =& $mform->createElement( 'checkbox', $completiontimespentenabledel, '', get_string('completiontimespentgroup', 'lesson') ); $completiontimespentel = 'completiontimespent' . $suffix; $group[] =& $mform->createElement('duration', $completiontimespentel, '', ['optional' => false]); $completiontimespentgroupel = 'completiontimespentgroup' . $suffix; $mform->addGroup($group, $completiontimespentgroupel, '', ' ', false); $mform->hideIf($completiontimespentel . '[number]', $completiontimespentenabledel, 'notchecked'); $mform->hideIf($completiontimespentel . '[timeunit]', $completiontimespentenabledel, 'notchecked'); return [$completionendreachedel, $completiontimespentgroupel]; } /** * Called during validation. Indicates whether a module-specific completion rule is selected. * * @param array $data Input data (not yet validated) * @return bool True if one or more rules is enabled, false if none are. */ public function completion_rule_enabled($data) { $suffix = $this->get_suffix(); return !empty($data['completionendreached' . $suffix]) || $data['completiontimespent' . $suffix] > 0; } /** * Allows module to modify the data returned by form get_data(). * This method is also called in the bulk activity completion form. * * Only available on moodleform_mod. * * @param stdClass $data the form data to be modified. */ public function data_postprocessing($data) { parent::data_postprocessing($data); // Turn off completion setting if the checkbox is not ticked. if (!empty($data->completionunlocked)) { $suffix = $this->get_suffix(); $completion = $data->{'completion' . $suffix}; $autocompletion = !empty($completion) && $completion == COMPLETION_TRACKING_AUTOMATIC; if (empty($data->{'completiontimespentenabled' . $suffix}) || !$autocompletion) { $data->{'completiontimespent' . $suffix} = 0; } if (empty($data->{'completionendreached' . $suffix}) || !$autocompletion) { $data->{'completionendreached' . $suffix} = 0; } } } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/workshop/mod_form.php000064400000060331152267041520023636 0ustar00. /** * The main workshop configuration form * * The UI mockup has been proposed in MDL-18688 * It uses the standard core Moodle formslib. For more info about them, please * visit: https://moodledev.io/docs/apis/subsystems/form * * @package mod_workshop * @copyright 2009 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/course/moodleform_mod.php'); require_once(__DIR__ . '/locallib.php'); require_once($CFG->libdir . '/filelib.php'); use core_grades\component_gradeitems; /** * Module settings form for Workshop instances */ class mod_workshop_mod_form extends moodleform_mod { /** @var object the course this instance is part of */ protected $course = null; /** * Constructor */ public function __construct($current, $section, $cm, $course) { $this->course = $course; parent::__construct($current, $section, $cm, $course); } /** * Defines the workshop instance configuration form * * @return void */ public function definition() { global $CFG, $PAGE; $workshopconfig = get_config('workshop'); $mform = $this->_form; // General -------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); // Workshop name $label = get_string('workshopname', 'workshop'); $mform->addElement('text', 'name', $label, array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); // Introduction $this->standard_intro_elements(get_string('introduction', 'workshop')); // Grading settings ----------------------------------------------------------- $mform->addElement('header', 'gradingsettings', get_string('gradingsettings', 'workshop')); $mform->setExpanded('gradingsettings'); $label = get_string('strategy', 'workshop'); $mform->addElement('select', 'strategy', $label, workshop::available_strategies_list()); $mform->setDefault('strategy', $workshopconfig->strategy); $mform->addHelpButton('strategy', 'strategy', 'workshop'); $grades = workshop::available_maxgrades_list(); $gradecategories = grade_get_categories_menu($this->course->id); $label = get_string('submissiongrade', 'workshop'); $mform->addGroup(array( $mform->createElement('select', 'grade', '', $grades), $mform->createElement('select', 'gradecategory', '', $gradecategories), ), 'submissiongradegroup', $label, ' ', false); $mform->setDefault('grade', $workshopconfig->grade); $mform->addHelpButton('submissiongradegroup', 'submissiongrade', 'workshop'); $mform->addElement('float', 'submissiongradepass', get_string('gradetopasssubmission', 'workshop')); $mform->addHelpButton('submissiongradepass', 'gradepass', 'grades'); $mform->setDefault('submissiongradepass', ''); $label = get_string('gradinggrade', 'workshop'); $mform->addGroup(array( $mform->createElement('select', 'gradinggrade', '', $grades), $mform->createElement('select', 'gradinggradecategory', '', $gradecategories), ), 'gradinggradegroup', $label, ' ', false); $mform->setDefault('gradinggrade', $workshopconfig->gradinggrade); $mform->addHelpButton('gradinggradegroup', 'gradinggrade', 'workshop'); $mform->addElement('float', 'gradinggradepass', get_string('gradetopassgrading', 'workshop')); $mform->addHelpButton('gradinggradepass', 'gradepass', 'grades'); $mform->setDefault('gradinggradepass', ''); $options = array(); for ($i = 5; $i >= 0; $i--) { $options[$i] = $i; } $label = get_string('gradedecimals', 'workshop'); $mform->addElement('select', 'gradedecimals', $label, $options); $mform->setDefault('gradedecimals', $workshopconfig->gradedecimals); // Submission settings -------------------------------------------------------- $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'workshop')); $label = get_string('instructauthors', 'workshop'); $mform->addElement('editor', 'instructauthorseditor', $label, null, workshop::instruction_editors_options($this->context)); $typeelements = []; foreach (['submissiontypetext', 'submissiontypefile'] as $type) { $available = $type . 'available'; $required = $type . 'required'; $availablelabel = get_string($available, 'workshop'); $requiredlabel = get_string($required, 'workshop'); $typeelements[] = $mform->createElement('advcheckbox', $available, '', $availablelabel); $typeelements[] = $mform->createElement('advcheckbox', $required, '', $requiredlabel); $mform->setDefault($available, 1); } // We can't use
as the separator as it does not work well in this case with the Boost theme. // Instead, separate both tuples with a full-width empty div. $mform->addGroup($typeelements, 'submissiontypes', get_string('submissiontypes', 'workshop'), array(' ', '
'), false); $options = array(); for ($i = 7; $i >= 1; $i--) { $options[$i] = $i; } $label = get_string('nattachments', 'workshop'); $mform->addElement('select', 'nattachments', $label, $options); $mform->setDefault('nattachments', 1); $mform->hideIf('nattachments', 'submissiontypefileavailable'); $label = get_string('allowedfiletypesforsubmission', 'workshop'); $mform->addElement('filetypes', 'submissionfiletypes', $label); $mform->addHelpButton('submissionfiletypes', 'allowedfiletypesforsubmission', 'workshop'); $mform->hideIf('submissionfiletypes', 'submissiontypefileavailable'); $options = get_max_upload_sizes($CFG->maxbytes, $this->course->maxbytes, 0, $workshopconfig->maxbytes); $mform->addElement('select', 'maxbytes', get_string('maxbytes', 'workshop'), $options); $mform->setDefault('maxbytes', $workshopconfig->maxbytes); $mform->hideIf('maxbytes', 'submissiontypefileavailable'); $label = get_string('latesubmissions', 'workshop'); $text = get_string('latesubmissions_desc', 'workshop'); $mform->addElement('checkbox', 'latesubmissions', $label, $text); $mform->addHelpButton('latesubmissions', 'latesubmissions', 'workshop'); // Assessment settings -------------------------------------------------------- $mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop')); $label = get_string('instructreviewers', 'workshop'); $mform->addElement('editor', 'instructreviewerseditor', $label, null, workshop::instruction_editors_options($this->context)); $label = get_string('useselfassessment', 'workshop'); $text = get_string('useselfassessment_desc', 'workshop'); $mform->addElement('checkbox', 'useselfassessment', $label, $text); $mform->addHelpButton('useselfassessment', 'useselfassessment', 'workshop'); // Feedback ------------------------------------------------------------------- $mform->addElement('header', 'feedbacksettings', get_string('feedbacksettings', 'workshop')); $mform->addElement('select', 'overallfeedbackmode', get_string('overallfeedbackmode', 'mod_workshop'), array( 0 => get_string('overallfeedbackmode_0', 'mod_workshop'), 1 => get_string('overallfeedbackmode_1', 'mod_workshop'), 2 => get_string('overallfeedbackmode_2', 'mod_workshop'))); $mform->addHelpButton('overallfeedbackmode', 'overallfeedbackmode', 'mod_workshop'); $mform->setDefault('overallfeedbackmode', 1); $options = array(); for ($i = 7; $i >= 0; $i--) { $options[$i] = $i; } $mform->addElement('select', 'overallfeedbackfiles', get_string('overallfeedbackfiles', 'workshop'), $options); $mform->setDefault('overallfeedbackfiles', 0); $mform->hideIf('overallfeedbackfiles', 'overallfeedbackmode', 'eq', 0); $label = get_string('allowedfiletypesforoverallfeedback', 'workshop'); $mform->addElement('filetypes', 'overallfeedbackfiletypes', $label); $mform->addHelpButton('overallfeedbackfiletypes', 'allowedfiletypesforoverallfeedback', 'workshop'); $mform->hideIf('overallfeedbackfiletypes', 'overallfeedbackfiles', 'eq', 0); $options = get_max_upload_sizes($CFG->maxbytes, $this->course->maxbytes); $mform->addElement('select', 'overallfeedbackmaxbytes', get_string('overallfeedbackmaxbytes', 'workshop'), $options); $mform->setDefault('overallfeedbackmaxbytes', $workshopconfig->maxbytes); $mform->hideIf('overallfeedbackmaxbytes', 'overallfeedbackmode', 'eq', 0); $mform->hideIf('overallfeedbackmaxbytes', 'overallfeedbackfiles', 'eq', 0); $label = get_string('conclusion', 'workshop'); $mform->addElement('editor', 'conclusioneditor', $label, null, workshop::instruction_editors_options($this->context)); $mform->addHelpButton('conclusioneditor', 'conclusion', 'workshop'); // Example submissions -------------------------------------------------------- $mform->addElement('header', 'examplesubmissionssettings', get_string('examplesubmissions', 'workshop')); $label = get_string('useexamples', 'workshop'); $text = get_string('useexamples_desc', 'workshop'); $mform->addElement('checkbox', 'useexamples', $label, $text); $mform->addHelpButton('useexamples', 'useexamples', 'workshop'); $label = get_string('examplesmode', 'workshop'); $options = workshop::available_example_modes_list(); $mform->addElement('select', 'examplesmode', $label, $options); $mform->setDefault('examplesmode', $workshopconfig->examplesmode); $mform->hideIf('examplesmode', 'useexamples'); // Availability --------------------------------------------------------------- $mform->addElement('header', 'accesscontrol', get_string('availability', 'core')); $label = get_string('submissionstart', 'workshop'); $mform->addElement('date_time_selector', 'submissionstart', $label, array('optional' => true)); $label = get_string('submissionend', 'workshop'); $mform->addElement('date_time_selector', 'submissionend', $label, array('optional' => true)); $label = get_string('submissionendswitch', 'mod_workshop'); $mform->addElement('checkbox', 'phaseswitchassessment', $label); $mform->hideIf('phaseswitchassessment', 'submissionend[enabled]'); $mform->addHelpButton('phaseswitchassessment', 'submissionendswitch', 'mod_workshop'); $label = get_string('assessmentstart', 'workshop'); $mform->addElement('date_time_selector', 'assessmentstart', $label, array('optional' => true)); $label = get_string('assessmentend', 'workshop'); $mform->addElement('date_time_selector', 'assessmentend', $label, array('optional' => true)); // Common module settings, Restrict availability, Activity completion etc. ---- $features = array('groups' => true, 'groupings' => true, 'outcomes' => true, 'gradecat' => false, 'idnumber' => false); $this->standard_coursemodule_elements(); // Standard buttons, common to all modules ------------------------------------ $this->add_action_buttons(); $PAGE->requires->js_call_amd('mod_workshop/modform', 'init'); } /** * Prepares the form before data are set * * Additional wysiwyg editor are prepared here, the introeditor is prepared automatically by core. * Grade items are set here because the core modedit supports single grade item only. * * @param array $data to be set * @return void */ public function data_preprocessing(&$data) { if ($this->current->instance) { // editing an existing workshop - let us prepare the added editor elements (intro done automatically) $draftitemid = file_get_submitted_draft_itemid('instructauthors'); $data['instructauthorseditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($this->context), $data['instructauthors']); $data['instructauthorseditor']['format'] = $data['instructauthorsformat']; $data['instructauthorseditor']['itemid'] = $draftitemid; $draftitemid = file_get_submitted_draft_itemid('instructreviewers'); $data['instructreviewerseditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($this->context), $data['instructreviewers']); $data['instructreviewerseditor']['format'] = $data['instructreviewersformat']; $data['instructreviewerseditor']['itemid'] = $draftitemid; $draftitemid = file_get_submitted_draft_itemid('conclusion'); $data['conclusioneditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'conclusion', 0, workshop::instruction_editors_options($this->context), $data['conclusion']); $data['conclusioneditor']['format'] = $data['conclusionformat']; $data['conclusioneditor']['itemid'] = $draftitemid; // Set submission type checkboxes. foreach (['submissiontypetext', 'submissiontypefile'] as $type) { $data[$type . 'available'] = 1; $data[$type . 'required'] = 0; if ($data[$type] == WORKSHOP_SUBMISSION_TYPE_DISABLED) { $data[$type . 'available'] = 0; } else if ($data[$type] == WORKSHOP_SUBMISSION_TYPE_REQUIRED) { $data[$type . 'required'] = 1; } } } else { // adding a new workshop instance $draftitemid = file_get_submitted_draft_itemid('instructauthors'); file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'instructauthors', 0); // no context yet, itemid not used $data['instructauthorseditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid); $draftitemid = file_get_submitted_draft_itemid('instructreviewers'); file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'instructreviewers', 0); // no context yet, itemid not used $data['instructreviewerseditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid); $draftitemid = file_get_submitted_draft_itemid('conclusion'); file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'conclusion', 0); // no context yet, itemid not used $data['conclusioneditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid); } } /** * Combine submission type checkboxes into integer values for the database. * * @param stdClass $data The submitted form data. */ public function data_postprocessing($data) { parent::data_postprocessing($data); foreach (['text', 'file'] as $type) { $field = 'submissiontype' . $type; $available = $field . 'available'; $required = $field . 'required'; if ($data->$required) { $data->$field = WORKSHOP_SUBMISSION_TYPE_REQUIRED; } else if ($data->$available) { $data->$field = WORKSHOP_SUBMISSION_TYPE_AVAILABLE; } else { $data->$field = WORKSHOP_SUBMISSION_TYPE_DISABLED; } unset($data->$available); unset($data->$required); } } /** * Set the grade item categories when editing an instance */ public function definition_after_data() { $mform =& $this->_form; if ($id = $mform->getElementValue('update')) { $instance = $mform->getElementValue('instance'); $gradeitems = grade_item::fetch_all(array( 'itemtype' => 'mod', 'itemmodule' => 'workshop', 'iteminstance' => $instance, 'courseid' => $this->course->id)); if (!empty($gradeitems)) { foreach ($gradeitems as $gradeitem) { // here comes really crappy way how to set the value of the fields // gradecategory and gradinggradecategory - grrr QuickForms $decimalpoints = $gradeitem->get_decimals(); if ($gradeitem->itemnumber == 0) { $mform->setDefault('submissiongradepass', format_float($gradeitem->gradepass, $decimalpoints)); $group = $mform->getElement('submissiongradegroup'); $elements = $group->getElements(); foreach ($elements as $element) { if ($element->getName() == 'gradecategory') { $element->setValue($gradeitem->categoryid); } } } else if ($gradeitem->itemnumber == 1) { $mform->setDefault('gradinggradepass', format_float($gradeitem->gradepass, $decimalpoints)); $group = $mform->getElement('gradinggradegroup'); $elements = $group->getElements(); foreach ($elements as $element) { if ($element->getName() == 'gradinggradecategory') { $element->setValue($gradeitem->categoryid); } } } } } } $typevalues = $mform->getElementValue('submissiontypes'); foreach (['submissiontypetext', 'submissiontypefile'] as $type) { // Don't leave a disabled "required" checkbox checked. if (!$typevalues[$type . 'available']) { $mform->setDefault($type . 'required', 0); } } parent::definition_after_data(); } /** * Validates the form input * * @param array $data submitted data * @param array $files submitted files * @return array eventual errors indexed by the field name */ public function validation($data, $files) { $errors = parent::validation($data, $files); // check the phases borders are valid if ($data['submissionstart'] > 0 and $data['submissionend'] > 0 and $data['submissionstart'] >= $data['submissionend']) { $errors['submissionend'] = get_string('submissionendbeforestart', 'mod_workshop'); } if ($data['assessmentstart'] > 0 and $data['assessmentend'] > 0 and $data['assessmentstart'] >= $data['assessmentend']) { $errors['assessmentend'] = get_string('assessmentendbeforestart', 'mod_workshop'); } // check the phases do not overlap if (max($data['submissionstart'], $data['submissionend']) > 0 and max($data['assessmentstart'], $data['assessmentend']) > 0) { $phasesubmissionend = max($data['submissionstart'], $data['submissionend']); $phaseassessmentstart = min($data['assessmentstart'], $data['assessmentend']); if ($phaseassessmentstart == 0) { $phaseassessmentstart = max($data['assessmentstart'], $data['assessmentend']); } if ($phasesubmissionend > 0 and $phaseassessmentstart > 0 and $phaseassessmentstart < $phasesubmissionend) { foreach (array('submissionend', 'submissionstart', 'assessmentstart', 'assessmentend') as $f) { if ($data[$f] > 0) { $errors[$f] = get_string('phasesoverlap', 'mod_workshop'); break; } } } } // Check that the submission grade pass is a valid number. if (!empty($data['submissiongradepass'])) { $submissiongradefloat = unformat_float($data['submissiongradepass'], true); if ($submissiongradefloat === false) { $errors['submissiongradepass'] = get_string('err_numeric', 'form'); } else { if ($submissiongradefloat > $data['grade']) { $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']); } } } // Check that the grade pass is a valid number. if (!empty($data['gradinggradepass'])) { $gradepassfloat = unformat_float($data['gradinggradepass'], true); if ($gradepassfloat === false) { $errors['gradinggradepass'] = get_string('err_numeric', 'form'); } else { if ($gradepassfloat > $data['gradinggrade']) { $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']); } } } // We need to do a custom completion validation because workshop grade items identifiers divert from standard. // Refer to validation defined in moodleform_mod.php. if (isset($data['completionpassgrade']) && $data['completionpassgrade'] && isset($data['completiongradeitemnumber'])) { $itemnames = component_gradeitems::get_itemname_mapping_for_component('mod_workshop'); $gradepassfield = $itemnames[(int) $data['completiongradeitemnumber']] . 'gradepass'; // We need to make all the validations related with $gradepassfield // with them being correct floats, keeping the originals unmodified for // later validations / showing the form back... // TODO: Note that once MDL-73994 is fixed we'll have to re-visit this and // adapt the code below to the new values arriving here, without forgetting // the special case of empties and nulls. $gradepass = isset($data[$gradepassfield]) ? unformat_float($data[$gradepassfield]) : null; if (is_null($gradepass) || $gradepass == 0) { $errors['completionpassgrade'] = get_string( 'activitygradetopassnotset', 'completion' ); } else { // We have validated grade pass. Unset any errors. unset($errors['completionpassgrade']); } } if (!$data['submissiontypetextavailable'] && !$data['submissiontypefileavailable']) { // One submission type must be available. $errors['submissiontypes'] = get_string('nosubmissiontype', 'workshop'); } return $errors; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/choice/mod_form.php000064400000020552152267041700023215 0ustar00dirroot.'/course/moodleform_mod.php'); class mod_choice_mod_form extends moodleform_mod { function definition() { global $CFG, $DB; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('choicename', 'choice'), array('size'=>'64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(get_string('description', 'choice')); $mform->addElement('select', 'display', get_string("displaymode", "choice"), [ CHOICE_DISPLAY_HORIZONTAL => get_string('displayhorizontal', 'choice'), CHOICE_DISPLAY_VERTICAL => get_string('displayvertical', 'choice'), ]); //------------------------------------------------------------------------------- $mform->addElement('header', 'optionhdr', get_string('options', 'choice')); $mform->addElement('selectyesno', 'allowupdate', get_string("allowupdate", "choice")); $mform->addElement('selectyesno', 'allowmultiple', get_string('allowmultiple', 'choice')); if ($this->_instance) { if ($DB->count_records('choice_answers', array('choiceid' => $this->_instance)) > 0) { // Prevent user from toggeling the number of allowed answers once there are submissions. $mform->freeze('allowmultiple'); } } $mform->addElement('selectyesno', 'limitanswers', get_string('limitanswers', 'choice')); $mform->addHelpButton('limitanswers', 'limitanswers', 'choice'); $mform->addElement('selectyesno', 'showavailable', get_string('showavailable', 'choice')); $mform->addHelpButton('showavailable', 'showavailable', 'choice'); $mform->hideIf('showavailable', 'limitanswers', 'eq', 0); $repeatarray = array(); $repeatarray[] = $mform->createElement('text', 'option', get_string('optionno', 'choice')); $repeatarray[] = $mform->createElement('text', 'limit', get_string('limitno', 'choice')); $repeatarray[] = $mform->createElement('hidden', 'optionid', 0); if ($this->_instance){ $repeatno = $DB->count_records('choice_options', array('choiceid'=>$this->_instance)); $repeatno += 2; } else { $repeatno = 5; } $repeateloptions = array(); $repeateloptions['limit']['default'] = 0; $repeateloptions['limit']['hideif'] = array('limitanswers', 'eq', 0); $repeateloptions['limit']['rule'] = 'numeric'; $repeateloptions['limit']['type'] = PARAM_INT; $repeateloptions['option']['helpbutton'] = array('choiceoptions', 'choice'); $mform->setType('option', PARAM_CLEANHTML); $mform->setType('optionid', PARAM_INT); $this->repeat_elements($repeatarray, $repeatno, $repeateloptions, 'option_repeats', 'option_add_fields', 3, null, true); // Make the first option required if ($mform->elementExists('option[0]')) { $mform->addRule('option[0]', get_string('atleastoneoption', 'choice'), 'required', null, 'client'); } //------------------------------------------------------------------------------- $mform->addElement('header', 'availabilityhdr', get_string('availability')); $mform->addElement('date_time_selector', 'timeopen', get_string("choiceopen", "choice"), array('optional' => true)); $mform->addElement('date_time_selector', 'timeclose', get_string("choiceclose", "choice"), array('optional' => true)); $mform->addElement('advcheckbox', 'showpreview', get_string('showpreview', 'choice')); $mform->addHelpButton('showpreview', 'showpreview', 'choice'); $mform->disabledIf('showpreview', 'timeopen[enabled]'); //------------------------------------------------------------------------------- $mform->addElement('header', 'resultshdr', get_string('results', 'choice')); $mform->addElement('select', 'showresults', get_string("publish", "choice"), [ CHOICE_SHOWRESULTS_NOT => get_string('publishnot', 'choice'), CHOICE_SHOWRESULTS_AFTER_ANSWER => get_string('publishafteranswer', 'choice'), CHOICE_SHOWRESULTS_AFTER_CLOSE => get_string('publishafterclose', 'choice'), CHOICE_SHOWRESULTS_ALWAYS => get_string('publishalways', 'choice'), ]); $mform->addElement('select', 'publish', get_string("privacy", "choice"), [ CHOICE_PUBLISH_ANONYMOUS => get_string('publishanonymous', 'choice'), CHOICE_PUBLISH_NAMES => get_string('publishnames', 'choice'), ]); $mform->hideIf('publish', 'showresults', 'eq', 0); $mform->addElement('selectyesno', 'showunanswered', get_string("showunanswered", "choice")); $mform->addElement('selectyesno', 'includeinactive', get_string('includeinactive', 'choice')); $mform->setDefault('includeinactive', 0); //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- $this->add_action_buttons(); } function data_preprocessing(&$default_values){ global $DB; if (!empty($this->_instance) && ($options = $DB->get_records_menu('choice_options',array('choiceid'=>$this->_instance), 'id', 'id,text')) && ($options2 = $DB->get_records_menu('choice_options', array('choiceid'=>$this->_instance), 'id', 'id,maxanswers')) ) { $choiceids=array_keys($options); $options=array_values($options); $options2=array_values($options2); foreach (array_keys($options) as $key){ $default_values['option['.$key.']'] = $options[$key]; $default_values['limit['.$key.']'] = $options2[$key]; $default_values['optionid['.$key.']'] = $choiceids[$key]; } } } /** * Allows module to modify the data returned by form get_data(). * This method is also called in the bulk activity completion form. * * Only available on moodleform_mod. * * @param stdClass $data the form data to be modified. */ public function data_postprocessing($data) { parent::data_postprocessing($data); // Set up completion section even if checkbox is not ticked. if (!empty($data->completionunlocked)) { $suffix = $this->get_suffix(); if (empty($data->{'completionsubmit' . $suffix})) { $data->{'completionsubmit' . $suffix} = 0; } } } /** * Enforce validation rules here * * @param array $data array of ("fieldname"=>value) of submitted data * @param array $files array of uploaded files "element_name"=>tmp_file_path * @return array **/ public function validation($data, $files) { $errors = parent::validation($data, $files); // Check open and close times are consistent. if ($data['timeopen'] && $data['timeclose'] && $data['timeclose'] < $data['timeopen']) { $errors['timeclose'] = get_string('closebeforeopen', 'choice'); } return $errors; } public function add_completion_rules() { $mform =& $this->_form; $suffix = $this->get_suffix(); $completionsubmitel = 'completionsubmit' . $suffix; $mform->addElement('checkbox', $completionsubmitel, '', get_string('completionsubmit', 'choice')); // Enable this completion rule by default. $mform->setDefault($completionsubmitel, 1); return [$completionsubmitel]; } public function completion_rule_enabled($data) { $suffix = $this->get_suffix(); return !empty($data['completionsubmit' . $suffix]); } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/glossary/mod_form.php000064400000026270152267042220023627 0ustar00dirroot.'/course/moodleform_mod.php'); class mod_glossary_mod_form extends moodleform_mod { function definition() { global $CFG, $COURSE, $DB; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(); if (has_capability('mod/glossary:manageentries', context_system::instance())) { $mform->addElement('checkbox', 'globalglossary', get_string('isglobal', 'glossary')); $mform->addHelpButton('globalglossary', 'isglobal', 'glossary'); }else{ $mform->addElement('hidden', 'globalglossary'); $mform->setType('globalglossary', PARAM_INT); } $options = array(1=>get_string('mainglossary', 'glossary'), 0=>get_string('secondaryglossary', 'glossary')); $mform->addElement('select', 'mainglossary', get_string('glossarytype', 'glossary'), $options); $mform->addHelpButton('mainglossary', 'glossarytype', 'glossary'); $mform->setDefault('mainglossary', 0); // ---------------------------------------------------------------------- $mform->addElement('header', 'entrieshdr', get_string('entries', 'glossary')); $mform->addElement('selectyesno', 'defaultapproval', get_string('defaultapproval', 'glossary')); $mform->setDefault('defaultapproval', $CFG->glossary_defaultapproval); $mform->addHelpButton('defaultapproval', 'defaultapproval', 'glossary'); $mform->addElement('selectyesno', 'editalways', get_string('editalways', 'glossary')); $mform->setDefault('editalways', 0); $mform->addHelpButton('editalways', 'editalways', 'glossary'); $mform->addElement('selectyesno', 'allowduplicatedentries', get_string('allowduplicatedentries', 'glossary')); $mform->setDefault('allowduplicatedentries', $CFG->glossary_dupentries); $mform->addHelpButton('allowduplicatedentries', 'allowduplicatedentries', 'glossary'); $mform->addElement('selectyesno', 'allowcomments', get_string('allowcomments', 'glossary')); $mform->setDefault('allowcomments', $CFG->glossary_allowcomments); $mform->addHelpButton('allowcomments', 'allowcomments', 'glossary'); $mform->addElement('selectyesno', 'usedynalink', get_string('usedynalink', 'glossary')); $mform->setDefault('usedynalink', $CFG->glossary_linkbydefault); $mform->addHelpButton('usedynalink', 'usedynalink', 'glossary'); // ---------------------------------------------------------------------- $mform->addElement('header', 'appearancehdr', get_string('appearance')); // Get and update available formats. $recformats = glossary_get_available_formats(); $formats = array(); foreach ($recformats as $format) { $formats[$format->name] = get_string('displayformat'.$format->name, 'glossary'); } asort($formats); $mform->addElement('select', 'displayformat', get_string('displayformat', 'glossary'), $formats); $mform->setDefault('displayformat', 'dictionary'); $mform->addHelpButton('displayformat', 'displayformat', 'glossary'); $displayformats['default'] = get_string('displayformatdefault', 'glossary'); $displayformats = array_merge($displayformats, $formats); $mform->addElement('select', 'approvaldisplayformat', get_string('approvaldisplayformat', 'glossary'), $displayformats); $mform->setDefault('approvaldisplayformat', 'default'); $mform->addHelpButton('approvaldisplayformat', 'approvaldisplayformat', 'glossary'); $mform->addElement('text', 'entbypage', get_string('entbypage', 'glossary')); $mform->setDefault('entbypage', $this->get_default_entbypage()); $mform->addRule('entbypage', null, 'numeric', null, 'client'); $mform->setType('entbypage', PARAM_INT); $mform->addElement('selectyesno', 'showalphabet', get_string('showalphabet', 'glossary')); $mform->setDefault('showalphabet', 1); $mform->addHelpButton('showalphabet', 'showalphabet', 'glossary'); $mform->addElement('selectyesno', 'showall', get_string('showall', 'glossary')); $mform->setDefault('showall', 1); $mform->addHelpButton('showall', 'showall', 'glossary'); $mform->addElement('selectyesno', 'showspecial', get_string('showspecial', 'glossary')); $mform->setDefault('showspecial', 1); $mform->addHelpButton('showspecial', 'showspecial', 'glossary'); $mform->addElement('selectyesno', 'allowprintview', get_string('allowprintview', 'glossary')); $mform->setDefault('allowprintview', 1); $mform->addHelpButton('allowprintview', 'allowprintview', 'glossary'); if ($CFG->enablerssfeeds && isset($CFG->glossary_enablerssfeeds) && $CFG->glossary_enablerssfeeds) { //------------------------------------------------------------------------------- $mform->addElement('header', 'rssheader', get_string('rss')); $choices = array(); $choices[0] = get_string('none'); $choices[1] = get_string('withauthor', 'glossary'); $choices[2] = get_string('withoutauthor', 'glossary'); $mform->addElement('select', 'rsstype', get_string('rsstype', 'glossary'), $choices); $mform->addHelpButton('rsstype', 'rsstype', 'glossary'); $choices = array(); $choices[0] = '0'; $choices[1] = '1'; $choices[2] = '2'; $choices[3] = '3'; $choices[4] = '4'; $choices[5] = '5'; $choices[10] = '10'; $choices[15] = '15'; $choices[20] = '20'; $choices[25] = '25'; $choices[30] = '30'; $choices[40] = '40'; $choices[50] = '50'; $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices); $mform->addHelpButton('rssarticles', 'rssarticles', 'glossary'); $mform->hideIf('rssarticles', 'rsstype', 'eq', 0); } //------------------------------------------------------------------------------- $this->standard_grading_coursemodule_elements(); $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- // buttons $this->add_action_buttons(); } function definition_after_data() { global $COURSE, $DB; parent::definition_after_data(); $mform =& $this->_form; $mainglossaryel =& $mform->getElement('mainglossary'); $mainglossary = $DB->get_record('glossary', array('mainglossary'=>1, 'course'=>$COURSE->id)); if ($mainglossary && ($mainglossary->id != $mform->getElementValue('instance'))){ //secondary glossary, a main one already exists in this course. $mainglossaryel->setValue(0); $mainglossaryel->freeze(); $mainglossaryel->setPersistantFreeze(true); } else { $mainglossaryel->unfreeze(); $mainglossaryel->setPersistantFreeze(false); } } public function data_preprocessing(&$defaultvalues) { parent::data_preprocessing($defaultvalues); // Fallsback on the default setting if 'Entries shown per page' has been left blank. // This prevents the field from being required and expand its section which should not // be the case if there is a default value defined. if (empty($defaultvalues['entbypage']) || $defaultvalues['entbypage'] < 0) { $defaultvalues['entbypage'] = $this->get_default_entbypage(); } $suffix = $this->get_suffix(); $completionentriesel = 'completionentries' . $suffix; $completionentriesenabledel = 'completionentriesenabled' . $suffix; // Set up the completion checkboxes which aren't part of standard data. // Tick by default if Add mode or if completion entries settings is set to 1 or more. if (empty($this->_instance) || !empty($defaultvalues[$completionentriesel])) { $defaultvalues[$completionentriesenabledel] = 1; } else { $defaultvalues[$completionentriesenabledel] = 0; } if (empty($defaultvalues[$completionentriesel])) { $defaultvalues[$completionentriesel] = 1; } } public function add_completion_rules() { $mform = $this->_form; $suffix = $this->get_suffix(); $group = []; $completionentriesenabledel = 'completionentriesenabled' . $suffix; $group[] =& $mform->createElement( 'checkbox', $completionentriesenabledel, '', get_string('completionentries', 'glossary') ); $completionentriesel = 'completionentries' . $suffix; $group[] =& $mform->createElement('text', $completionentriesel, '', ['size' => 3]); $mform->setType($completionentriesel, PARAM_INT); $completionentriesgroupel = 'completionentriesgroup' . $suffix; $mform->addGroup($group, $completionentriesgroupel, '', ' ', false); $mform->hideIf($completionentriesel, $completionentriesenabledel, 'notchecked'); return [$completionentriesgroupel]; } public function completion_rule_enabled($data) { $suffix = $this->get_suffix(); return (!empty($data['completionentriesenabled' . $suffix]) && $data['completionentries' . $suffix] != 0); } /** * Allows module to modify the data returned by form get_data(). * This method is also called in the bulk activity completion form. * * Only available on moodleform_mod. * * @param stdClass $data the form data to be modified. */ public function data_postprocessing($data) { parent::data_postprocessing($data); if (!empty($data->completionunlocked)) { // Turn off completion settings if the checkboxes aren't ticked. $suffix = $this->get_suffix(); $completion = $data->{'completion' . $suffix}; $autocompletion = !empty($completion) && $completion == COMPLETION_TRACKING_AUTOMATIC; if (empty($data->{'completionentriesenabled' . $suffix}) || !$autocompletion) { $data->{'completionentries' . $suffix} = 0; } } } /** * Returns the default value for 'Entries shown per page'. * * @return int default for number of entries per page. */ protected function get_default_entbypage() { global $CFG; return !empty($CFG->glossary_entbypage) ? $CFG->glossary_entbypage : 10; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/resource/mod_form.php000064400000024476152267052670023633 0ustar00. /** * Resource configuration form * * @package mod_resource * @copyright 2009 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; require_once($CFG->dirroot.'/course/moodleform_mod.php'); require_once($CFG->dirroot.'/mod/resource/locallib.php'); require_once($CFG->libdir.'/filelib.php'); class mod_resource_mod_form extends moodleform_mod { function definition() { global $CFG, $DB; $mform =& $this->_form; $config = get_config('resource'); if ($this->current->instance and $this->current->tobemigrated) { // resource not migrated yet $resource_old = $DB->get_record('resource_old', array('oldid'=>$this->current->instance)); $mform->addElement('static', 'warning', '', get_string('notmigrated', 'resource', $resource_old->type)); $mform->addElement('cancel'); $this->standard_hidden_coursemodule_elements(); return; } //------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'48')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(); $element = $mform->getElement('introeditor'); $attributes = $element->getAttributes(); $attributes['rows'] = 5; $element->setAttributes($attributes); $filemanager_options = array(); $filemanager_options['accepted_types'] = '*'; $filemanager_options['maxbytes'] = 0; $filemanager_options['maxfiles'] = -1; $filemanager_options['mainfile'] = true; $mform->addElement('filemanager', 'files', get_string('selectfiles'), null, $filemanager_options); // add legacy files flag only if used if (isset($this->current->legacyfiles) and $this->current->legacyfiles != RESOURCELIB_LEGACYFILES_NO) { $options = array(RESOURCELIB_LEGACYFILES_DONE => get_string('legacyfilesdone', 'resource'), RESOURCELIB_LEGACYFILES_ACTIVE => get_string('legacyfilesactive', 'resource')); $mform->addElement('select', 'legacyfiles', get_string('legacyfiles', 'resource'), $options); } //------------------------------------------------------- $mform->addElement('header', 'optionssection', get_string('appearance')); if ($this->current->instance) { $options = resourcelib_get_displayoptions(explode(',', $config->displayoptions), $this->current->display); } else { $options = resourcelib_get_displayoptions(explode(',', $config->displayoptions)); } if (count($options) == 1) { $mform->addElement('hidden', 'display'); $mform->setType('display', PARAM_INT); reset($options); $mform->setDefault('display', key($options)); } else { $mform->addElement('select', 'display', get_string('displayselect', 'resource'), $options); $mform->setDefault('display', $config->display); $mform->addHelpButton('display', 'displayselect', 'resource'); } $mform->addElement('checkbox', 'showsize', get_string('showsize', 'resource')); $mform->setDefault('showsize', $config->showsize); $mform->addHelpButton('showsize', 'showsize', 'resource'); $mform->addElement('checkbox', 'showtype', get_string('showtype', 'resource')); $mform->setDefault('showtype', $config->showtype); $mform->addHelpButton('showtype', 'showtype', 'resource'); $mform->addElement('checkbox', 'showdate', get_string('showdate', 'resource')); $mform->setDefault('showdate', $config->showdate); $mform->addHelpButton('showdate', 'showdate', 'resource'); if (array_key_exists(RESOURCELIB_DISPLAY_POPUP, $options)) { $mform->addElement('text', 'popupwidth', get_string('popupwidth', 'resource'), array('size'=>3)); if (count($options) > 1) { $mform->hideIf('popupwidth', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP); } $mform->setType('popupwidth', PARAM_INT); $mform->setDefault('popupwidth', $config->popupwidth); $mform->setAdvanced('popupwidth', true); $mform->addElement('text', 'popupheight', get_string('popupheight', 'resource'), array('size'=>3)); if (count($options) > 1) { $mform->hideIf('popupheight', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP); } $mform->setType('popupheight', PARAM_INT); $mform->setDefault('popupheight', $config->popupheight); $mform->setAdvanced('popupheight', true); } if (array_key_exists(RESOURCELIB_DISPLAY_AUTO, $options) or array_key_exists(RESOURCELIB_DISPLAY_EMBED, $options) or array_key_exists(RESOURCELIB_DISPLAY_FRAME, $options)) { $mform->addElement('checkbox', 'printintro', get_string('printintro', 'resource')); $mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_POPUP); $mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_DOWNLOAD); $mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_OPEN); $mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_NEW); $mform->setDefault('printintro', $config->printintro); } $options = array('0' => get_string('none'), '1' => get_string('allfiles'), '2' => get_string('htmlfilesonly')); $mform->addElement('select', 'filterfiles', get_string('filterfiles', 'resource'), $options); $mform->setDefault('filterfiles', $config->filterfiles); $mform->setAdvanced('filterfiles', true); //------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------- $this->add_action_buttons(); //------------------------------------------------------- $mform->addElement('hidden', 'revision'); $mform->setType('revision', PARAM_INT); $mform->setDefault('revision', 1); } function data_preprocessing(&$default_values) { if ($this->current->instance and !$this->current->tobemigrated) { $draftitemid = file_get_submitted_draft_itemid('files'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_resource', 'content', 0, array('subdirs'=>true)); $default_values['files'] = $draftitemid; } if (!empty($default_values['displayoptions'])) { $displayoptions = (array) unserialize_array($default_values['displayoptions']); if (isset($displayoptions['printintro'])) { $default_values['printintro'] = $displayoptions['printintro']; } if (!empty($displayoptions['popupwidth'])) { $default_values['popupwidth'] = $displayoptions['popupwidth']; } if (!empty($displayoptions['popupheight'])) { $default_values['popupheight'] = $displayoptions['popupheight']; } if (!empty($displayoptions['showsize'])) { $default_values['showsize'] = $displayoptions['showsize']; } else { // Must set explicitly to 0 here otherwise it will use system // default which may be 1. $default_values['showsize'] = 0; } if (!empty($displayoptions['showtype'])) { $default_values['showtype'] = $displayoptions['showtype']; } else { $default_values['showtype'] = 0; } if (!empty($displayoptions['showdate'])) { $default_values['showdate'] = $displayoptions['showdate']; } else { $default_values['showdate'] = 0; } } } function definition_after_data() { if ($this->current->instance and $this->current->tobemigrated) { // resource not migrated yet return; } parent::definition_after_data(); } function validation($data, $files) { global $USER; $errors = parent::validation($data, $files); $usercontext = context_user::instance($USER->id); $fs = get_file_storage(); if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data['files'], 'sortorder, id', false)) { $errors['files'] = get_string('required'); return $errors; } if (count($files) == 1) { // no need to select main file if only one picked return $errors; } else if(count($files) > 1) { $mainfile = false; foreach($files as $file) { if ($file->get_sortorder() == 1) { $mainfile = true; break; } } // set a default main file if (!$mainfile) { $file = reset($files); file_set_sortorder($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename(), 1); } } return $errors; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/lti/mod_form.php000064400000072601152267057140022562 0ustar00. // // This file is part of BasicLTI4Moodle // // BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability) // consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web // based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI // specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS // are already supporting or going to support BasicLTI. This project Implements the consumer // for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas. // BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem // at the GESSI research group at UPC. // SimpleLTI consumer for Moodle is an implementation of the early specification of LTI // by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a // Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier. // // BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis // of the Universitat Politecnica de Catalunya http://www.upc.edu // Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu. /** * This file defines the main lti configuration form * * @package mod_lti * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis * marc.alier@upc.edu * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu * @author Marc Alier * @author Jordi Piguillem * @author Nikolas Galanis * @author Chris Scribner * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; require_once($CFG->dirroot.'/course/moodleform_mod.php'); require_once($CFG->dirroot.'/mod/lti/locallib.php'); class mod_lti_mod_form extends moodleform_mod { /** @var int the tool typeid, or 0 if the instance form is being created for a manually configured tool instance.*/ protected int $typeid; /** @var string|null type */ protected ?string $type; /** * Constructor. * * Throws an exception if trying to init the form for a new manual instance of a tool, which is not supported in 4.3 onward. * * @param \stdClass $current the current form data. * @param string $section the section number. * @param \stdClass $cm the course module object. * @param \stdClass $course the course object. * @throws moodle_exception if trying to init the form for the creation of a manual instance, which is no longer supported. */ public function __construct($current, $section, $cm, $course) { // Setup some of the pieces used to control display in the form definition() method. // Type ID parameter being passed when adding an preconfigured tool from activity chooser. $this->typeid = optional_param('typeid', 0, PARAM_INT); $this->type = optional_param('type', null, PARAM_ALPHA); // Only permit construction if the form deals with editing an existing instance (current->id not empty), or creating an // instance from a preconfigured tool type ($this->typeid not empty). Make an exception for callers, such as core_completion // which aren't instantiating the form with the expected data, by checking whether the page has been set up, which is the // case for normal uses. global $PAGE; if ($PAGE->has_set_url() && str_contains($PAGE->url, '/course/modedit.php')) { if (empty($this->typeid) && empty($current->id)) { throw new moodle_exception('lti:addmanualinstanceprohibitederror', 'mod_lti'); } } parent::__construct($current, $section, $cm, $course); } /** * Defines the form for legacy instances. Here tool config is frozen because the manual configuration method is deprecated. * * @param array $instancetypes the array of options for the legacy 'preconfigured tools' select. * @return void */ protected function legacy_instance_form_definition(array $instancetypes): void { global $OUTPUT; // The legacy form handles instances which are either entirely manually configured (current->typeid = 0), or which are // manually configured and have been domain-matched to a preconfigured tool (current->typeid != 0). $manualinstance = empty($this->current->typeid); $matchestoolnotavailabletocourse = !$manualinstance; $typeid = $manualinstance ? '0' : $this->current->typeid; // Since 'mod/lti:addmanualinstance' capability is deprecated, determining which users may have had access to the certain // form fields (the manual config fields) isn't straightforward. Users without 'mod/lti:addmanualinstance' would have only // been permitted to edit the basic instance fields (name, etc.), so care must be taken not to display the config fields to // these users. Users who can add/edit course tools (mod/lti:addcoursetool) are able to view tool information anyway, via // the tool definitions, so this capability is used as a replacement, to control access to these tool config fields. $canviewmanualconfig = has_capability('mod/lti:addcoursetool', $this->context); $showtypes = has_capability('mod/lti:addpreconfiguredinstance', $this->context); if ($manualinstance && !$canviewmanualconfig) { // If you cannot add a manual instance and this is already a manual instance, then remove the 'types' selector. $showtypes = false; } $mform =& $this->_form; // Show the deprecation notice, regardless of whether the user can view the tool configuration details or not. // They will still see locked privacy fields and should be informed as to why that is. $mform->addElement('html', $OUTPUT->notification( get_string('editmanualinstancedeprecationwarning', 'mod_lti', get_docs_url('External_tool')), \core\output\notification::NOTIFY_WARNING, false) ); // Adding the "general" fieldset, where all the common settings are shown. $mform->addElement('html', ""); $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field. $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), ['size' => '64']); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); // Adding the optional "intro" and "introformat" pair of fields. $this->standard_intro_elements(get_string('basicltiintro', 'lti')); $mform->setAdvanced('introeditor'); // Display the label to the right of the checkbox so it looks better & matches rest of the form. if ($mform->elementExists('showdescription')) { $coursedesc = $mform->getElement('showdescription'); if (!empty($coursedesc)) { $coursedesc->setText(' ' . $coursedesc->getLabel()); $coursedesc->setLabel(' '); } } $mform->setAdvanced('showdescription'); $mform->addElement('checkbox', 'showtitlelaunch', get_string('display_name', 'lti')); $mform->setAdvanced('showtitlelaunch'); $mform->addHelpButton('showtitlelaunch', 'display_name', 'lti'); $mform->addElement('checkbox', 'showdescriptionlaunch', get_string('display_description', 'lti')); $mform->setAdvanced('showdescriptionlaunch'); $mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti'); if ($showtypes) { if ($manualinstance) { // Legacy, manually configured instances: only freeze the element (not hardFreeze) so that disabledIf() still works. // The data in the select is restricted so that only the current value is deemed valid, preventing DOM-edit changes, // which are possible with frozen elements. $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti')); $mform->addHelpButton('typeid', 'external_tool_type', 'lti'); $manualinstanceoption = $instancetypes[0]; // The 'Automatic, based on tool URL' option. $tooltypes->addOption($manualinstanceoption->name, 0, []); $mform->freeze('typeid'); } else if ($matchestoolnotavailabletocourse) { // Legacy instances domain-matched to site tools: use a hidden field for typeid and a static visual element when // displaying these instances so that the string value of typeid is still visible when the element is frozen. // This gets around the fact that a frozen select without a selected option will display nothing. $mform->addElement('hidden', 'typeid', $typeid); $mform->setType('typeid', PARAM_INT); $manualinstanceoption = $instancetypes[0]; // The 'Automatic, based on tool URL' option. $mform->addElement('static', 'typeiddisplayonly', get_string('external_tool_type', 'lti'), $manualinstanceoption->name); } } else { // Need to submit these still, but hidden to avoid instructor modification. $mform->addElement('hidden', 'typeid', $typeid); $mform->setType('typeid', PARAM_INT); } // Disable the content selection button unconditionally. Freeze/hardFreeze is unsuitable for buttons. $mform->addElement('button', 'selectcontent', get_string('selectcontent', 'lti'), ['disabled' => 'disabled']); $mform->disabledIf('selectcontent', 'typeid', 'eq', $typeid); if ($canviewmanualconfig) { $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), ['size' => '64']); $mform->setType('toolurl', PARAM_URL); $mform->addHelpButton('toolurl', 'launch_url', 'lti'); $mform->addElement('text', 'securetoolurl', get_string('secure_launch_url', 'lti'), ['size' => '64']); $mform->setType('securetoolurl', PARAM_URL); $mform->setAdvanced('securetoolurl'); $mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti'); } else { // Need to submit these still, but hidden to avoid instructor modification. $mform->addElement('hidden', 'toolurl', '', ['id' => 'id_toolurl']); $mform->setType('toolurl', PARAM_URL); $mform->addElement('hidden', 'securetoolurl', '', ['id' => 'id_securetoolurl']); $mform->setType('securetoolurl', PARAM_URL); } $mform->addElement('hidden', 'lineitemresourceid', '', ['id' => 'id_lineitemresourceid']); $mform->setType('lineitemresourceid', PARAM_TEXT); $mform->addElement('hidden', 'lineitemtag', '', ['id' => 'id_lineitemtag']); $mform->setType('lineitemtag', PARAM_TEXT); $mform->addElement('hidden', 'lineitemsubreviewurl', '', ['id' => 'id_lineitemsubreviewurl']); $mform->setType('lineitemsubreviewurl', PARAM_URL); $mform->addElement('hidden', 'lineitemsubreviewparams', '', ['id' => 'id_lineitemsubreviewparams']); $mform->setType('lineitemsubreviewparams', PARAM_TEXT); $launchoptions = [ LTI_LAUNCH_CONTAINER_DEFAULT => get_string('default', 'lti'), LTI_LAUNCH_CONTAINER_EMBED => get_string('embed', 'lti'), LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS => get_string('embed_no_blocks', 'lti'), LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW => get_string('existing_window', 'lti'), LTI_LAUNCH_CONTAINER_WINDOW => get_string('new_window', 'lti') ]; $mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions); $mform->addHelpButton('launchcontainer', 'launchinpopup', 'lti'); $mform->setAdvanced('launchcontainer'); if ($canviewmanualconfig) { $mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti')); $mform->setType('resourcekey', PARAM_TEXT); $mform->setAdvanced('resourcekey'); $mform->addHelpButton('resourcekey', 'resourcekey', 'lti'); $mform->setForceLtr('resourcekey'); $mform->addElement('passwordunmask', 'password', get_string('password', 'lti')); $mform->setType('password', PARAM_TEXT); $mform->setAdvanced('password'); $mform->addHelpButton('password', 'password', 'lti'); $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), ['rows' => 4, 'cols' => 60]); $mform->setType('instructorcustomparameters', PARAM_TEXT); $mform->setAdvanced('instructorcustomparameters'); $mform->addHelpButton('instructorcustomparameters', 'custom', 'lti'); $mform->setForceLtr('instructorcustomparameters'); $mform->addElement('text', 'icon', get_string('icon_url', 'lti'), ['size' => '64']); $mform->setType('icon', PARAM_URL); $mform->setAdvanced('icon'); $mform->addHelpButton('icon', 'icon_url', 'lti'); $mform->addElement('text', 'secureicon', get_string('secure_icon_url', 'lti'), ['size' => '64']); $mform->setType('secureicon', PARAM_URL); $mform->setAdvanced('secureicon'); $mform->addHelpButton('secureicon', 'secure_icon_url', 'lti'); } else { // Need to submit these still, but hidden to avoid instructor modification. $mform->addElement('hidden', 'resourcekey', '', ['id' => 'id_resourcekey']); $mform->setType('resourcekey', PARAM_TEXT); $mform->addElement('hidden', 'password', '', ['id' => 'id_password']); $mform->setType('password', PARAM_TEXT); $mform->addElement('hidden', 'instructorcustomparameters', '', ['id' => 'id_instructorcustomparameters']); $mform->setType('instructorcustomparameters', PARAM_TEXT); $mform->addElement('hidden', 'icon', '', ['id' => 'id_icon']); $mform->setType('icon', PARAM_URL); $mform->addElement('hidden', 'secureicon', '', ['id' => 'id_secureicon']); $mform->setType('secureicon', PARAM_URL); } // Add privacy preferences fieldset where users choose whether to send their data. $mform->addElement('header', 'privacy', get_string('privacy', 'lti')); $mform->addElement('advcheckbox', 'instructorchoicesendname', get_string('share_name', 'lti')); $mform->addHelpButton('instructorchoicesendname', 'share_name', 'lti'); $mform->addElement('advcheckbox', 'instructorchoicesendemailaddr', get_string('share_email', 'lti')); $mform->addHelpButton('instructorchoicesendemailaddr', 'share_email', 'lti'); $mform->addElement('advcheckbox', 'instructorchoiceacceptgrades', get_string('accept_grades', 'lti')); $mform->addHelpButton('instructorchoiceacceptgrades', 'accept_grades', 'lti'); // Add standard course module grading elements. $this->standard_grading_coursemodule_elements(); // Add standard elements, common to all modules. $this->standard_coursemodule_elements(); $mform->setAdvanced('cmidnumber'); // Add standard buttons, common to all modules. $this->add_action_buttons(); $mform->hardFreeze([ 'toolurl', 'securetoolurl', 'launchcontainer', 'instructorcustomparameters', 'icon', 'secureicon', 'instructorchoicesendname', 'instructorchoicesendemailaddr', 'instructorchoiceacceptgrades' ]); } public function definition() { global $CFG, $PAGE, $OUTPUT, $COURSE; if ($this->type) { component_callback("ltisource_$this->type", 'add_instance_hook'); } // Determine whether this tool instance is a manually configure instance (now deprecated). $manualinstance = empty($this->current->typeid) && empty($this->typeid); // Determine whether this tool instance is using a domain-matched site tool which is not visible at the course level. // In such a case, the instance has a typeid (the site tool) and toolurl (the url used to domain match the site tool) set, // and the type still exists (is not deleted). $instancetypes = lti_get_types_for_add_instance(); $matchestoolnotavailabletocourse = false; if (!$manualinstance && !empty($this->current->toolurl)) { if (lti_get_type_config($this->current->typeid)) { $matchestoolnotavailabletocourse = !in_array($this->current->typeid, array_keys($instancetypes)); } } // Display the legacy form, presenting a read-only view of the configuration for unsupported (since 4.3) instances, which: // - Are manually configured instances (no longer supported. course tools should be configured and used instead). // - Are domain-matched to a hidden site level tool (no longer supported. to be replaced by URL-based course tool creation) // Instances based on preconfigured tools and which are not domain matched as above, are still valid and will be shown using // the non-legacy form. if ($manualinstance || $matchestoolnotavailabletocourse) { $this->legacy_instance_form_definition($instancetypes); return; } $tooltypeid = $this->current->typeid ?? $this->typeid; $tooltype = lti_get_type($tooltypeid); // Store the id of the tool type should it be linked to a tool proxy, to aid in disabling certain form elements. $toolproxytypeid = $tooltype->toolproxyid ? $tooltypeid : ''; $issitetooltype = $tooltype->course == get_site()->id; $mform =& $this->_form; // Adding the "general" fieldset, where all the common settings are shown. $mform->addElement('html', ""); $mform->addElement('header', 'general', get_string('general', 'form')); // For tools supporting content selection, add the 'Select content button'. $config = lti_get_type_config($tooltypeid); $supportscontentitemselection = !empty($config['contentitem']); if ($supportscontentitemselection) { $contentitemurl = new moodle_url('/mod/lti/contentitem.php'); $contentbuttonattributes = [ 'data-contentitemurl' => $contentitemurl->out(false), ]; // If this is an instance, was it created based on content selection in a prior-edit (need to infer since not stored). $iscontentitem = !empty($this->current->id) && (!empty($this->current->toolurl) || !empty($this->current->instructorcustomparameters) || !empty($this->current->secureicon) || !empty($this->current->icon)); $selectcontentindicatorinner = $iscontentitem ? $OUTPUT->pix_icon('i/valid', get_string('contentselected', 'mod_lti'), 'moodle', ['class' => 'me-1']) . get_string('contentselected', 'mod_lti') : ''; $selectcontentindicator = html_writer::div($selectcontentindicatorinner, '', ['aria-role' => 'status', 'id' => 'id_selectcontentindicator']); $selectcontentgrp = [ $mform->createElement('button', 'selectcontent', get_string('selectcontent', 'mod_lti'), $contentbuttonattributes, ['customclassoverride' => 'btn-secondary']), $mform->createElement('html', $selectcontentindicator), ]; $mform->addGroup($selectcontentgrp, 'selectcontentgroup', get_string('content'), ' ', false); } // Adding the standard "name" field. $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), ['size' => '64']); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'server'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server'); // Show activity name when launched only applies to embedded type launches. if (in_array($config['launchcontainer'], [LTI_LAUNCH_CONTAINER_EMBED, LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS])) { $mform->addElement('checkbox', 'showtitlelaunch', get_string('display_name', 'lti')); $mform->setDefault('showtitlelaunch', true); $mform->addHelpButton('showtitlelaunch', 'display_name', 'lti'); } else { // Include in the form anyway, so we retain the setting value in case the tool launch container is changed back. $mform->addElement('hidden', 'showtitlelaunch'); $mform->setType('showtitlelaunch', PARAM_BOOL); } // Adding the optional "intro" and "introformat" pair of fields. $this->standard_intro_elements(get_string('basicltiintro', 'lti')); // Display the label to the right of the checkbox so it looks better & matches rest of the form. if ($mform->elementExists('showdescription')) { $coursedesc = $mform->getElement('showdescription'); if (!empty($coursedesc)) { $coursedesc->setText(' ' . $coursedesc->getLabel()); $coursedesc->setLabel(' '); } } // Show activity description when launched only applies to embedded type launches. if (in_array($config['launchcontainer'], [LTI_LAUNCH_CONTAINER_EMBED, LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS])) { $mform->addElement('checkbox', 'showdescriptionlaunch', get_string('display_description', 'lti')); $mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti'); } else { // Include in the form anyway, so we retain the setting value in case the tool launch container is changed back. $mform->addElement('hidden', 'showdescriptionlaunch'); $mform->setType('showdescriptionlaunch', PARAM_BOOL); } // Tool settings. $mform->addElement('hidden', 'typeid', $tooltypeid, ['id' => 'hidden_typeid']); $mform->setType('typeid', PARAM_INT); if (!empty($config['contentitem'])) { $mform->addElement('hidden', 'contentitem', 1); $mform->setType('contentitem', PARAM_INT); } // Included to support deep linking return, but hidden to avoid instructor modification. $mform->addElement('hidden', 'toolurl', '', ['id' => 'id_toolurl']); $mform->setType('toolurl', PARAM_URL); $mform->addElement('hidden', 'securetoolurl', '', ['id' => 'id_securetoolurl']); $mform->setType('securetoolurl', PARAM_URL); $mform->addElement('hidden', 'urlmatchedtypeid', '', ['id' => 'id_urlmatchedtypeid']); $mform->setType('urlmatchedtypeid', PARAM_INT); $mform->addElement('hidden', 'lineitemresourceid', '', ['id' => 'id_lineitemresourceid']); $mform->setType('lineitemresourceid', PARAM_TEXT); $mform->addElement('hidden', 'lineitemtag', '', ['id' => 'id_lineitemtag']); $mform->setType('lineitemtag', PARAM_TEXT); $mform->addElement('hidden', 'lineitemsubreviewurl', '', ['id' => 'id_lineitemsubreviewurl']); $mform->setType('lineitemsubreviewurl', PARAM_URL); $mform->addElement('hidden', 'lineitemsubreviewparams', '', ['id' => 'id_lineitemsubreviewparams']); $mform->setType('lineitemsubreviewparams', PARAM_TEXT); // Launch container is set to 'LTI_LAUNCH_CONTAINER_DEFAULT', meaning it'll delegate to the tool's configuration. // Existing instances using values other than this can continue to use their existing value but cannot change it. $mform->addElement('hidden', 'launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT); $mform->setType('launchcontainer', PARAM_INT); // Included to support deep linking return, but hidden to avoid instructor modification. $mform->addElement('hidden', 'resourcekey', '', ['id' => 'id_resourcekey']); $mform->setType('resourcekey', PARAM_TEXT); $mform->addElement('hidden', 'password', '', ['id' => 'id_password']); $mform->setType('password', PARAM_TEXT); $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), ['rows' => 4, 'cols' => 60]); $mform->setType('instructorcustomparameters', PARAM_TEXT); $mform->setAdvanced('instructorcustomparameters'); $mform->addHelpButton('instructorcustomparameters', 'custom', 'lti'); $mform->setForceLtr('instructorcustomparameters'); $mform->addElement('hidden', 'icon', '', ['id' => 'id_icon']); $mform->setType('icon', PARAM_URL); $mform->addElement('hidden', 'secureicon', '', ['id' => 'id_secureicon']); $mform->setType('secureicon', PARAM_URL); // Add standard course module grading elements, and show them if the tool type + instance config permits it. if (!empty($config['acceptgrades']) && in_array($config['acceptgrades'], [LTI_SETTING_ALWAYS, LTI_SETTING_DELEGATE])) { $elementnamesbeforegrading = $this->_form->_elementIndex; $this->standard_grading_coursemodule_elements(); $elementnamesaftergrading = $this->_form->_elementIndex; // For all 'real' elements (not hidden or header) added as part of the standard grading elements, add a hideIf rule // making the element dependent on the 'accept grades from the tool' checkbox (instructorchoiceacceptgrades). $diff = array_diff($elementnamesaftergrading, $elementnamesbeforegrading); $diff = array_filter($diff, fn($key) => !in_array($this->_form->_elements[$key]->_type, ['hidden', 'header'])); foreach ($diff as $gradeelementname => $gradeelementindex) { $mform->hideIf($gradeelementname, 'instructorchoiceacceptgrades', 'eq', 0); } // Extend the grade section with the 'accept grades from the tool' checkbox, allowing per-instance overrides of that // value according to the following rules: // - Site tools with 'acceptgrades' set to 'ALWAYS' do not permit overrides at the instance level; the checkbox is // omitted in such cases. // - Site tools with 'acceptgrades' set to 'DELEGATE' result in a checkbox that is defaulted to unchecked but which // permits overrides to 'yes/checked'. // - Course tools with 'acceptgrades' set to 'ALWAYS' result in a checkbox that is defaulted to checked but which // permits overrides to 'no/unchecked'. // - Course tools with 'acceptgrades' set to 'DELEGATE' result in a checkbox that is defaulted to unchecked but which // permits overrides to 'yes/checked'. if (($issitetooltype && $config['acceptgrades'] == LTI_SETTING_DELEGATE) || !$issitetooltype) { $mform->insertElementBefore( $mform->createElement( 'advcheckbox', 'instructorchoiceacceptgrades', get_string('accept_grades_from_tool', 'mod_lti', $tooltype->name) ), array_keys($diff)[0] ); $acceptgradesdefault = !$issitetooltype && $config['acceptgrades'] == LTI_SETTING_ALWAYS ? '1' : '0'; $mform->setDefault('instructorchoiceacceptgrades', $acceptgradesdefault); $mform->disabledIf('instructorchoiceacceptgrades', 'typeid', 'in', [$toolproxytypeid]); // LTI 2 only. } } // Add standard elements, common to all modules. $this->standard_coursemodule_elements(); $mform->setAdvanced('cmidnumber'); // Add standard buttons, common to all modules. $this->add_action_buttons(); if ($supportscontentitemselection) { $jsparams = [$COURSE->id]; // If local-network-access is enabled, pass the tool URL as well. $jsparams[] = (isset($CFG->ltiallowlocalnetwork) && $CFG->ltiallowlocalnetwork) ? $tooltype->baseurl : ''; $PAGE->requires->js_call_amd('mod_lti/mod_form', 'init', $jsparams); } } /** * Sets the current values handled by services in case of update. * * @param object $defaultvalues default values to populate the form with. */ public function set_data($defaultvalues) { $services = lti_get_services(); if (is_object($defaultvalues)) { foreach ($services as $service) { $service->set_instance_form_values( $defaultvalues ); } } parent::set_data($defaultvalues); } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/forum/mod_form.php000064400000060372152267074240023124 0ustar00. /** * @package mod_forum * @copyright Jamie Pratt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page } require_once ($CFG->dirroot.'/course/moodleform_mod.php'); use core_grades\component_gradeitems; class mod_forum_mod_form extends moodleform_mod { function definition() { global $CFG, $COURSE, $DB; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('forumname', 'forum'), array('size'=>'64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(get_string('forumintro', 'forum')); $forumtypes = forum_get_forum_types(); core_collator::asort($forumtypes, core_collator::SORT_STRING); $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $forumtypes); $mform->addHelpButton('type', 'forumtype', 'forum'); $mform->setDefault('type', 'general'); $mform->addElement('header', 'availability', get_string('availability', 'forum')); $name = get_string('duedate', 'forum'); $mform->addElement('date_time_selector', 'duedate', $name, array('optional' => true)); $mform->addHelpButton('duedate', 'duedate', 'forum'); $name = get_string('cutoffdate', 'forum'); $mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional' => true)); $mform->addHelpButton('cutoffdate', 'cutoffdate', 'forum'); // Attachments and word count. $mform->addElement('header', 'attachmentswordcounthdr', get_string('attachmentswordcount', 'forum')); $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, 0, $CFG->forum_maxbytes); $choices[1] = get_string('uploadnotallowed'); $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices); $mform->addHelpButton('maxbytes', 'maxattachmentsize', 'forum'); $mform->setDefault('maxbytes', $CFG->forum_maxbytes); $choices = array( 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 20 => 20, 50 => 50, 100 => 100 ); $mform->addElement('select', 'maxattachments', get_string('maxattachments', 'forum'), $choices); $mform->addHelpButton('maxattachments', 'maxattachments', 'forum'); $mform->setDefault('maxattachments', $CFG->forum_maxattachments); $mform->addElement('selectyesno', 'displaywordcount', get_string('displaywordcount', 'forum')); $mform->addHelpButton('displaywordcount', 'displaywordcount', 'forum'); $mform->setDefault('displaywordcount', 0); // Subscription and tracking. $mform->addElement('header', 'subscriptionandtrackinghdr', get_string('subscriptionandtracking', 'forum')); $options = forum_get_subscriptionmode_options(); $mform->addElement('select', 'forcesubscribe', get_string('subscriptionmode', 'forum'), $options); $mform->addHelpButton('forcesubscribe', 'subscriptionmode', 'forum'); if (isset($CFG->forum_subscription)) { $defaultforumsubscription = $CFG->forum_subscription; } else { $defaultforumsubscription = FORUM_CHOOSESUBSCRIBE; } $mform->setDefault('forcesubscribe', $defaultforumsubscription); $options = array(); $options[FORUM_TRACKING_OPTIONAL] = get_string('trackingoptional', 'forum'); $options[FORUM_TRACKING_OFF] = get_string('trackingoff', 'forum'); if ($CFG->forum_allowforcedreadtracking) { $options[FORUM_TRACKING_FORCED] = get_string('trackingon', 'forum'); } $mform->addElement('select', 'trackingtype', get_string('trackingtype', 'forum'), $options); $mform->addHelpButton('trackingtype', 'trackingtype', 'forum'); $default = $CFG->forum_trackingtype; if ((!$CFG->forum_allowforcedreadtracking) && ($default == FORUM_TRACKING_FORCED)) { $default = FORUM_TRACKING_OPTIONAL; } $mform->setDefault('trackingtype', $default); if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) { //------------------------------------------------------------------------------- $mform->addElement('header', 'rssheader', get_string('rss')); $choices = array(); $choices[0] = get_string('none'); $choices[1] = get_string('discussions', 'forum'); $choices[2] = get_string('posts', 'forum'); $mform->addElement('select', 'rsstype', get_string('rsstype', 'forum'), $choices); $mform->addHelpButton('rsstype', 'rsstype', 'forum'); if (isset($CFG->forum_rsstype)) { $mform->setDefault('rsstype', $CFG->forum_rsstype); } $choices = array(); $choices[0] = '0'; $choices[1] = '1'; $choices[2] = '2'; $choices[3] = '3'; $choices[4] = '4'; $choices[5] = '5'; $choices[10] = '10'; $choices[15] = '15'; $choices[20] = '20'; $choices[25] = '25'; $choices[30] = '30'; $choices[40] = '40'; $choices[50] = '50'; $mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices); $mform->addHelpButton('rssarticles', 'rssarticles', 'forum'); $mform->hideIf('rssarticles', 'rsstype', 'eq', '0'); if (isset($CFG->forum_rssarticles)) { $mform->setDefault('rssarticles', $CFG->forum_rssarticles); } } $mform->addElement('header', 'discussionlocking', get_string('discussionlockingheader', 'forum')); $options = [ 0 => get_string('discussionlockingdisabled', 'forum'), 1 * DAYSECS => get_string('numday', 'core', 1), 1 * WEEKSECS => get_string('numweek', 'core', 1), 2 * WEEKSECS => get_string('numweeks', 'core', 2), 30 * DAYSECS => get_string('nummonth', 'core', 1), 60 * DAYSECS => get_string('nummonths', 'core', 2), 90 * DAYSECS => get_string('nummonths', 'core', 3), 180 * DAYSECS => get_string('nummonths', 'core', 6), 1 * YEARSECS => get_string('numyear', 'core', 1), ]; $mform->addElement('select', 'lockdiscussionafter', get_string('lockdiscussionafter', 'forum'), $options); $mform->addHelpButton('lockdiscussionafter', 'lockdiscussionafter', 'forum'); $mform->disabledIf('lockdiscussionafter', 'type', 'eq', 'single'); //------------------------------------------------------------------------------- $mform->addElement('header', 'blockafterheader', get_string('blockafter', 'forum')); $options = array(); $options[0] = get_string('blockperioddisabled','forum'); $options[60*60*24] = '1 '.get_string('day'); $options[60*60*24*2] = '2 '.get_string('days'); $options[60*60*24*3] = '3 '.get_string('days'); $options[60*60*24*4] = '4 '.get_string('days'); $options[60*60*24*5] = '5 '.get_string('days'); $options[60*60*24*6] = '6 '.get_string('days'); $options[60*60*24*7] = '1 '.get_string('week'); $mform->addElement('select', 'blockperiod', get_string('blockperiod', 'forum'), $options); $mform->addHelpButton('blockperiod', 'blockperiod', 'forum'); $mform->addElement('text', 'blockafter', get_string('blockafter', 'forum')); $mform->setType('blockafter', PARAM_INT); $mform->setDefault('blockafter', '0'); $mform->addRule('blockafter', null, 'numeric', null, 'client'); $mform->addHelpButton('blockafter', 'blockafter', 'forum'); $mform->hideIf('blockafter', 'blockperiod', 'eq', 0); $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum')); $mform->setType('warnafter', PARAM_INT); $mform->setDefault('warnafter', '0'); $mform->addRule('warnafter', null, 'numeric', null, 'client'); $mform->addHelpButton('warnafter', 'warnafter', 'forum'); $mform->hideIf('warnafter', 'blockperiod', 'eq', 0); //------------------------------------------------------------------------------- // Add the whole forum grading options. $this->add_forum_grade_settings($mform, 'forum'); $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- // buttons $this->add_action_buttons(); } /** * Add the whole forum grade settings to the mform. * * @param \mform $mform * @param string $itemname */ private function add_forum_grade_settings($mform, string $itemname) { global $COURSE; $component = "mod_{$this->_modname}"; $defaultgradingvalue = 0; $itemnumber = component_gradeitems::get_itemnumber_from_itemname($component, $itemname); $gradefieldname = component_gradeitems::get_field_name_for_itemnumber($component, $itemnumber, 'grade'); $gradecatfieldname = component_gradeitems::get_field_name_for_itemnumber($component, $itemnumber, 'gradecat'); $gradepassfieldname = component_gradeitems::get_field_name_for_itemnumber($component, $itemnumber, 'gradepass'); // The advancedgradingmethod is different in that it is suffixed with an area name... which is not the // itemnumber. $methodfieldname = "advancedgradingmethod_{$itemname}"; $headername = "{$gradefieldname}_header"; $mform->addElement('header', $headername, get_string("grade_{$itemname}_header", $component)); $isupdate = !empty($this->_cm); $gradeoptions = [ 'isupdate' => $isupdate, 'currentgrade' => false, 'hasgrades' => false, 'canrescale' => false, 'useratings' => false, ]; if ($isupdate) { $gradeitem = grade_item::fetch([ 'itemtype' => 'mod', 'itemmodule' => $this->_cm->modname, 'iteminstance' => $this->_cm->instance, 'itemnumber' => $itemnumber, 'courseid' => $COURSE->id, ]); if ($gradeitem) { $gradeoptions['currentgrade'] = $gradeitem->grademax; $gradeoptions['currentgradetype'] = $gradeitem->gradetype; $gradeoptions['currentscaleid'] = $gradeitem->scaleid; $gradeoptions['hasgrades'] = $gradeitem->has_grades(); } } $mform->addElement( 'modgrade', $gradefieldname, get_string("{$gradefieldname}_title", $component), $gradeoptions ); $mform->addHelpButton($gradefieldname, 'modgrade', 'grades'); $mform->setDefault($gradefieldname, $defaultgradingvalue); if (!empty($this->current->_advancedgradingdata['methods']) && !empty($this->current->_advancedgradingdata['areas'])) { $areadata = $this->current->_advancedgradingdata['areas'][$itemname]; $mform->addElement( 'select', $methodfieldname, get_string('gradingmethod', 'core_grading'), $this->current->_advancedgradingdata['methods'] ); $mform->addHelpButton($methodfieldname, 'gradingmethod', 'core_grading'); $mform->hideIf($methodfieldname, "{$gradefieldname}[modgrade_type]", 'eq', 'none'); } // Grade category. $mform->addElement( 'select', $gradecatfieldname, get_string('gradecategoryonmodform', 'grades'), grade_get_categories_menu($COURSE->id, $this->_outcomesused) ); $mform->addHelpButton($gradecatfieldname, 'gradecategoryonmodform', 'grades'); $mform->hideIf($gradecatfieldname, "{$gradefieldname}[modgrade_type]", 'eq', 'none'); // Grade to pass. $mform->addElement('text', $gradepassfieldname, get_string('gradepass', 'grades')); $mform->addHelpButton($gradepassfieldname, 'gradepass', 'grades'); $mform->setDefault($gradepassfieldname, ''); $mform->setType($gradepassfieldname, PARAM_RAW); $mform->hideIf($gradepassfieldname, "{$gradefieldname}[modgrade_type]", 'eq', 'none'); $mform->addElement('selectyesno', 'grade_forum_notify', get_string('sendstudentnotificationsdefault', 'forum')); $mform->addHelpButton('grade_forum_notify', 'sendstudentnotificationsdefault', 'forum'); $mform->hideIf('grade_forum_notify', "{$gradefieldname}[modgrade_type]", 'eq', 'none'); } function definition_after_data() { parent::definition_after_data(); $mform =& $this->_form; $type =& $mform->getElement('type'); $typevalue = $mform->getElementValue('type'); //we don't want to have these appear as possible selections in the form but //we want the form to display them if they are set. if ($typevalue[0]=='news') { $type->addOption(get_string('namenews', 'forum'), 'news'); $mform->addHelpButton('type', 'namenews', 'forum'); $type->freeze(); $type->setPersistantFreeze(true); } if ($typevalue[0]=='social') { $type->addOption(get_string('namesocial', 'forum'), 'social'); $type->freeze(); $type->setPersistantFreeze(true); } } public function validation($data, $files) { $errors = parent::validation($data, $files); if ($data['type'] === 'single' && $data['groupmode'] == SEPARATEGROUPS) { $errors['type'] = get_string('cannotusesingletopicandseperategroups', 'forum'); $errors['groupmode'] = get_string('cannotuseseperategroupsandsingletopic', 'forum'); } if ($data['duedate'] && $data['cutoffdate']) { if ($data['duedate'] > $data['cutoffdate']) { $errors['cutoffdate'] = get_string('cutoffdatevalidation', 'forum'); } } $this->validation_forum_grade($data, $files, $errors); return $errors; } /** * Handle definition after data for grade settings. * * @param array $data * @param array $files * @param array $errors */ private function validation_forum_grade(array $data, array $files, array $errors) { global $COURSE; $mform =& $this->_form; $component = "mod_forum"; $itemname = 'forum'; $itemnumber = component_gradeitems::get_itemnumber_from_itemname($component, $itemname); $gradefieldname = component_gradeitems::get_field_name_for_itemnumber($component, $itemnumber, 'grade'); $gradepassfieldname = component_gradeitems::get_field_name_for_itemnumber($component, $itemnumber, 'grade'); $gradeitem = grade_item::fetch([ 'itemtype' => 'mod', 'itemmodule' => $data['modulename'], 'iteminstance' => $data['instance'], 'itemnumber' => $itemnumber, 'courseid' => $COURSE->id, ]); if ($mform->elementExists('cmidnumber') && $this->_cm) { if (!grade_verify_idnumber($data['cmidnumber'], $COURSE->id, $gradeitem, $this->_cm)) { $errors['cmidnumber'] = get_string('idnumbertaken'); } } // Check that the grade pass is a valid number. $gradepassvalid = false; if (isset($data[$gradepassfieldname])) { if (unformat_float($data[$gradepassfieldname], true) === false) { $errors[$gradepassfieldname] = get_string('err_numeric', 'form'); } else { $gradepassvalid = true; } } // Grade to pass: ensure that the grade to pass is valid for points and scales. // If we are working with a scale, convert into a positive number for validation. if ($gradepassvalid && isset($data[$gradepassfieldname]) && (!empty($data[$gradefieldname]))) { $grade = $data[$gradefieldname]; if (unformat_float($data[$gradepassfieldname]) > $grade) { $errors[$gradepassfieldname] = get_string('gradepassgreaterthangrade', 'grades', $grade); } } } public function data_preprocessing(&$defaultvalues) { parent::data_preprocessing($defaultvalues); $suffix = $this->get_suffix(); $completiondiscussionsenabledel = 'completiondiscussionsenabled' . $suffix; $completiondiscussionsel = 'completiondiscussions' . $suffix; $completionrepliesenabledel = 'completionrepliesenabled' . $suffix; $completionrepliesel = 'completionreplies' . $suffix; $completionpostsel = 'completionposts' . $suffix; $completionpostsenabledel = 'completionpostsenabled' . $suffix; // Set up the completion checkboxes which aren't part of standard data. // We also make the default value (if you turn on the checkbox) for those // numbers to be 1, this will not apply unless checkbox is ticked. $defaultvalues[$completiondiscussionsenabledel] = !empty($defaultvalues[$completiondiscussionsel]) ? 1 : 0; if (empty($defaultvalues[$completiondiscussionsel])) { $defaultvalues[$completiondiscussionsel] = 1; } $defaultvalues[$completionrepliesenabledel] = !empty($defaultvalues[$completionrepliesel]) ? 1 : 0; if (empty($defaultvalues[$completionrepliesel])) { $defaultvalues[$completionrepliesel] = 1; } // Tick by default if Add mode or if completion posts settings is set to 1 or more. if (empty($this->_instance) || !empty($defaultvalues[$completionpostsel])) { $defaultvalues[$completionpostsenabledel] = 1; } else { $defaultvalues[$completionpostsenabledel] = 0; } if (empty($defaultvalues[$completionpostsel])) { $defaultvalues[$completionpostsel] = 1; } } /** * Add custom completion rules. * * @return array Array of string IDs of added items, empty array if none */ public function add_completion_rules() { $mform = $this->_form; $suffix = $this->get_suffix(); $group = []; $completionpostsenabledel = 'completionpostsenabled' . $suffix; $group[] =& $mform->createElement('checkbox', $completionpostsenabledel, '', get_string('completionposts', 'forum')); $completionpostsel = 'completionposts' . $suffix; $group[] =& $mform->createElement('text', $completionpostsel, '', ['size' => 3]); $mform->setType($completionpostsel, PARAM_INT); $completionpostsgroupel = 'completionpostsgroup' . $suffix; $mform->addGroup($group, $completionpostsgroupel, '', ' ', false); $mform->hideIf($completionpostsel, $completionpostsenabledel, 'notchecked'); $group = []; $completiondiscussionsenabledel = 'completiondiscussionsenabled' . $suffix; $group[] =& $mform->createElement( 'checkbox', $completiondiscussionsenabledel, '', get_string('completiondiscussions', 'forum') ); $completiondiscussionsel = 'completiondiscussions' . $suffix; $group[] =& $mform->createElement('text', $completiondiscussionsel, '', ['size' => 3]); $mform->setType($completiondiscussionsel, PARAM_INT); $completiondiscussionsgroupel = 'completiondiscussionsgroup' . $suffix; $mform->addGroup($group, $completiondiscussionsgroupel, '', ' ', false); $mform->hideIf($completiondiscussionsel, $completiondiscussionsenabledel, 'notchecked'); $group = []; $completionrepliesenabledel = 'completionrepliesenabled' . $suffix; $group[] =& $mform->createElement('checkbox', $completionrepliesenabledel, '', get_string('completionreplies', 'forum')); $completionrepliesel = 'completionreplies' . $suffix; $group[] =& $mform->createElement('text', $completionrepliesel, '', ['size' => 3]); $mform->setType($completionrepliesel, PARAM_INT); $completionrepliesgroupel = 'completionrepliesgroup' . $suffix; $mform->addGroup($group, $completionrepliesgroupel, '', ' ', false); $mform->hideIf($completionrepliesel, $completionrepliesenabledel, 'notchecked'); return [$completiondiscussionsgroupel, $completionrepliesgroupel, $completionpostsgroupel]; } public function completion_rule_enabled($data) { $suffix = $this->get_suffix(); return (!empty($data['completiondiscussionsenabled' . $suffix]) && $data['completiondiscussions' . $suffix] != 0) || (!empty($data['completionrepliesenabled' . $suffix]) && $data['completionreplies' . $suffix] != 0) || (!empty($data['completionpostsenabled' . $suffix]) && $data['completionposts' . $suffix] != 0); } /** * Return submitted data if properly submitted or returns NULL if validation fails or * if there is no submitted data. * * Do not override this method, override data_postprocessing() instead. * * @return object submitted data; NULL if not valid or not submitted or cancelled */ public function get_data() { $data = parent::get_data(); if ($data) { $itemname = 'forum'; $component = 'mod_forum'; $gradepassfieldname = component_gradeitems::get_field_name_for_itemname($component, $itemname, 'gradepass'); // Convert the grade pass value - we may be using a language which uses commas, // rather than decimal points, in numbers. These need to be converted so that // they can be added to the DB. if (isset($data->{$gradepassfieldname})) { $data->{$gradepassfieldname} = unformat_float($data->{$gradepassfieldname}); } } return $data; } /** * Allows module to modify the data returned by form get_data(). * This method is also called in the bulk activity completion form. * * Only available on moodleform_mod. * * @param stdClass $data the form data to be modified. */ public function data_postprocessing($data) { parent::data_postprocessing($data); // Turn off completion settings if the checkboxes aren't ticked. if (!empty($data->completionunlocked)) { $suffix = $this->get_suffix(); $completion = $data->{'completion' . $suffix}; $autocompletion = !empty($completion) && $completion == COMPLETION_TRACKING_AUTOMATIC; if (empty($data->{'completiondiscussionsenabled' . $suffix}) || !$autocompletion) { $data->{'completiondiscussions' . $suffix} = 0; } if (empty($data->{'completionrepliesenabled' . $suffix}) || !$autocompletion) { $data->{'completionreplies' . $suffix} = 0; } if (empty($data->{'completionpostsenabled' . $suffix}) || !$autocompletion) { $data->{'completionposts' . $suffix} = 0; } } } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/assign/mod_form.php000064400000051665152267105330023260 0ustar00. /** * This file contains the forms to create and edit an instance of this module * * @package mod_assign * @copyright 2012 NetSpot {@link http://www.netspot.com.au} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); require_once($CFG->dirroot.'/course/moodleform_mod.php'); require_once($CFG->dirroot . '/mod/assign/locallib.php'); /** * Assignment settings form. * * @package mod_assign * @copyright 2012 NetSpot {@link http://www.netspot.com.au} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_assign_mod_form extends moodleform_mod { /** * Called to define this moodle form * * @return void */ public function definition() { global $CFG, $COURSE, $OUTPUT;; $mform = $this->_form; $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('assignmentname', 'assign'), array('size'=>'64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(get_string('description', 'assign')); // Activity. $mform->addElement('editor', 'activityeditor', get_string('activityeditor', 'assign'), array('rows' => 10), array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $this->context, 'subdirs' => true)); $mform->addHelpButton('activityeditor', 'activityeditor', 'assign'); $mform->setType('activityeditor', PARAM_RAW); $mform->addElement('filemanager', 'introattachments', get_string('introattachments', 'assign'), null, array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes) ); $mform->addHelpButton('introattachments', 'introattachments', 'assign'); $mform->addElement('advcheckbox', 'submissionattachments', get_string('submissionattachments', 'assign')); $mform->addHelpButton('submissionattachments', 'submissionattachments', 'assign'); [$assignment] = $this->get_assign(); $mform->addElement('header', 'availability', get_string('availability', 'assign')); $mform->setExpanded('availability', true); $name = get_string('allowsubmissionsfromdate', 'assign'); $options = array('optional'=>true); $mform->addElement('date_time_selector', 'allowsubmissionsfromdate', $name, $options); $mform->addHelpButton('allowsubmissionsfromdate', 'allowsubmissionsfromdate', 'assign'); // Add the option to recalculate the penalty if there is existing grade. $penaltysettingmessage = ''; if ($assignment->has_instance() && \mod_assign\penalty\helper::is_penalty_enabled($assignment->get_instance()->id) && $assignment->count_grades() > 0) { // Create notification. $penaltysettingmessage = $OUTPUT->notification(get_string('penaltyduedatechangemessage', 'assign'), 'warning', false); $mform->addElement('html', $penaltysettingmessage); $mform->addElement('select', 'recalculatepenalty', get_string('modgraderecalculatepenalty', 'grades'), [ '' => get_string('choose'), 'no' => get_string('no'), 'yes' => get_string('yes'), ]); $mform->addHelpButton('recalculatepenalty', 'modgraderecalculatepenalty', 'grades'); } $name = get_string('duedate', 'assign'); $mform->addElement('date_time_selector', 'duedate', $name, array('optional'=>true)); $mform->addHelpButton('duedate', 'duedate', 'assign'); $mform->disabledIf('duedate', 'recalculatepenalty', 'eq', ''); $name = get_string('cutoffdate', 'assign'); $mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional'=>true)); $mform->addHelpButton('cutoffdate', 'cutoffdate', 'assign'); $name = get_string('gradingduedate', 'assign'); $mform->addElement('date_time_selector', 'gradingduedate', $name, array('optional' => true)); $mform->addHelpButton('gradingduedate', 'gradingduedate', 'assign'); $timelimitenabled = get_config('assign', 'enabletimelimit'); // Time limit. if ($timelimitenabled) { $mform->addElement('duration', 'timelimit', get_string('timelimit', 'assign'), array('optional' => true)); $mform->addHelpButton('timelimit', 'timelimit', 'assign'); } $name = get_string('alwaysshowdescription', 'assign'); $mform->addElement('checkbox', 'alwaysshowdescription', $name); $mform->addHelpButton('alwaysshowdescription', 'alwaysshowdescription', 'assign'); $mform->disabledIf('alwaysshowdescription', 'allowsubmissionsfromdate[enabled]', 'notchecked'); $assignment->add_all_plugin_settings($mform); $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'assign')); $name = get_string('submissiondrafts', 'assign'); $mform->addElement('selectyesno', 'submissiondrafts', $name); $mform->addHelpButton('submissiondrafts', 'submissiondrafts', 'assign'); if ($assignment->has_submissions_or_grades()) { $mform->freeze('submissiondrafts'); } $name = get_string('requiresubmissionstatement', 'assign'); $mform->addElement('selectyesno', 'requiresubmissionstatement', $name); $mform->addHelpButton('requiresubmissionstatement', 'requiresubmissionstatement', 'assign'); $mform->setType('requiresubmissionstatement', PARAM_BOOL); $options = [ASSIGN_UNLIMITED_ATTEMPTS => get_string('unlimitedattempts', 'mod_assign')]; $options += array_combine(range(1, 30), range(1, 30)); $mform->addElement('select', 'maxattempts', get_string('maxattempts', 'mod_assign'), $options); $mform->addHelpButton('maxattempts', 'maxattempts', 'assign'); $choice = new core\output\choicelist(); $choice->add_option( value: ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL, name: get_string('attemptreopenmethod_manual', 'mod_assign'), definition: ['description' => get_string('attemptreopenmethod_manual_help', 'mod_assign')] ); $choice->add_option( value: ASSIGN_ATTEMPT_REOPEN_METHOD_AUTOMATIC, name: get_string('attemptreopenmethod_automatic', 'mod_assign'), definition: ['description' => get_string('attemptreopenmethod_automatic_help', 'mod_assign')] ); $choice->add_option( value: ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS, name: get_string('attemptreopenmethod_untilpass', 'mod_assign'), definition: ['description' => get_string('attemptreopenmethod_untilpass_help', 'mod_assign')] ); $mform->addElement('choicedropdown', 'attemptreopenmethod', get_string('attemptreopenmethod', 'mod_assign'), $choice); $mform->hideIf('attemptreopenmethod', 'maxattempts', 'eq', 1); $mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'assign')); $name = get_string('teamsubmission', 'assign'); $mform->addElement('selectyesno', 'teamsubmission', $name); $mform->addHelpButton('teamsubmission', 'teamsubmission', 'assign'); if ($assignment->has_submissions_or_grades()) { $mform->freeze('teamsubmission'); } $name = get_string('preventsubmissionnotingroup', 'assign'); $mform->addElement('selectyesno', 'preventsubmissionnotingroup', $name); $mform->addHelpButton('preventsubmissionnotingroup', 'preventsubmissionnotingroup', 'assign'); $mform->setType('preventsubmissionnotingroup', PARAM_BOOL); $mform->hideIf('preventsubmissionnotingroup', 'teamsubmission', 'eq', 0); $name = get_string('requireallteammemberssubmit', 'assign'); $mform->addElement('selectyesno', 'requireallteammemberssubmit', $name); $mform->addHelpButton('requireallteammemberssubmit', 'requireallteammemberssubmit', 'assign'); $mform->hideIf('requireallteammemberssubmit', 'teamsubmission', 'eq', 0); $mform->disabledIf('requireallteammemberssubmit', 'submissiondrafts', 'eq', 0); $groupings = groups_get_all_groupings($assignment->get_course()->id); $options = array(); $options[0] = get_string('none'); foreach ($groupings as $grouping) { $options[$grouping->id] = $grouping->name; } $name = get_string('teamsubmissiongroupingid', 'assign'); $mform->addElement('select', 'teamsubmissiongroupingid', $name, $options); $mform->addHelpButton('teamsubmissiongroupingid', 'teamsubmissiongroupingid', 'assign'); $mform->hideIf('teamsubmissiongroupingid', 'teamsubmission', 'eq', 0); if ($assignment->has_submissions_or_grades()) { $mform->freeze('teamsubmissiongroupingid'); } $mform->addElement('header', 'notifications', get_string('notifications', 'assign')); $name = get_string('sendnotifications', 'assign'); $mform->addElement('selectyesno', 'sendnotifications', $name); $mform->addHelpButton('sendnotifications', 'sendnotifications', 'assign'); $name = get_string('sendlatenotifications', 'assign'); $mform->addElement('selectyesno', 'sendlatenotifications', $name); $mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'assign'); $mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1); $name = get_string('sendstudentnotificationsdefault', 'assign'); $mform->addElement('selectyesno', 'sendstudentnotifications', $name); $mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'assign'); $this->standard_grading_coursemodule_elements(); $name = get_string('blindmarking', 'assign'); $mform->addElement('selectyesno', 'blindmarking', $name); $mform->addHelpButton('blindmarking', 'blindmarking', 'assign'); if ($assignment->has_submissions_or_grades() ) { $mform->freeze('blindmarking'); } $name = get_string('hidegrader', 'assign'); $mform->addElement('selectyesno', 'hidegrader', $name); $mform->addHelpButton('hidegrader', 'hidegrader', 'assign'); $name = get_string('markingworkflow', 'assign'); $mform->addElement('selectyesno', 'markingworkflow', $name); $mform->addHelpButton('markingworkflow', 'markingworkflow', 'assign'); $name = get_string('markingallocation', 'assign'); $mform->addElement('selectyesno', 'markingallocation', $name); $mform->addHelpButton('markingallocation', 'markingallocation', 'assign'); $mform->hideIf('markingallocation', 'markingworkflow', 'eq', 0); $name = get_string('markinganonymous', 'assign'); $mform->addElement('selectyesno', 'markinganonymous', $name); $mform->addHelpButton('markinganonymous', 'markinganonymous', 'assign'); $mform->hideIf('markinganonymous', 'markingworkflow', 'eq', 0); $mform->hideIf('markinganonymous', 'blindmarking', 'eq', 0); // Add Penalty settings if the module supports it. if (\core_grades\penalty_manager::is_penalty_enabled_for_module('assign')) { // Show the message if we need to change the penalty settings. if (!empty($penaltysettingmessage)) { $mform->addElement('html', $penaltysettingmessage); } // Enable or disable the penalty settings. $mform->addElement('selectyesno', 'gradepenalty', get_string('gradepenalty', 'mod_assign')); $mform->addHelpButton('gradepenalty', 'gradepenalty', 'mod_assign'); $mform->setDefault('gradepenalty', 0); // Hide if the due date is not enabled. $mform->hideIf('gradepenalty', 'duedate[enabled]'); // Hide if the grade type is not set to point. $mform->hideIf('gradepenalty', 'grade[modgrade_type]', 'neq', 'point'); // Disable if the recalculate penalty is not set. $mform->disabledIf('gradepenalty', 'recalculatepenalty', 'eq', ''); } $this->standard_coursemodule_elements(); $this->apply_admin_defaults(); $this->add_action_buttons(); } /** * Override definition after data has been set. * * The value of date time selector will be lost in a POST request, if the selector is disabled. * So, we need to set the value again. * * return void */ public function definition_after_data() { parent::definition_after_data(); $mform = $this->_form; // The value of date time selector will be lost in a POST request. $recalculatepenalty = optional_param('recalculatepenalty', null, PARAM_TEXT); if ($recalculatepenalty === '') { $mform->setConstant('duedate', $mform->_defaultValues['duedate']); } } /** * Perform minimal validation on the settings form * @param array $data * @param array $files */ public function validation($data, $files) { $errors = parent::validation($data, $files); if (!empty($data['allowsubmissionsfromdate']) && !empty($data['duedate'])) { if ($data['duedate'] <= $data['allowsubmissionsfromdate']) { $errors['duedate'] = get_string('duedateaftersubmissionvalidation', 'assign'); } } if (!empty($data['cutoffdate']) && !empty($data['duedate'])) { if ($data['cutoffdate'] < $data['duedate'] ) { $errors['cutoffdate'] = get_string('cutoffdatevalidation', 'assign'); } } if (!empty($data['allowsubmissionsfromdate']) && !empty($data['cutoffdate'])) { if ($data['cutoffdate'] < $data['allowsubmissionsfromdate']) { $errors['cutoffdate'] = get_string('cutoffdatefromdatevalidation', 'assign'); } } if ($data['gradingduedate']) { if ($data['allowsubmissionsfromdate'] && $data['allowsubmissionsfromdate'] > $data['gradingduedate']) { $errors['gradingduedate'] = get_string('gradingduefromdatevalidation', 'assign'); } if ($data['duedate'] && $data['duedate'] > $data['gradingduedate']) { $errors['gradingduedate'] = get_string('gradingdueduedatevalidation', 'assign'); } } $multipleattemptsallowed = $data['maxattempts'] > 1 || $data['maxattempts'] == ASSIGN_UNLIMITED_ATTEMPTS; if ($data['blindmarking'] && $multipleattemptsallowed && $data['attemptreopenmethod'] == ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS) { $errors['attemptreopenmethod'] = get_string('reopenuntilpassincompatiblewithblindmarking', 'assign'); } [$assignment] = $this->get_assign(); $errors = array_merge($errors, $assignment->plugin_settings_validation($data, $files)); return $errors; } /** * Any data processing needed before the form is displayed * (needed to set up draft areas for editor and filemanager elements) * @param array $defaultvalues */ public function data_preprocessing(&$defaultvalues) { [$assignment, $ctx] = $this->get_assign(); $draftitemid = file_get_submitted_draft_itemid('introattachments'); file_prepare_draft_area($draftitemid, $ctx->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0, array('subdirs' => 0)); $defaultvalues['introattachments'] = $draftitemid; // Activity editor fields. $activitydraftitemid = file_get_submitted_draft_itemid('activityeditor'); if (!empty($defaultvalues['activity'])) { $defaultvalues['activityeditor'] = array( 'text' => file_prepare_draft_area($activitydraftitemid, $ctx->id, 'mod_assign', ASSIGN_ACTIVITYATTACHMENT_FILEAREA, 0, array('subdirs' => 0), $defaultvalues['activity']), 'format' => $defaultvalues['activityformat'], 'itemid' => $activitydraftitemid ); } $assignment->plugin_data_preprocessing($defaultvalues); } /** * Add any custom completion rules to the form. * * @return array Contains the names of the added form elements */ public function add_completion_rules() { $mform =& $this->_form; $suffix = $this->get_suffix(); $completionsubmitel = 'completionsubmit' . $suffix; $mform->addElement('advcheckbox', $completionsubmitel, '', get_string('completionsubmit', 'assign')); // Enable this completion rule by default. $mform->setDefault($completionsubmitel, 1); return [$completionsubmitel]; } /** * Determines if completion is enabled for this module. * * @param array $data * @return bool */ public function completion_rule_enabled($data) { $suffix = $this->get_suffix(); return !empty($data['completionsubmit' . $suffix]); } /** * Get the list of admin settings for this module and apply any defaults/advanced/locked/required settings. * * @param array $datetimeoffsets - If passed, this is an array of fieldnames => times that the * default date/time value should be relative to. If not passed, all * date/time fields are set relative to the users current midnight. * @return void */ public function apply_admin_defaults($datetimeoffsets = []): void { parent::apply_admin_defaults($datetimeoffsets); $isupdate = !empty($this->_cm); if ($isupdate) { return; } $settings = get_config('mod_assign'); $mform = $this->_form; if ($mform->elementExists('grade')) { $element = $mform->getElement('grade'); if (property_exists($settings, 'defaultgradetype')) { $modgradetype = $element->getName() . '[modgrade_type]'; switch ((int)$settings->defaultgradetype) { case GRADE_TYPE_NONE : $mform->setDefault($modgradetype, 'none'); break; case GRADE_TYPE_SCALE : $mform->setDefault($modgradetype, 'scale'); break; case GRADE_TYPE_VALUE : $mform->setDefault($modgradetype, 'point'); break; } } if (property_exists($settings, 'defaultgradescale')) { /** @var grade_scale|false $gradescale */ $gradescale = grade_scale::fetch(['id' => (int)$settings->defaultgradescale, 'courseid' => 0]); if ($gradescale) { $mform->setDefault($element->getName() . '[modgrade_scale]', $gradescale->id); } } } } /** * Get a relevant assign instance for this form, and the context. * * If we are editing an existing assign, it is that assignment and context, otherwise it is for the course context. * * @return array [$assignment, $ctx] the assignment object and the context. */ protected function get_assign(): array { global $DB; $ctx = null; if ($this->current && $this->current->coursemodule) { $cm = get_coursemodule_from_instance('assign', $this->current->id, 0, false, MUST_EXIST); $ctx = context_module::instance($cm->id); } $assignment = new assign($ctx, null, null); if ($this->current && $this->current->course) { if (!$ctx) { $ctx = context_course::instance($this->current->course); } $course = $DB->get_record('course', ['id' => $this->current->course], '*', MUST_EXIST); $assignment->set_course($course); } return [$assignment, $ctx]; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/qbank/mod_form.php000064400000012331152267107310023053 0ustar00. defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/course/moodleform_mod.php'); /** * mod_qbank settings form definition. * * @package mod_qbank * @copyright 2024 onwards Catalyst IT EU {@link https://catalyst-eu.net} * @author Simon Adams * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_qbank_mod_form extends moodleform_mod { #[\Override] protected function definition(): void { global $CFG; $mform = $this->_form; $striptags = !empty($CFG->formatstringstriptags); $this->standard_hidden_coursemodule_elements(); // We need to force visibility on this here as we don't need the other standard course elements. $mform->addElement('hidden', 'visible', 0); $mform->setType('visible', PARAM_INT); $mform->addElement('hidden', 'type'); $mform->setDefaults('type', \core_question\local\bank\question_bank_helper::TYPE_STANDARD); $mform->setType('type', PARAM_TEXT); $mform->addElement('header', 'generalhdr', get_string('general')); // Add element for name. $mform->addElement('text', 'name', get_string('qbankname', 'mod_qbank'), ['size' => '64']); if ($striptags) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addHelpButton('name', 'qbankname', 'mod_qbank'); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', null, 'maxlength', \core_question\local\bank\question_bank_helper::BANK_NAME_MAX_LENGTH, 'client'); // Add intro editor. $mform->addElement('editor', 'introeditor', get_string('moduleintro'), ['rows' => 10], [ 'maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $this->context, 'subdirs' => true, ]); $mform->setType('introeditor', PARAM_RAW); // No XSS prevention here, users must be trusted. if ($CFG->requiremodintro) { $mform->addRule('introeditor', get_string('required'), 'required', null, 'client'); } // Add show description checkbox. $mform->addElement('advcheckbox', 'showdescription', get_string('showdescription', 'mod_qbank')); $mform->addHelpButton('showdescription', 'showdescription', 'mod_qbank'); $mform->addElement('header', 'modstandardelshdr', get_string('modstandardels', 'form')); // Add idnumber element. $mform->addElement('text', 'cmidnumber', get_string('idnumbermod')); if ($striptags) { $mform->setType('cmidnumber', PARAM_TEXT); } else { $mform->setType('cmidnumber', PARAM_CLEANHTML); } $mform->addHelpButton('cmidnumber', 'idnumbermod'); // Add our submission buttons. $buttonarray[] = $mform->createElement('submit', 'submitbutton2', get_string('saveandreturn', 'mod_qbank')); $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('saveanddisplay', 'mod_qbank')); $buttonarray[] = $mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', [' '], false); $mform->setType('buttonar', PARAM_RAW); } #[\Override] public function validation($data, $files): array { global $DB; $mform = $this->_form; // We don't want the parent validation as it has completion settings which we don't use. // Best call the grandparent though in case it changes in the future. $errors = moodleform::validation($data, $files); if ($mform->elementExists('name')) { $name = trim($data['name']); if ($name === '') { $errors['name'] = get_string('required'); } } if (!empty($data['cmidnumber'])) { $idnumexists = $DB->record_exists_select( 'course_modules', 'id <> :id AND course = :course AND idnumber = :idnumber', ['course' => $data['course'], 'idnumber' => $data['cmidnumber'], 'id' => $data['coursemodule'] ?? null] ); if ($idnumexists) { $errors['cmidnumber'] = get_string('idnumbertaken'); } } if (!empty($data['type']) && !in_array($data['type'], core_question\local\bank\question_bank_helper::SHARED_TYPES, true)) { $errors['type'] = get_string('unknownbanktype', 'mod_qbank', $data['type']); } return $errors; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/mod/h5pactivity/mod_form.php000064400000023514152267113460024240 0ustar00. /** * The main mod_h5pactivity configuration form. * * @package mod_h5pactivity * @copyright 2020 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ use mod_h5pactivity\local\manager; defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot.'/course/moodleform_mod.php'); /** * Module instance settings form. * * @package mod_h5pactivity * @copyright 2020 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_h5pactivity_mod_form extends moodleform_mod { /** * Defines forms elements */ public function definition(): void { global $CFG, $OUTPUT; $mform = $this->_form; // Adding the "general" fieldset, where all the common settings are shown. $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field. $mform->addElement('text', 'name', get_string('name'), ['size' => '64']); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(); // Adding the rest of mod_h5pactivity settings, spreading all them into this fieldset. $options = []; $options['accepted_types'] = ['.h5p']; $options['maxbytes'] = 0; $options['maxfiles'] = 1; $options['subdirs'] = 0; $mform->addElement('filemanager', 'packagefile', get_string('package', 'mod_h5pactivity'), null, $options); $mform->addHelpButton('packagefile', 'package', 'mod_h5pactivity'); $mform->addRule('packagefile', null, 'required'); // Add a link to the Content Bank if the user can access. $course = $this->get_course(); $coursecontext = context_course::instance($course->id); if (has_capability('moodle/contentbank:access', $coursecontext)) { $msg = null; $context = $this->get_context(); if ($context instanceof \context_module) { // This is an existing activity. If the H5P file it's a referenced file from the content bank, a link for // displaying this specific content will be used instead of the generic link to the main page of the content bank. $fs = get_file_storage(); $files = $fs->get_area_files($context->id, 'mod_h5pactivity', 'package', 0, 'sortorder, itemid, filepath, filename', false); $file = reset($files); if ($file && $file->get_reference() != null) { $referencedfile = \repository::get_moodle_file($file->get_reference()); if ($referencedfile->get_component() == 'contentbank') { // If the attached file is a referencedfile in the content bank, display a link to open this content. $url = new moodle_url('/contentbank/view.php', ['id' => $referencedfile->get_itemid()]); $msg = get_string('opencontentbank', 'mod_h5pactivity', $url->out()); $msg .= ' '.$OUTPUT->help_icon('contentbank', 'mod_h5pactivity'); } } } if (!isset($msg)) { $url = new moodle_url('/contentbank/index.php', ['contextid' => $coursecontext->id]); $msg = get_string('usecontentbank', 'mod_h5pactivity', $url->out()); $msg .= ' '.$OUTPUT->help_icon('contentbank', 'mod_h5pactivity'); } $mform->addElement('static', 'contentbank', '', $msg); } // H5P displaying options. $factory = new \core_h5p\factory(); $core = $factory->get_core(); $displayoptions = (array) \core_h5p\helper::decode_display_options($core); $mform->addElement('header', 'h5pdisplay', get_string('h5pdisplay', 'mod_h5pactivity')); foreach ($displayoptions as $key => $value) { $name = get_string('display'.$key, 'mod_h5pactivity'); $fieldname = "displayopt[$key]"; $mform->addElement('checkbox', $fieldname, $name); $mform->setType($fieldname, PARAM_BOOL); } // Add standard grading elements. $this->standard_grading_coursemodule_elements(); // Attempt options. $mform->addElement('header', 'h5pattempts', get_string('h5pattempts', 'mod_h5pactivity')); $mform->addElement('static', 'trackingwarning', '', get_string('tracking_messages', 'mod_h5pactivity')); $options = [1 => get_string('yes'), 0 => get_string('no')]; $mform->addElement('select', 'enabletracking', get_string('enabletracking', 'mod_h5pactivity'), $options); $mform->setDefault('enabletracking', 1); $options = manager::get_grading_methods(); $mform->addElement('select', 'grademethod', get_string('grade_grademethod', 'mod_h5pactivity'), $options); $mform->setType('grademethod', PARAM_INT); $mform->hideIf('grademethod', 'enabletracking', 'neq', 1); $mform->disabledIf('grademethod', 'grade[modgrade_type]', 'neq', 'point'); $mform->addHelpButton('grademethod', 'grade_grademethod', 'mod_h5pactivity'); $options = manager::get_review_modes(); $mform->addElement('select', 'reviewmode', get_string('review_mode', 'mod_h5pactivity'), $options); $mform->setType('reviewmode', PARAM_INT); $mform->hideIf('reviewmode', 'enabletracking', 'neq', 1); // Add standard elements. $this->standard_coursemodule_elements(); // Add standard buttons. $this->add_action_buttons(); } /** * Enforce validation rules here * * @param array $data array of ("fieldname"=>value) of submitted data * @param array $files array of uploaded files "element_name"=>tmp_file_path * @return array **/ public function validation($data, $files) { global $USER; $errors = parent::validation($data, $files); if (empty($data['packagefile'])) { $errors['packagefile'] = get_string('required'); } else { $draftitemid = file_get_submitted_draft_itemid('packagefile'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_h5pactivity', 'packagefilecheck', null, ['subdirs' => 0, 'maxfiles' => 1]); // Get file from users draft area. $usercontext = context_user::instance($USER->id); $fs = get_file_storage(); $files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id', false); if (count($files) < 1) { $errors['packagefile'] = get_string('required'); return $errors; } $file = reset($files); if (!$file->is_external_file() && !empty($data['updatefreq'])) { // Make sure updatefreq is not set if using normal local file. $errors['updatefreq'] = get_string('updatefreq_error', 'mod_h5pactivity'); } } return $errors; } /** * Enforce defaults here. * * @param array $defaultvalues Form defaults * @return void **/ public function data_preprocessing(&$defaultvalues) { // H5P file. $draftitemid = file_get_submitted_draft_itemid('packagefile'); file_prepare_draft_area($draftitemid, $this->context->id, 'mod_h5pactivity', 'package', 0, ['subdirs' => 0, 'maxfiles' => 1]); $defaultvalues['packagefile'] = $draftitemid; // H5P display options. $factory = new \core_h5p\factory(); $core = $factory->get_core(); if (isset($defaultvalues['displayoptions'])) { $currentdisplay = $defaultvalues['displayoptions']; $displayoptions = (array) \core_h5p\helper::decode_display_options($core, $currentdisplay); } else { $displayoptions = (array) \core_h5p\helper::decode_display_options($core); } foreach ($displayoptions as $key => $value) { $fieldname = "displayopt[$key]"; $defaultvalues[$fieldname] = $value; } } /** * Allows modules to modify the data returned by form get_data(). * This method is also called in the bulk activity completion form. * * Only available on moodleform_mod. * * @param stdClass $data passed by reference */ public function data_postprocessing($data) { parent::data_postprocessing($data); $factory = new \core_h5p\factory(); $core = $factory->get_core(); if (isset($data->displayopt)) { $config = (object) $data->displayopt; } else { $config = \core_h5p\helper::decode_display_options($core); } $data->displayoptions = \core_h5p\helper::get_display_options($core, $config); if (!isset($data->enabletracking)) { $data->enabletracking = 0; } } }