Skip to content

Commit

Permalink
Changed columns to use format_text
Browse files Browse the repository at this point in the history
Fixes for issue#6.
  • Loading branch information
drachels committed Oct 1, 2021
1 parent 52bba88 commit 9ee7e0d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 45 deletions.
3 changes: 2 additions & 1 deletion mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ public function definition() {
$mform =& $this->_form;

// 20210218 Changed to using a text editor instead of textarea.
$mform->addElement('editor', 'text_editor', $temp->submitdirections, 'wrap="virtual" rows="5"');
// Changed to format text which allows filters such as Gerico, etc. to work.
$mform->addElement('editor', 'text_editor', format_text($temp->submitdirections, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null), 'wrap="virtual" rows="5"');
$mform->setType('text_editor', PARAM_RAW);

$mform->addElement('hidden', 'id', $cm->id, 'id="hotquestion_courseid"');
Expand Down
78 changes: 36 additions & 42 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();

/**
* A custmom renderer class that extends the plugin_renderer_base and is used by the hotquestion module.
* A custom renderer class that extends the plugin_renderer_base and is used by the hotquestion module.
*
* @package mod_hotquestion
* @copyright 2019 onwards AL Rachels [email protected]
Expand Down Expand Up @@ -54,6 +54,7 @@ public function introduction() {
$output = '';
if (trim($this->hotquestion->instance->intro)) {
$output .= $this->box_start('generalbox boxaligncenter', 'intro');
// Add the description for this activity.
$output .= format_module_intro('hotquestion', $this->hotquestion->instance, $this->hotquestion->cm->id);
$output .= $this->box_end();
}
Expand Down Expand Up @@ -83,46 +84,42 @@ public function toolbar($shownew = true) {
$options['id'] = $this->hotquestion->cm->id;
$options['action'] = 'download';
$url = new moodle_url('/mod/hotquestion/view.php', $options);
$toolbuttons[] = html_writer::link($url, $this->pix_icon('a/download_all',
get_string('csvexport', 'hotquestion')),
array('class' => 'toolbutton'));
$toolbuttons[] = html_writer::link($url, $this->pix_icon('a/download_all'
, get_string('csvexport', 'hotquestion'))
, array('class' => 'toolbutton'));
}

// Print prev/next round toolbuttons.
if ($this->hotquestion->get_prevround() != null) {
$roundp = $this->hotquestion->get_prevround()->id;
$roundn = '';
$url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id, 'round' => $roundp));
$toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed_rtl',
get_string('previousround', 'hotquestion')),
array('class' => 'toolbutton'));
$toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed_rtl'
, get_string('previousround', 'hotquestion'))
, array('class' => 'toolbutton'));
} else {
$toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty_rtl', ''),
array('class' => 'dis_toolbutton'));
$toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty_rtl', '')
, array('class' => 'dis_toolbutton'));
}

// 20200215 Text added to show x of n display in toolbar.
if (($this->hotquestion->get_roundcount() != null) && ($this->hotquestion->get_currentroundx() != null)) {
$cx = $this->hotquestion->get_currentroundx();
// Showing round x of n rounds. X = current round being looked at and n = total number of rounds.
$toolbuttons[] = $cx.get_string('xofn', 'hotquestion').
$this->hotquestion->get_roundcount();
$toolbuttons[] = $cx.get_string('xofn', 'hotquestion').$this->hotquestion->get_roundcount();
} else {
$toolbuttons[] = $this->hotquestion->get_roundcount().
get_string('xofn', 'hotquestion').
$this->hotquestion->get_roundcount();
$toolbuttons[] = $this->hotquestion->get_roundcount().get_string('xofn', 'hotquestion')
.$this->hotquestion->get_roundcount();
}

if ($this->hotquestion->get_nextround() != null) {
$roundn = $this->hotquestion->get_nextround()->id;
$roundp = '';
$url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id, 'round' => $roundn));
$toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed',
get_string('nextround', 'hotquestion')),
array('class' => 'toolbutton'));
$toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed'
, get_string('nextround', 'hotquestion')), array('class' => 'toolbutton'));
} else {
$toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty', ''),
array('class' => 'dis_toolbutton'));
$toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty', ''), array('class' => 'dis_toolbutton'));
}

// Print new round toolbutton.
Expand Down Expand Up @@ -170,9 +167,7 @@ public function toolbar($shownew = true) {

// Print refresh toolbutton.
$url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id));
$toolbuttons[] = html_writer::link($url, $this->pix_icon('t/reload',
get_string('reload')),
array('class' => 'toolbutton'));
$toolbuttons[] = html_writer::link($url, $this->pix_icon('t/reload', get_string('reload')), array('class' => 'toolbutton'));

// Return all available toolbuttons.
$output .= html_writer::alist($toolbuttons, array('id' => 'toolbar'));
Expand Down Expand Up @@ -234,51 +229,50 @@ public function questions($allowvote = true) {

// Admin, manager and teachers headings for questions, priority, heat, remove and approved headings.
if (has_capability('mod/hotquestion:manageentries', $context)) {
// 20200512 Changed from fixed string to new questionlabel column setting.
$table->head = array($this->hotquestion->instance->questionlabel);
// 20210924 Changed to format_text questionlabel column setting.
$table->head = array(format_text($this->hotquestion->instance->questionlabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null));
// Check teacher priority column visibilty settings.
if ($teacherpriorityvisibility) {
// Priority column is visible, so show the label.
// 20200512 Changed from fixed string to new prioritylable column setting.
$table->head[] .= $this->hotquestion->instance->teacherprioritylabel;
// 20210924 Changed to format_text prioritylabel column setting.
$table->head[] .= format_text($this->hotquestion->instance->teacherprioritylabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null);
} else {
// Priority column is not visible, so replace label with a space.
$table->head[] .= ' ';
}
// Check heat column visibilty settings for teachers.
if ($heatvisibility) {
// 20200512 Changed from fixed string to new heatlabel column setting.
// 20210924 Changed to format_text heatlabel column setting.
// 20200526 Show heatlimit setting and how many heat/votes remain for current user.
$table->head[] .= $this->hotquestion->instance->heatlabel
$table->head[] .= format_text($this->hotquestion->instance->heatlabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null)
.' '.$this->hotquestion->instance->heatlimit
.'/'.$temp;

} else {
// Heat column is not visible, so replace label with a space.
$table->head[] .= ' ';
}
// 20200512 Changed from fixed string to new removelabel column setting.
$table->head[] .= $this->hotquestion->instance->removelabel;
// 20200512 Changed from fixed string to new approvallabel column setting.
$table->head[] .= $this->hotquestion->instance->approvallabel;
// 20210924 Changed to format_text removelabel column setting.
$table->head[] .= format_text($this->hotquestion->instance->removelabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null);
// 20210924 Changed to format_text approvallabel column setting.
$table->head[] .= format_text($this->hotquestion->instance->approvallabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null);
} else {
// Students only see headings for questions, priority, and heat columns.
// 20200512 Changed from fixed string to new questionlabel column setting.
$table->head = array($this->hotquestion->instance->questionlabel);
// 20210924 Changed to format_text questionlabel column setting.
$table->head = array(format_text($this->hotquestion->instance->questionlabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null));
// Check teacher priority column visibilty settings.
if ($teacherpriorityvisibility) {
// 20200512 Changed from fixed string to new prioritylabel column setting.
// 20210924 Changed to format_text prioritylabel column setting.
// Priority column is visible, so show the label.
$table->head[] .= $this->hotquestion->instance->teacherprioritylabel;
$table->head[] .= format_text($this->hotquestion->instance->teacherprioritylabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null);
} else {
// Priority column is not visible, so replace label with a space.
$table->head[] .= ' ';
}
// Check heat column visibilty settings for students.
if ($heatvisibility) {
// 20200512 Changed from fixed string to new heatlabel column setting.
// 20210924 Changed to format_text heatlabel column setting.
// Heat column is visible, so show the label.
$table->head[] .= $this->hotquestion->instance->heatlabel
$table->head[] .= format_text($this->hotquestion->instance->heatlabel, $format = FORMAT_MOODLE, $options = null, $courseid_do_not_use = null)
.' '.$this->hotquestion->instance->heatlimit
.'/'.$temp;
} else {
Expand Down Expand Up @@ -320,11 +314,11 @@ public function questions($allowvote = true) {
, format_time(time() - $question->time)).')';
// 20201217 Added capability to hide authors name from students.
if (!$authorinfohide || (has_capability('mod/hotquestion:manageentries', $context))) {
$info = '<div class="author">'.get_string('authorinfo', 'hotquestion', $a).'</div>';
$authorinfo = '<div class="author">'.get_string('authorinfo', 'hotquestion', $a).'</div>';
} else {
$info = '<div class="author">'.get_string('authorinfohide', 'hotquestion', $a).'</div>';
$authorinfo = '<div class="author">'.get_string('authorinfohide', 'hotquestion', $a).'</div>';
}
$line[] = $content.$info;
$line[] = $content.$authorinfo;
// Get current priority value to show.
$tpriority = $question->tpriority;
// Get current heat total to show.
Expand Down
11 changes: 11 additions & 0 deletions upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
=== 4.0.1 ===
20210516 Hot Question_695 - Invalid get_string() identifier: 'hotquestion:rate'.
Added the missing string.
20210516 Hot Question_723 - Invalid get_string() identifier: 'hotquestion:comment'.
Added the missing string.
20210823 Hot Question_751 - user_picture::fields() is deprecated. Please use the
\core_user\fields API instead. For compatibility, added an if check to use the new
code for Moodle > 3.0 the old code for 3.0 and below.
20211001 Hot Question_752 - need to format_text of the submit directions. Changed the
code to include format_text, in mod_form.php down around line 236.

=== 4.0.0 ===
20210321 Hot Question_561 See about using editor text area to allow for formatting
and emoji's. Got it working in just a couple of hours, mostly looking for the
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021032300; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2021100100; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2014111000; // Requires Moodle 2.8 version.
$plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->component = 'mod_hotquestion';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = "4.0.0 (Build: 2021032300)"; // User-friendly version number.
$plugin->release = "4.0.1 (Build: 2021100100)"; // User-friendly version number.

0 comments on commit 9ee7e0d

Please sign in to comment.