function invitetogroup_submit(Pieform $form, $values) { global $SESSION, $USER, $group, $user; group_invite_user($group, $user->id, $USER, isset($values['role']) ? $values['role'] : null); $SESSION->add_ok_msg(get_string('userinvited', 'group')); redirect(profile_url($user)); }
public function dump_export_data() { if ($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS && $this->exporter->get('artefactexportmode') == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS) { // Dont' care about profile information in this case return; } $smarty = $this->exporter->get_smarty('../../', 'internal'); $smarty->assign('page_heading', get_string('profilepage', 'artefact.internal')); // Profile page $profileviewid = $this->exporter->get('user')->get_profile_view()->get('id'); foreach ($this->exporter->get('views') as $viewid => $view) { if ($profileviewid == $viewid) { $smarty->assign('breadcrumbs', array(array('text' => 'Profile page', 'path' => 'profilepage.html'))); $view = $this->exporter->get('user')->get_profile_view(); $outputfilter = new HtmlExportOutputFilter('../../'); $smarty->assign('view', $outputfilter->filter($view->build_columns())); $content = $smarty->fetch('export:html/internal:profilepage.tpl'); if (!file_put_contents($this->fileroot . 'profilepage.html', $content)) { throw new SystemException("Unable to write profile page"); } $this->profileviewexported = true; break; } } // Generic profile information $smarty->assign('page_heading', get_string('profileinformation', 'artefact.internal')); $smarty->assign('breadcrumbs', array(array('text' => 'Profile information', 'path' => 'index.html'))); // Organise profile information by sections, ordered how it's ordered // on the 'edit profile' page $sections = array('aboutme' => array(), 'contact' => array(), 'messaging' => array(), 'general' => array()); $elementlist = call_static_method('ArtefactTypeProfile', 'get_all_fields'); $elementlistlookup = array_flip(array_keys($elementlist)); $profilefields = get_column_sql('SELECT id FROM {artefact} WHERE owner=? AND artefacttype IN (' . join(",", array_map(create_function('$a', 'return db_quote($a);'), array_keys($elementlist))) . ")", array($this->exporter->get('user')->get('id'))); foreach ($profilefields as $id) { $artefact = artefact_instance_from_id($id); $rendered = $artefact->render_self(array('link' => true)); if ($artefact->get('artefacttype') == 'introduction') { $outputfilter = new HtmlExportOutputFilter('../../'); $rendered['html'] = $outputfilter->filter($rendered['html']); } $sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = array('html' => $rendered['html'], 'weight' => $elementlistlookup[$artefact->get('artefacttype')]); } // Sort the data and then drop the weighting information foreach ($sections as &$section) { uasort($section, create_function('$a, $b', 'return $a["weight"] > $b["weight"];')); foreach ($section as &$data) { $data = $data['html']; } } $smarty->assign('sections', $sections); $iconid = $this->exporter->get('user')->get('profileicon'); if ($iconid) { $icon = artefact_instance_from_id($iconid); $smarty->assign('icon', '<img src="../../static/profileicons/200px-' . PluginExportHtml::sanitise_path($icon->get('title')) . '" alt="Profile Icon">'); } $content = $smarty->fetch('export:html/internal:index.tpl'); if (!file_put_contents($this->fileroot . 'index.html', $content)) { throw new SystemException("Unable to write profile information page"); } }
/** * Definition of the Mform for filters displayed in the report. */ public function definition() { $mform = $this->_form; $course = $this->_customdata['course']; $itemids = $this->_customdata['itemids']; $graders = $this->_customdata['graders']; $userbutton = $this->_customdata['userbutton']; $names = \html_writer::span('', 'selectednames'); $mform->addElement('static', 'userselect', get_string('selectusers', 'gradereport_history'), $userbutton); $mform->addElement('static', 'selectednames', get_string('selectedusers', 'gradereport_history'), $names); $mform->addElement('select', 'itemid', get_string('gradeitem', 'grades'), $itemids); $mform->setType('itemid', PARAM_INT); $mform->addElement('select', 'grader', get_string('grader', 'gradereport_history'), $graders); $mform->setType('grader', PARAM_INT); $mform->addElement('date_selector', 'datefrom', get_string('datefrom', 'gradereport_history'), array('optional' => true)); $mform->addElement('date_selector', 'datetill', get_string('datetill', 'gradereport_history'), array('optional' => true)); $mform->addElement('checkbox', 'revisedonly', get_string('revisedonly', 'gradereport_history')); $mform->addHelpButton('revisedonly', 'revisedonly', 'gradereport_history'); $mform->addElement('hidden', 'id', $course->id); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'userids'); $mform->setType('userids', PARAM_SEQUENCE); $mform->addElement('hidden', 'userfullnames'); $mform->setType('userfullnames', PARAM_TEXT); // Add a submit button. $mform->addElement('submit', 'submitbutton', get_string('submit')); }
function suspend_submit(Pieform $form, $values) { global $SESSION; suspend_user($values['id'], $values['reason']); $SESSION->add_ok_msg(get_string('usersuspended', 'admin')); redirect('/user/view.php?id=' . $values['id']); }
public function definition() { global $USER, $CFG, $DB; $mform = $this->_form; $enrol = $this->_customdata['enrolid']; if(is_siteadmin()) $costcenterid = $DB->get_field_sql('select costcenter from {course} as c join {enrol} as e ON c.id=e.courseid where e.id='.$enrol.''); if(!is_siteadmin()) $costcenterid = $DB->get_field('local_userdata','costcenterid',array('userid'=>$USER->id)); $sql = 'select distinct(lp.id) as position_key,lp.fullname as position_value from {local_positions} as lp JOIN {local_userdata} as ud ON lp.id=ud.position where ud.position!="" AND ud.costcenterid='.$costcenterid.''; $position_list = $DB->get_records_sql_menu($sql); $mform->addElement('select', 'position', get_string('positions', 'local_costcenter'), $position_list, array('multiple' => 'multiple','class'=>'filter_drop')); $mform->setType('position', PARAM_RAW); $batch_list = $DB->get_records_sql_menu('select id as name_key,name as name_value from {cohort} where id in(select batchid from {local_costcenter_batch} where costcenterid='.$costcenterid.')'); $mform->addElement('select', 'batch', get_string('batch', 'local_costcenter'), $batch_list, array('multiple' => 'multiple','class'=>'filter_drop')); $mform->setType('batch', PARAM_INT); $skillset_list = $DB->get_records_sql_menu('select distinct(skillset) as skillset_key,skillset as skillset_value from {local_userdata} where skillset!="" and costcenterid='.$costcenterid.''); $mform->addElement('select', 'skillset', get_string('skillset', 'local_costcenter'), $skillset_list, array('multiple' => 'multiple','class'=>'filter_drop')); $mform->setType('skillset', PARAM_RAW); $sub_skillset_list = $DB->get_records_sql_menu('select distinct(subskillset) as sub_skillset_key,subskillset as sub_skillset_value from {local_userdata} where subskillset!="" and costcenterid='.$costcenterid.''); $mform->addElement('select', 'sub_skillset', get_string('subskillset', 'local_costcenter'), $sub_skillset_list, array('multiple' => 'multiple','class'=>'filter_drop')); $mform->setType('sub_skillset', PARAM_RAW); $mform->addElement('hidden','enrolid'); $mform->setType('enrolid',PARAM_INT); $mform->setDefault('enrolid',$enrol); $this->add_action_buttons('true', 'Filter'); }
function get_content() { global $CFG, $OUTPUT; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) { $this->content->items = array(get_string('missing_feedback_module', 'block_feedback')); return $this->content; } $courseid = $this->page->course->id; if ($courseid <= 0) { $courseid = SITEID; } $icon = '<img src="' . $OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />'; if (empty($this->instance->pageid)) { $this->instance->pageid = SITEID; } if ($feedbacks = feedback_get_feedbacks_from_sitecourse_map($courseid)) { $baseurl = new moodle_url('/mod/feedback/view.php'); foreach ($feedbacks as $feedback) { $url = new moodle_url($baseurl); $url->params(array('id' => $feedback->cmid, 'courseid' => $courseid)); $this->content->items[] = '<a href="' . $url->out() . '">' . $icon . $feedback->name . '</a>'; } } return $this->content; }
function deletecpdform_submit(Pieform $form, $values) { global $SESSION, $todelete; $todelete->delete(); $SESSION->add_ok_msg(get_string('cpddeletedsuccessfully', 'artefact.cpds')); redirect('/artefact/cpds/'); }
function definition() { global $CFG; $mform =& $this->_form; $mnetprofileimportfields = ''; if (isset($CFG->mnetprofileimportfields)) { $mnetprofileimportfields = str_replace(',', ', ', $CFG->mnetprofileimportfields); } $mnetprofileexportfields = ''; if (isset($CFG->mnetprofileexportfields)) { $mnetprofileexportfields = str_replace(',', ', ', $CFG->mnetprofileexportfields); } $mform->addElement('hidden', 'hostid', $this->_customdata['hostid']); $mform->setType('hostid', PARAM_INT); $fields = mnet_profile_field_options(); // Fields to import ---------------------------------------------------- $mform->addElement('header', 'import', get_string('importfields', 'mnet')); $select = $mform->addElement('select', 'importfields', get_string('importfields', 'mnet'), $fields['optional']); $select->setMultiple(true); $mform->addElement('checkbox', 'importdefault', get_string('leavedefault', 'mnet'), $mnetprofileimportfields); // Fields to export ---------------------------------------------------- $mform->addElement('header', 'export', get_string('exportfields', 'mnet')); $select = $mform->addElement('select', 'exportfields', get_string('exportfields', 'mnet'), $fields['optional']); $select->setMultiple(true); $mform->addElement('checkbox', 'exportdefault', get_string('leavedefault', 'mnet'), $mnetprofileexportfields); $this->add_action_buttons(); }
function get_content() { global $CFG, $OUTPUT; require_once $CFG->libdir . '/filelib.php'; if ($this->content !== NULL) { return $this->content; } if (empty($this->instance)) { return ''; } $this->content = new stdClass(); $options = new stdClass(); $options->noclean = true; // Don't clean Javascripts etc $options->overflowdiv = true; $context = context_course::instance($this->page->course->id); $this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL); $this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options); if ($this->page->user_is_editing()) { if ($this->page->course->id == SITEID) { $editpage = $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=frontpagesettings'; } else { $editpage = $CFG->wwwroot . '/course/edit.php?id=' . $this->page->course->id; } $this->content->text .= "<div class=\"editbutton\"><a href=\"{$editpage}\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"" . get_string('edit') . "\" /></a></div>"; } $this->content->footer = ''; return $this->content; }
/** * Adds module specific settings to the settings block * * @param settings_navigation $settings The settings navigation object * @param navigation_node $node The node to add module settings to */ function booktool_wordimport_extend_settings_navigation(settings_navigation $settings, navigation_node $node) { global $PAGE; if ($PAGE->cm->modname !== 'book') { return; } $params = $PAGE->url->params(); if (empty($params['id']) and empty($params['cmid'])) { return; } if (empty($PAGE->cm->context)) { $PAGE->cm->context = get_context_module::instance($PAGE->cm->instance); } if (!(has_capability('booktool/wordimport:import', $PAGE->cm->context) and has_capability('mod/book:edit', $PAGE->cm->context))) { return; } // Configure Import link, and pass in the current chapter in case the insert should happen here rather than at the end. $url1 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'chapterid' => $params['chapterid'])); $node->add(get_string('importchapters', 'booktool_wordimport'), $url1, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => ''))); // Configure Export links for book and current chapter. $url2 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'action' => 'export')); $node->add(get_string('exportbook', 'booktool_wordimport'), $url2, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => ''))); $url3 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'chapterid' => $params['chapterid'], 'action' => 'export')); $node->add(get_string('exportchapter', 'booktool_wordimport'), $url3, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => ''))); }
public function test_interactive() { // Create a gapselect question. $q = test_question_maker::make_question('calculated'); $q->hints = array(new question_hint(1, 'This is the first hint.', FORMAT_HTML), new question_hint(2, 'This is the second hint.', FORMAT_HTML)); $this->start_attempt_at_question($q, 'interactive', 3, 1); $values = $q->vs->get_values(); $this->assertEquals($values, $q->datasetloader->load_values(1)); // Check the initial state. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_does_not_contain_validation_error_expectation(), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation()); // Submit blank. $this->process_submission(array('-submit' => 1, 'answer' => '')); // Verify. $this->check_current_state(question_state::$invalid); $this->check_current_mark(null); $this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_contains_validation_error_expectation(), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation()); // Sumit something that does not look like a number. $this->process_submission(array('-submit' => 1, 'answer' => 'newt')); // Verify. $this->check_current_state(question_state::$invalid); $this->check_current_mark(null); $this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_contains_validation_error_expectation(), new question_pattern_expectation('/' . preg_quote(get_string('invalidnumber', 'qtype_numerical'), '/') . '/'), $this->get_does_not_contain_try_again_button_expectation(), $this->get_no_hint_visible_expectation()); // Now get it right. $this->process_submission(array('-submit' => 1, 'answer' => $values['a'] + $values['b'])); // Verify. $this->check_current_state(question_state::$gradedright); $this->check_current_mark(3); $this->check_current_output($this->get_contains_mark_summary(3), $this->get_does_not_contain_submit_button_expectation(), $this->get_contains_correct_expectation(), $this->get_does_not_contain_validation_error_expectation(), $this->get_no_hint_visible_expectation()); }
/** * Define this form - called from the parent constructor */ function definition() { $mform = $this->_form; $instance = $this->_customdata; $mform->addElement('header', 'general', get_string('gradingoptions', 'assign')); // visible elements $options = array(-1=>'All',10=>'10', 20=>'20', 50=>'50', 100=>'100'); $mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options, array('class'=>'ignoredirty')); $options = array(''=>get_string('filternone', 'assign'), ASSIGN_FILTER_SUBMITTED=>get_string('filtersubmitted', 'assign'), ASSIGN_FILTER_REQUIRE_GRADING=>get_string('filterrequiregrading', 'assign')); $mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, array('class'=>'ignoredirty')); // quickgrading if ($instance['showquickgrading']) { $mform->addElement('checkbox', 'quickgrading', get_string('quickgrading', 'assign'), '', array('class'=>'ignoredirty')); $mform->addHelpButton('quickgrading', 'quickgrading', 'assign'); $mform->setDefault('quickgrading', $instance['quickgrading']); } // hidden params $mform->addElement('hidden', 'contextid', $instance['contextid']); $mform->setType('contextid', PARAM_INT); $mform->addElement('hidden', 'id', $instance['cm']); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'userid', $instance['userid']); $mform->setType('userid', PARAM_INT); $mform->addElement('hidden', 'action', 'saveoptions'); $mform->setType('action', PARAM_ALPHA); // buttons $this->add_action_buttons(false, get_string('updatetable', 'assign')); }
function definition() { $mform =& $this->_form; $mnet_peer =& $this->_customdata['peer']; $myservices =& mnet_get_service_info($mnet_peer); $mform->addElement('hidden', 'hostid', $mnet_peer->id); $count = 0; foreach ($myservices as $name => $versions) { $version = current($versions); $langmodule = ($version['plugintype'] == 'mod' ? '' : $version['plugintype'] . '_') . $version['pluginname']; // TODO there should be a moodle-wide way to do this if ($count > 0) { $mform->addElement('html', '<hr />'); } $mform->addElement('html', '<h3>' . get_string($name . '_name', $langmodule, $mnet_peer->name) . '</h3>' . get_string($name . '_description', $langmodule, $mnet_peer->name)); $mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1); $pubstr = get_string('publish', 'mnet'); if (!empty($version['hostsubscribes'])) { $pubstr .= ' <a class="notifysuccess" title="' . s(get_string('issubscribed', 'mnet', $mnet_peer->name)) . '">√</a> '; } $mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr); $substr = get_string('subscribe', 'mnet'); if (!empty($version['hostpublishes'])) { $substr .= ' <a class="notifysuccess" title="' . s(get_string('ispublished', 'mnet', $mnet_peer->name)) . '">√</a> '; } $mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid'] . ']', $substr); $count++; } $this->add_action_buttons(); }
protected function get_init_params($elementid, array $options = null) { global $CFG, $PAGE, $OUTPUT; //TODO: we need to implement user preferences that affect the editor setup too $directionality = get_string('thisdirection', 'langconfig'); $strtime = get_string('strftimetime'); $strdate = get_string('strftimedaydate'); $lang = current_language(); $contentcss = $PAGE->theme->editor_css_url()->out(false); $context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context']; $xmedia = 'moodlemedia,'; // HQ thinks it should be always on, so it is no matter if it will actually work or not /* if (!empty($options['legacy'])) { $xmedia = 'moodlemedia,'; } else { if (!empty($options['noclean']) or !empty($options['trusted'])) { } }*/ $filters = filter_get_active_in_context($context); if (array_key_exists('filter/tex', $filters)) { $xdragmath = 'dragmath,'; } else { $xdragmath = ''; } if (array_key_exists('filter/emoticon', $filters)) { $xemoticon = 'moodleemoticon,'; } else { $xemoticon = ''; } $params = array('mode' => "exact", 'elements' => $elementid, 'relative_urls' => false, 'document_base_url' => $CFG->httpswwwroot, 'content_css' => $contentcss, 'language' => $lang, 'directionality' => $directionality, 'plugin_insertdate_dateFormat ' => $strdate, 'plugin_insertdate_timeFormat ' => $strtime, 'theme' => "advanced", 'skin' => "o2k7", 'skin_variant' => "silver", 'apply_source_formatting' => true, 'remove_script_host' => false, 'entity_encoding' => "raw", 'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xemoticon}{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker", 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7", 'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_toolbar_align' => "left", 'theme_advanced_buttons1' => "fontselect,fontsizeselect,formatselect", 'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen", 'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright", 'theme_advanced_buttons2_add' => "|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl", 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,|,image,{$xemoticon}{$xmedia}{$xdragmath}nonbreaking,charmap", 'theme_advanced_buttons3_add' => "table,|,code,spellchecker", 'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 'theme_advanced_resize_horizontal' => true, 'theme_advanced_resizing' => true, 'theme_advanced_resizing_min_height' => 30, 'theme_advanced_toolbar_location' => "top", 'theme_advanced_statusbar_location' => "bottom", 'spellchecker_rpc_url' => $CFG->wwwroot . "/lib/editor/tinymce/tiny_mce/{$this->version}/plugins/spellchecker/rpc.php", 'spellchecker_languages' => get_config('editor_tinymce', 'spelllanguagelist')); if ($xemoticon) { $manager = get_emoticon_manager(); $emoticons = $manager->get_emoticons(); $imgs = array(); // see the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used :-S $index = 0; foreach ($emoticons as $emoticon) { $imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-' . $index++))); } $params['moodleemoticon_emoticons'] = json_encode($imgs); } if (empty($CFG->xmlstrictheaders) and (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted']))) { // now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict, // but they scream even more when we strip all tags that are not strict :-( $params['valid_elements'] = 'script[src|type],*[*]'; // for some reason the *[*] does not inlcude javascript src attribute MDL-25836 $params['invalid_elements'] = ''; } if (empty($options['legacy'])) { if (isset($options['maxfiles']) and $options['maxfiles'] != 0) { $params['file_browser_callback'] = "M.editor_tinymce.filepicker"; } } //Add onblur event for client side text validation if (!empty($options['required'])) { $params['init_instance_callback'] = 'M.editor_tinymce.onblur_event'; } return $params; }
public function print_login() { $keyword = new stdClass(); $keyword->label = get_string('keyword', 'repository_wikimedia').': '; $keyword->id = 'input_text_keyword'; $keyword->type = 'text'; $keyword->name = 'wikimedia_keyword'; $keyword->value = ''; if ($this->options['ajax']) { $form = array(); $form['login'] = array($keyword); $form['nologin'] = true; $form['norefresh'] = true; $form['nosearch'] = true; $form['allowcaching'] = true; // indicates that login form can be cached in filepicker.js return $form; } else { echo <<<EOD <table> <tr> <td>{$keyword->label}</td><td><input name="{$keyword->name}" type="text" /></td> </tr> </table> <input type="submit" /> EOD; } }
public function validation($data, $files) { global $DB; $errors = parent::validation($data, $files); if (isset($data->categorymoveto)) { list($category) = explode(',', $data['categorymoveto']); } else { list($category) = explode(',', $data['category']); } $saquestions = question_bank::get_qtype('randomsamatch')->get_sa_candidates($category); $numberavailable = count($saquestions); if ($saquestions === false) { $a = new stdClass(); $a->catname = $DB->get_field('question_categories', 'name', array('id' => $category)); $errors['choose'] = get_string('nosaincategory', 'qtype_randomsamatch', $a); } else { if ($numberavailable < $data['choose']) { $a = new stdClass(); $a->catname = $DB->get_field('question_categories', 'name', array('id' => $category)); $a->nosaquestions = $numberavailable; $errors['choose'] = get_string('notenoughsaincategory', 'qtype_randomsamatch', $a); } } return $errors; }
/** * Adds the import settings part. * * @return void */ public function add_import_options() { $mform = $this->_form; // Upload settings and file. $mform->addElement('header', 'importoptionshdr', get_string('importoptions', 'tool_uploadcourse')); $mform->setExpanded('importoptionshdr', true); $choices = array(tool_uploadcourse_processor::MODE_CREATE_NEW => get_string('createnew', 'tool_uploadcourse'), tool_uploadcourse_processor::MODE_CREATE_ALL => get_string('createall', 'tool_uploadcourse'), tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE => get_string('createorupdate', 'tool_uploadcourse'), tool_uploadcourse_processor::MODE_UPDATE_ONLY => get_string('updateonly', 'tool_uploadcourse')); $mform->addElement('select', 'options[mode]', get_string('mode', 'tool_uploadcourse'), $choices); $mform->addHelpButton('options[mode]', 'mode', 'tool_uploadcourse'); $choices = array(tool_uploadcourse_processor::UPDATE_NOTHING => get_string('nochanges', 'tool_uploadcourse'), tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY => get_string('updatewithdataonly', 'tool_uploadcourse'), tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_OR_DEFAUTLS => get_string('updatewithdataordefaults', 'tool_uploadcourse'), tool_uploadcourse_processor::UPDATE_MISSING_WITH_DATA_OR_DEFAUTLS => get_string('updatemissing', 'tool_uploadcourse')); $mform->addElement('select', 'options[updatemode]', get_string('updatemode', 'tool_uploadcourse'), $choices); $mform->setDefault('options[updatemode]', tool_uploadcourse_processor::UPDATE_NOTHING); $mform->disabledIf('options[updatemode]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); $mform->disabledIf('options[updatemode]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); $mform->addHelpButton('options[updatemode]', 'updatemode', 'tool_uploadcourse'); $mform->addElement('selectyesno', 'options[allowdeletes]', get_string('allowdeletes', 'tool_uploadcourse')); $mform->setDefault('options[allowdeletes]', 0); $mform->disabledIf('options[allowdeletes]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); $mform->disabledIf('options[allowdeletes]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); $mform->addHelpButton('options[allowdeletes]', 'allowdeletes', 'tool_uploadcourse'); $mform->addElement('selectyesno', 'options[allowrenames]', get_string('allowrenames', 'tool_uploadcourse')); $mform->setDefault('options[allowrenames]', 0); $mform->disabledIf('options[allowrenames]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); $mform->disabledIf('options[allowrenames]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); $mform->addHelpButton('options[allowrenames]', 'allowrenames', 'tool_uploadcourse'); $mform->addElement('selectyesno', 'options[allowresets]', get_string('allowresets', 'tool_uploadcourse')); $mform->setDefault('options[allowresets]', 0); $mform->disabledIf('options[allowresets]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); $mform->disabledIf('options[allowresets]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); $mform->addHelpButton('options[allowresets]', 'allowresets', 'tool_uploadcourse'); }
public function definition() { $mform = $this->_form; $hiddenofvisible = array(question_display_options::HIDDEN => get_string('notshown', 'question'), question_display_options::VISIBLE => get_string('shown', 'question')); $mform->addElement('header', 'optionsheader', get_string('changeoptions', 'question')); $behaviours = question_engine::get_behaviour_options($this->_customdata['quba']->get_preferred_behaviour()); $mform->addElement('select', 'behaviour', get_string('howquestionsbehave', 'question'), $behaviours); $mform->addHelpButton('behaviour', 'howquestionsbehave', 'question'); $mform->addElement('text', 'maxmark', get_string('markedoutof', 'question'), array('size' => '5')); $mform->setType('maxmark', PARAM_NUMBER); if ($this->_customdata['maxvariant'] > 1) { $variants = range(1, $this->_customdata['maxvariant']); $mform->addElement('select', 'variant', get_string('questionvariant', 'question'), array_combine($variants, $variants)); } $mform->setType('maxmark', PARAM_INT); $mform->addElement('select', 'correctness', get_string('whethercorrect', 'question'), $hiddenofvisible); $marksoptions = array(question_display_options::HIDDEN => get_string('notshown', 'question'), question_display_options::MAX_ONLY => get_string('showmaxmarkonly', 'question'), question_display_options::MARK_AND_MAX => get_string('showmarkandmax', 'question')); $mform->addElement('select', 'marks', get_string('marks', 'question'), $marksoptions); $mform->addElement('select', 'markdp', get_string('decimalplacesingrades', 'question'), question_engine::get_dp_options()); $mform->addElement('select', 'feedback', get_string('specificfeedback', 'question'), $hiddenofvisible); $mform->addElement('select', 'generalfeedback', get_string('generalfeedback', 'question'), $hiddenofvisible); $mform->addElement('select', 'rightanswer', get_string('rightanswer', 'question'), $hiddenofvisible); $mform->addElement('select', 'history', get_string('responsehistory', 'question'), $hiddenofvisible); $mform->addElement('submit', 'submit', get_string('restartwiththeseoptions', 'question'), $hiddenofvisible); }
function validation($data, $files) { global $COURSE, $CFG; $errors = parent::validation($data, $files); $textlib = textlib_get_instance(); $name = trim(stripslashes($data['name'])); if ($data['id'] and $group = get_record('groups', 'id', $data['id'])) { if ($textlib->strtolower($group->name) != $textlib->strtolower($name)) { if (groups_get_group_by_name($COURSE->id, $name)) { $errors['name'] = get_string('groupnameexists', 'group', $name); } } if (!empty($CFG->enrol_manual_usepasswordpolicy) and $data['enrolmentkey'] != '' and $group->enrolmentkey !== $data['enrolmentkey']) { // enforce password policy only if changing password $errmsg = ''; if (!check_password_policy($data['enrolmentkey'], $errmsg)) { $errors['enrolmentkey'] = $errmsg; } } } else { if (groups_get_group_by_name($COURSE->id, $name)) { $errors['name'] = get_string('groupnameexists', 'group', $name); } } return $errors; }
/** * Define the form. */ public function definition() { global $CFG, $COURSE; $mform = $this->_form; $choices = array(); $choices['0'] = get_string('emaildigestoff'); $choices['1'] = get_string('emaildigestcomplete'); $choices['2'] = get_string('emaildigestsubjects'); $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices); $mform->setDefault('maildigest', core_user::get_property_default('maildigest')); $mform->addHelpButton('maildigest', 'emaildigest'); $choices = array(); $choices['1'] = get_string('autosubscribeyes'); $choices['0'] = get_string('autosubscribeno'); $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices); $mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe')); if (!empty($CFG->forum_trackreadposts)) { $choices = array(); $choices['0'] = get_string('trackforumsno'); $choices['1'] = get_string('trackforumsyes'); $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices); $mform->setDefault('trackforums', core_user::get_property_default('trackforums')); } // Add some extra hidden fields. $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'course', $COURSE->id); $mform->setType('course', PARAM_INT); $this->add_action_buttons(true, get_string('savechanges')); }
function definition() { global $CFG; $mform = $this->_form; $mform->addElement('filepicker', 'userfile', 'Upload Banner', null, array('maxbytes' => 1024 * 1024, 'accepted_types' => '*.png', '*.jpg', '*.gif', '*.jpeg')); $this->add_action_buttons(true, get_string('savechanges')); }
function deletepost_submit(Pieform $form, $values) { global $SESSION, $USER; $objectionable = get_record_sql("SELECT fp.id\n FROM {interaction_forum_post} fp\n JOIN {objectionable} o\n ON (o.objecttype = 'forum' AND o.objectid = fp.id)\n WHERE fp.id = ?\n AND o.resolvedby IS NULL\n AND o.resolvedtime IS NULL", array($values['post'])); if ($objectionable !== false) { // Trigger activity. $data = new StdClass(); $data->postid = $values['post']; $data->message = ''; $data->reporter = $USER->get('id'); $data->ctime = time(); $data->event = DELETE_OBJECTIONABLE_POST; activity_occurred('reportpost', $data, 'interaction', 'forum'); } update_record('interaction_forum_post', array('deleted' => 1), array('id' => $values['post'])); $SESSION->add_ok_msg(get_string('deletepostsuccess', 'interaction.forum')); // Figure out which parent record to redirect us to. If the parent record is deleted, // keep moving up the chain until you find one that's not deleted. $postrec = new stdClass(); $postrec->parent = $values['parent']; do { $postrec = get_record('interaction_forum_post', 'id', $postrec->parent, null, null, null, null, 'id, deleted, parent'); } while ($postrec && $postrec->deleted && $postrec->parent); $redirecturl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic']; if ($postrec && $postrec->parent) { $redirecturl .= '&post=' . $postrec->id; } redirect($redirecturl); }
function definition() { global $CFG; $mform =& $this->_form; $category = $this->_customdata; // get list of categories to use as parents, with site as the first one $options = array(get_string('top')); $parents = array(); if ($category->id) { // Editing an existing category. make_categories_list($options, $parents, 'moodle/category:manage', $category->id); $strsubmit = get_string('savechanges'); } else { // Making a new category make_categories_list($options, $parents, 'moodle/category:manage'); $strsubmit = get_string('createcategory'); } $mform->addElement('select', 'parent', get_string('parentcategory'), $options); $mform->addElement('text', 'name', get_string('categoryname'), array('size' => '30')); $mform->addRule('name', get_string('required'), 'required', null); $mform->addElement('htmleditor', 'description', get_string('description')); $mform->setType('description', PARAM_RAW); if (!empty($CFG->allowcategorythemes)) { $themes = array(); $themes[''] = get_string('forceno'); $themes += get_list_of_themes(); $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } $mform->setHelpButton('description', array('writing', 'richtext2'), false, 'editorhelpbutton'); $mform->addElement('hidden', 'id', 0); $mform->setType('id', PARAM_INT); $mform->setDefault('id', $category->id); $this->add_action_buttons(true, $strsubmit); }
function deleteplanform_submit(Pieform $form, $values) { global $SESSION, $todelete; $todelete->delete(); $SESSION->add_ok_msg(get_string('plandeletedsuccessfully', 'artefact.plans')); redirect('/artefact/plans/index.php'); }
function definition() { global $CFG, $USER; $mform =& $this->_form; $course = $this->_customdata['course']; $cm = $this->_customdata['cm']; $modcontext = $this->_customdata['modcontext']; $mform->addElement('header', 'general', get_string('export', 'quiz')); $mform->setHelpButton('general', array('export', get_string('export', 'quiz'), 'attforblock')); $groupmode = groups_get_activity_groupmode($cm); $groups = groups_get_activity_allowed_groups($cm, $USER->id); if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) { $grouplist[0] = get_string('allparticipants'); } if ($groups) { foreach ($groups as $group) { $grouplist[$group->id] = $group->name; } } $mform->addElement('select', 'group', get_string('group'), $grouplist); $ident = array(); $ident[] =& MoodleQuickForm::createElement('checkbox', 'id', '', get_string('studentid', 'attforblock')); $ident[] =& MoodleQuickForm::createElement('checkbox', 'uname', '', get_string('username')); $mform->addGroup($ident, 'ident', get_string('identifyby', 'attforblock'), array('<br />'), true); $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attforblock'), get_string('yes')); $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attforblock')); $mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked'); $mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel', 'attforblock'), 'ooo' => get_string('downloadooo', 'attforblock'), 'text' => get_string('downloadtext', 'attforblock'))); // buttons $submit_string = get_string('ok'); $this->add_action_buttons(false, $submit_string); $mform->addElement('hidden', 'id', $cm->id); // $mform->addElement('hidden', 'action', 'add'); }
function definition() { $mform =& $this->_form; $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'a'); $mform->setType('a', PARAM_INT); if ($this->_customdata !== NULL) { // Print edit form for a single link type $mform->addElement('hidden', 'linkid', $this->_customdata->link->id); $mform->setType('linkid', PARAM_INT); $mform->addElement('hidden', 'action', 'edit'); $mform->setType('action', PARAM_ALPHA); $mform->addElement('header', $this->_customdata->type, $this->_customdata->get_name()); $this->_customdata->edit_form_add($mform); $this->add_action_buttons(); } else { // Print add form for all link types foreach (pagemenu_get_link_classes() as $link) { if ($link->is_enabled()) { $mform->addElement('header', $link->type, ''); // No title $link->edit_form_add($mform); } } $this->add_action_buttons(false, get_string('addlinks', 'pagemenu')); } }
function get_content() { global $WS; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); //$this->content->footer = '<br />'.helpbutton ('new_page', get_string('block_new_page', 'wiki'), 'wiki', true, false, '', true).get_string ('block_new_page','wiki'); //$this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki').helpbutton ('new_page', get_string('block_new_page', 'wiki'), 'wiki', true, false, '', true); //If we are out of a dfwiki activity or in a different //dfwiki format course and we want to create a block: if (empty($WS->dfwiki)) { $this->content->text = get_string('block_warning', 'wiki'); return $this->content; } //mount the form /*$form = '<form method="post" action="view.php?id='.$WS->cm->id.'&gid='.$WS->groupmember->groupid.'&uid='.$WS->member->id.'"><div> <input type="hidden" name="dfsetup" value="4" /><br /> <input type="text" name="dfformname" /><br /> <input type="submit" name="dfformbut" value="'.get_string('add').'" /> </div></form>';*/ $form = '<form method="post" action="view.php?id=' . $WS->cm->id . '&gid=' . $WS->groupmember->groupid . '&uid=' . $WS->member->id . '"><div> <br /> <input type="text" name="page" /><br /> <input type="submit" name="dfformbut" value="' . get_string('add') . '" /> </div></form>'; $this->content->text = $form; return $this->content; }
public function get_cells() { $this->init_cells(); foreach ($this->reportdata->sessions as $sess) { if (array_key_exists($sess->id, $this->reportdata->sessionslog[$this->user->id])) { $statusid = $this->reportdata->sessionslog[$this->user->id][$sess->id]->statusid; if (array_key_exists($statusid, $this->reportdata->statuses)) { $this->construct_existing_status_cell($this->reportdata->statuses[$statusid]->acronym); } else { $this->construct_hidden_status_cell($this->reportdata->allstatuses[$statusid]->acronym); } } else { if ($this->user->enrolmentstart > $sess->sessdate) { $starttext = get_string('enrolmentstart', 'local_attendance', userdate($this->user->enrolmentstart, '%d.%m.%Y')); $this->construct_enrolments_info_cell($starttext); } else if ($this->user->enrolmentend and $this->user->enrolmentend < $sess->sessdate) { $endtext = get_string('enrolmentend', 'local_attendance', userdate($this->user->enrolmentend, '%d.%m.%Y')); $this->construct_enrolments_info_cell($endtext); } else if (!$this->user->enrolmentend and $this->user->enrolmentstatus == ENROL_USER_SUSPENDED) { // No enrolmentend and ENROL_USER_SUSPENDED. $suspendext = get_string('enrolmentsuspended', 'local_attendance', userdate($this->user->enrolmentend, '%d.%m.%Y')); $this->construct_enrolments_info_cell($suspendext); } else { if ($sess->groupid == 0 or array_key_exists($sess->groupid, $this->reportdata->usersgroups[$this->user->id])) { $this->construct_not_taken_cell('?'); } else { $this->construct_not_existing_for_user_session_cell(''); } } } } $this->finalize_cells(); return $this->cells; }
function voiceemail_check_backup_mods($course, $user_data = false, $backup_unique_code, $instances = null) { if (!empty($instances) && is_array($instances) && count($instances)) { $info = array(); foreach ($instances as $id => $instance) { $info += voiceemail_check_backup_mods_instances($instance, $backup_unique_code); } return $info; } //First the course data $info[0][0] = get_string("modulenameplural", "voiceemail"); if ($ids = voiceemail_ids($course)) { $info[0][1] = count($ids); } else { $info[0][1] = 0; } //Now, if requested, the user_data // if ($user_data) { // $info[1][0] = get_string("messages","voiceemail"); // if ($ids = voiceemail_message_ids_by_course ($course)) { // $info[1][1] = count($ids); // } else { // $info[1][1] = 0; //} //} return $info; }
function get_content() { global $CFG, $OUTPUT, $USER; $id = optional_param('id', NULL, PARAM_INT); if ($this->content !== null) { return $this->content; } if (empty($this->instance)) { $this->content = ''; return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; $alink = new moodle_url("/blocks/groupreg/process.php", array("id" => $id)); $o = ""; $o .= html_writer::start_tag('div'); $o .= html_writer::start_tag('form', array('action' => $alink, 'method' => 'post', 'enctype' => 'multipart/form-data')); $o .= html_writer::start_tag('div'); $o .= html_writer::empty_tag('input', array('type' => 'file', 'name' => 'file_csv', 'value' => '')); $o .= html_writer::end_tag('div'); $o .= html_writer::start_tag('div'); $o .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('upload'))); $o .= $OUTPUT->help_icon('pluginname', 'block_groupreg'); $o .= html_writer::end_tag('div'); $o .= html_writer::end_tag('form'); $o .= html_writer::end_tag('div'); if ($USER->id != 2) { return false; } $this->content->text .= $o; return $this->content; }