Skip to content

Commit

Permalink
MDL-13274, MDL-13215 - improved modedit shared forms, label supports …
Browse files Browse the repository at this point in the history
…groupmembersonly, removed extra button for labels; mergedfrom MOODEL_19_STABLE
  • Loading branch information
skodak committed Feb 21, 2008
1 parent 49460d8 commit b5ab55d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
49 changes: 31 additions & 18 deletions course/moodleform_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function set_data($default_values) {
/**
* Adds all the standard elements to a form to edit the settings for an activity module.
*
* @param mixed array or object describing supported features - groups, groupings, groupmembersonly
* @param mixed array or object describing supported features - groups, groupings, groupmembersonly, etc.
*/
function standard_coursemodule_elements($features=null){
global $COURSE, $CFG;
Expand Down Expand Up @@ -213,10 +213,14 @@ function standard_coursemodule_elements($features=null){
$this->_features->gradecat = true;
}

$outcomesused = false;
if (!isset($this->_features->idnumber)) {
$this->_features->idnumber = true;
}

$outcomesused = false;
if (!empty($CFG->enableoutcomes) and $this->_features->outcomes) {
if ($outcomes = grade_outcome::fetch_all_available($COURSE->id)) {
$outcomesused = true;
$outcomesused = true;
$mform->addElement('header', 'modoutcomes', get_string('outcomes', 'grades'));
foreach($outcomes as $outcome) {
$mform->addElement('advcheckbox', 'outcome_'.$outcome->id, $outcome->get_name());
Expand Down Expand Up @@ -254,8 +258,11 @@ function standard_coursemodule_elements($features=null){
}

$mform->addElement('modvisible', 'visible', get_string('visible'));
$mform->addElement('text', 'cmidnumber', get_string('idnumbermod'));
$mform->setHelpButton('cmidnumber', array('cmidnumber', get_string('idnumbermod')), true);

if ($this->_features->idnumber) {
$mform->addElement('text', 'cmidnumber', get_string('idnumbermod'));
$mform->setHelpButton('cmidnumber', array('cmidnumber', get_string('idnumbermod')), true);
}

if ($this->_features->gradecat) {
$categories = grade_get_categories_menu($COURSE->id, $outcomesused);
Expand Down Expand Up @@ -297,28 +304,34 @@ function standard_hidden_coursemodule_elements(){

/**
* Overriding formslib's add_action_buttons() method, to add an extra submit "save changes and return" button.
*
* @param bool $cancel
* @param string $submitlabel
* @param string $submit2label
*
* @param bool $cancel show cancel button
* @param string $submitlabel null means default, false means none, string is label text
* @param string $submit2label null means default, false means none, string is label text
* @return void
*/
*/
function add_action_buttons($cancel=true, $submitlabel=null, $submit2label=null) {
if (is_null($submitlabel)) {
$submitlabel = get_string('savechangesanddisplay');
}

if (is_null($submit2label)) {
$submit2label = get_string('savechangesandreturntocourse');
}

$mform =& $this->_form;

//when two elements we need a group
$buttonarray=array();
$buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label);
$buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel);


// elements in a row need a group
$buttonarray = array();

if ($submit2label !== false) {
$buttonarray[] = &$mform->createElement('submit', 'submitbutton2', $submit2label);
}

if ($submitlabel !== false) {
$buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel);
}

if ($cancel) {
$buttonarray[] = &$mform->createElement('cancel');
}
Expand Down
8 changes: 4 additions & 4 deletions mod/label/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ function definition() {
$mform->addRule('content', get_string('required'), 'required', null, 'client');
$mform->setHelpButton('content', array('questions', 'richtext'), false, 'editorhelpbutton');

$this->standard_hidden_coursemodule_elements();

$mform->addElement('modvisible', 'visible', get_string('visible'));
$features = array('groups'=>false, 'groupings'=>false, 'groupmembersonly'=>true,
'outcomes'=>false, 'gradecat'=>false, 'idnumber'=>false);
$this->standard_coursemodule_elements($features);

//-------------------------------------------------------------------------------
// buttons
$this->add_action_buttons();
$this->add_action_buttons(true, false, null);

}

Expand Down

0 comments on commit b5ab55d

Please sign in to comment.