Skip to content

Commit

Permalink
Merge branch 'm29_MDL-49628a' of https://github.com/totara/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jun 2, 2015
2 parents 290b156 + 32bd11c commit 356fd5b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 30 deletions.
6 changes: 4 additions & 2 deletions badges/award.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,16 @@
if (!$role) {
$pageurl = new moodle_url('/badges/award.php', array('id' => $badgeid));
echo $OUTPUT->header();
echo $OUTPUT->box(get_string('selectaward', 'badges') . $OUTPUT->single_select(new moodle_url($pageurl), 'role', $select));
echo $OUTPUT->box($OUTPUT->single_select(new moodle_url($pageurl), 'role', $select, '', array('' => 'choosedots'),
null, array('label' => get_string('selectaward', 'badges'))));
echo $OUTPUT->footer();
die();
} else {
$pageurl = new moodle_url('/badges/award.php', array('id' => $badgeid));
$issuerrole = new stdClass();
$issuerrole->roleid = $role;
$roleselect = get_string('selectaward', 'badges') . $OUTPUT->single_select(new moodle_url($pageurl), 'role', $select, $role, null);
$roleselect = $OUTPUT->single_select(new moodle_url($pageurl), 'role', $select, $role, null, null,
array('label' => get_string('selectaward', 'badges')));
}
} else {
echo $OUTPUT->header();
Expand Down
11 changes: 3 additions & 8 deletions badges/criteria/award_criteria_overall.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,9 @@ public function config_form_criteria($data) {
echo $OUTPUT->box($editaction, array('criteria-header'));

$url = new moodle_url('criteria.php', array('id' => $data->id, 'sesskey' => sesskey()));
$table = new html_table();
$table->attributes = array('class' => 'clearfix');
$table->colclasses = array('', 'activatebadge');
$table->data[] = array(
$OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype), null),
get_string('overallcrit', 'badges')
);
echo html_writer::table($table);
echo $OUTPUT->single_select($url, 'update', $agg, $data->get_aggregation_method($this->criteriatype),
null, null, array('aria-describedby' => 'overall'));
echo html_writer::span(get_string('overallcrit', 'badges'), '', array('id' => 'overall'));
} else {
echo $OUTPUT->box(get_string('criteria_descr_' . $this->criteriatype, 'badges',
core_text::strtoupper($agg[$data->get_aggregation_method()])), 'clearfix');
Expand Down
23 changes: 12 additions & 11 deletions badges/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,7 @@ public function print_badge_criteria(badge $badge, $short = '') {

// Prints criteria actions for badge editing.
public function print_criteria_actions(badge $badge) {
$table = new html_table();
$table->attributes = array('class' => 'boxaligncenter', 'id' => 'badgeactions');
$table->colclasses = array('activatebadge');

$actions = array();
$output = '';
if (!$badge->is_active() && !$badge->is_locked()) {
$accepted = $badge->get_accepted_criteria();
$potential = array_diff($accepted, array_keys($badge->criteria));
Expand All @@ -798,16 +794,21 @@ public function print_criteria_actions(badge $badge) {
$select[$p] = get_string('criteria_' . $p, 'badges');
}
}
$actions[] = get_string('addbadgecriteria', 'badges');
$actions[] = $this->output->single_select(new moodle_url('/badges/criteria_settings.php',
array('badgeid' => $badge->id, 'add' => true)), 'type', $select);
$output .= $this->output->single_select(
new moodle_url('/badges/criteria_settings.php', array('badgeid' => $badge->id, 'add' => true)),
'type',
$select,
'',
array('' => 'choosedots'),
null,
array('label' => get_string('addbadgecriteria', 'badges'))
);
} else {
$actions[] = $this->output->box(get_string('nothingtoadd', 'badges'), 'clearfix');
$output .= $this->output->box(get_string('nothingtoadd', 'badges'), 'clearfix');
}
}

$table->data[] = $actions;
return html_writer::table($table);
return $output;
}

// Renders a table with users who have earned the badge.
Expand Down
10 changes: 9 additions & 1 deletion lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1826,14 +1826,22 @@ protected function render_single_button(single_button $button) {
* @param string $selected selected element
* @param array $nothing
* @param string $formid
* @param array $attributes other attributes for the single select
* @return string HTML fragment
*/
public function single_select($url, $name, array $options, $selected = '', $nothing = array('' => 'choosedots'), $formid = null) {
public function single_select($url, $name, array $options, $selected = '',
$nothing = array('' => 'choosedots'), $formid = null, $attributes = array()) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$select = new single_select($url, $name, $options, $selected, $nothing, $formid);

if (array_key_exists('label', $attributes)) {
$select->set_label($attributes['label']);
unset($attributes['label']);
}
$select->attributes = $attributes;

return $this->render($select);
}

Expand Down
4 changes: 2 additions & 2 deletions mod/data/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@


echo '<div class="fieldadd">';
echo '<label for="fieldform_jump">'.get_string('newfield','data').$OUTPUT->help_icon('newfield', 'data').'</label>';
$popupurl = $CFG->wwwroot.'/mod/data/field.php?d='.$data->id.'&mode=new&sesskey='. sesskey();
echo $OUTPUT->single_select(new moodle_url($popupurl), 'newtype', $menufield, null, array(''=>'choosedots'), 'fieldform');
echo $OUTPUT->single_select(new moodle_url($popupurl), 'newtype', $menufield, null, array('' => 'choosedots'),
'fieldform', array('label' => get_string('newfield', 'data') . $OUTPUT->help_icon('newfield', 'data')));
echo '</div>';

echo '<div class="sortdefault">';
Expand Down
9 changes: 6 additions & 3 deletions mod/wiki/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ public function wiki_print_subwiki_selector($wiki, $subwiki, $page, $pagetype =
echo $this->output->container_start('wiki_right');
$name = 'uid';
$selected = $subwiki->userid;
echo $this->output->single_select($baseurl, $name, $options, $selected, null);
echo $this->output->single_select($baseurl, $name, $options, $selected, null, null,
array('label' => get_string('user') . ':'));
echo $this->output->container_end();
}
return;
Expand Down Expand Up @@ -398,7 +399,8 @@ public function wiki_print_subwiki_selector($wiki, $subwiki, $page, $pagetype =
echo $this->output->container_start('wiki_right');
$name = 'groupanduser';
$selected = $subwiki->groupid . '-' . $subwiki->userid;
echo $this->output->single_select($baseurl, $name, $options, $selected, null);
echo $this->output->single_select($baseurl, $name, $options, $selected, null, null,
array('label' => get_string('user') . ':'));
echo $this->output->container_end();

return;
Expand Down Expand Up @@ -435,7 +437,8 @@ public function wiki_print_subwiki_selector($wiki, $subwiki, $page, $pagetype =
echo $this->output->container_start('wiki_right');
$name = 'groupanduser';
$selected = $subwiki->groupid . '-' . $subwiki->userid;
echo $this->output->single_select($baseurl, $name, $options, $selected, null);
echo $this->output->single_select($baseurl, $name, $options, $selected, null, null,
array('label' => get_string('user') . ':'));
echo $this->output->container_end();

return;
Expand Down
4 changes: 2 additions & 2 deletions user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@
// If there are multiple Roles in the course, then show a drop down menu for switching.
if (count($rolenames) > 1) {
echo '<div class="rolesform">';
echo '<label for="rolesform_jump">'.get_string('currentrole', 'role').'&nbsp;</label>';
echo $OUTPUT->single_select($rolenamesurl, 'roleid', $rolenames, $roleid, null, 'rolesform');
echo $OUTPUT->single_select($rolenamesurl, 'roleid', $rolenames, $roleid, null,
'rolesform', array('label' => get_string('currentrole', 'role')));
echo '</div>';

} else if (count($rolenames) == 1) {
Expand Down
2 changes: 1 addition & 1 deletion user/profile/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
// Create a new field link.
$options = profile_list_datatypes();
$popupurl = new moodle_url('/user/profile/index.php?id=0&action=editfield');
echo $OUTPUT->single_select($popupurl, 'datatype', $options, '', array('' => $strcreatefield), 'newfieldform');
echo $OUTPUT->single_select($popupurl, 'datatype', $options, '', null, 'newfieldform', array('label' => $strcreatefield));

// Add a div with a class so themers can hide, style or reposition the text.
html_writer::start_tag('div', array('class' => 'adminuseractionhint'));
Expand Down

0 comments on commit 356fd5b

Please sign in to comment.