MDL-37523 theme_mymobile: Removed a renderer from mymobile/renderers.php and added...
authorMary Evans <lazydaisy@visible-expression.co.uk>
Sun, 3 Feb 2013 23:35:05 +0000 (23:35 +0000)
committerMary Evans <lazydaisy@visible-expression.co.uk>
Sun, 3 Feb 2013 23:35:05 +0000 (23:35 +0000)
theme/mymobile/renderers.php
theme/mymobile/renderers/mod_choice_renderer.php [new file with mode: 0644]

index f3d3e9e..b32c5fb 100644 (file)
@@ -32,8 +32,6 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-include_once ($CFG->dirroot. '/mod/choice/renderer.php');
-
 class theme_mymobile_renderer extends plugin_renderer_base {
 
     /**
@@ -794,196 +792,15 @@ class theme_mymobile_core_renderer extends core_renderer {
 }
 
 /**
- * Overridden choie module renderer for the mymobile theme
+ * Overridden choice module renderer for the mymobile theme
  *
  * @package    theme
  * @subpackage mymobile
  * @copyright  John Stabinger
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class theme_mymobile_mod_choice_renderer extends mod_choice_renderer {
 
-    /**
-     * Returns HTML to display choices of option
-     * @param object $options
-     * @param int  $coursemoduleid
-     * @param bool $vertical
-     * @return string
-     */
-    public function display_options($options, $coursemoduleid, $vertical = false) {
-        $layoutclass = 'horizontal';
-        if ($vertical) {
-            $layoutclass = 'vertical';
-        }
-        $target = new moodle_url('/mod/choice/view.php');
-        //changed below to post from target john
-        $attributes = array('method'=>'POST', 'action'=>$target, 'class'=> $layoutclass);
-
-        $html = html_writer::start_tag('form', $attributes);
-        $html .= html_writer::start_tag('ul', array('class'=>'choices', 'data-role'=>'controlgroup' ));
-
-        $availableoption = count($options['options']);
-        foreach ($options['options'] as $option) {
-            $html .= html_writer::start_tag('li', array('class'=>'option'));
-            $option->attributes->name = 'answer';
-            $option->attributes->type = 'radio';
-            $option->attributes->id = 'answer'.html_writer::random_id();
-
-            $labeltext = $option->text;
-            if (!empty($option->attributes->disabled)) {
-                $labeltext .= ' ' . get_string('full', 'choice');
-                $availableoption--;
-            }
-
-            $html .= html_writer::empty_tag('input', (array)$option->attributes);
-            $html .= html_writer::tag('label', $labeltext, array('for'=>$option->attributes->id));
-            $html .= html_writer::end_tag('li');
-        }
-        $html .= html_writer::tag('li','', array('class'=>'clearfloat'));
-        $html .= html_writer::end_tag('ul');
-        $html .= html_writer::tag('div', '', array('class'=>'clearfloat'));
-        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
-        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=>$coursemoduleid));
-
-        if (!empty($options['hascapability']) && ($options['hascapability'])) {
-            if ($availableoption < 1) {
-               $html .= html_writer::tag('label', get_string('choicefull', 'choice'));
-            } else {
-                $html .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('savemychoice','choice'), 'class'=>'button'));
-            }
-
-            if (!empty($options['allowupdate']) && ($options['allowupdate'])) {
-                $url = new moodle_url('view.php', array('id'=>$coursemoduleid, 'action'=>'delchoice', 'sesskey'=>sesskey()));
-                $html .= html_writer::link($url, get_string('removemychoice','choice'));
-            }
-        } else {
-            $html .= html_writer::tag('label', get_string('havetologin', 'choice'));
-        }
-
-        $html .= html_writer::end_tag('ul');
-        $html .= html_writer::end_tag('form');
-
-        return $html;
-    }
-
-    /**
-     * Returns HTML to display choices result
-     *
-     * TODO: There are differences between this method and the mod choice renderers function.
-     *       This needs to be checked VERY careful as the minor changes look like they
-     *       may lead to regressions.
-     *
-     * @param object $choices
-     * @param bool $forcepublish
-     * @return string
-     */
-    public function display_publish_name_vertical($choices) {
-        $html ='';
-        $html .= html_writer::tag('h2',format_string(get_string("responses", "choice")), array('class'=>'main'));
-
-        $attributes = array('method'=>'POST');
-        $attributes['action'] = new moodle_url('/mod/choice/view.php');
-        $attributes['id'] = 'attemptsform';
-
-        if ($choices->viewresponsecapability) {
-            $html .= html_writer::start_tag('form', $attributes);
-            $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=> $choices->coursemoduleid));
-            $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=> sesskey()));
-            $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'mode', 'value'=>'overview'));
-        }
-
-        $table = new html_table();
-        $table->cellpadding = 0;
-        $table->cellspacing = 0;
-        $table->attributes['class'] = 'results names ';
-        $table->tablealign = 'center';
-        $table->data = array();
-
-        $count = 0;
-        ksort($choices->options);
-
-        $columns = array();
-        foreach ($choices->options as $optionid => $options) {
-            $coldata = '';
-            if ($choices->showunanswered && $optionid == 0) {
-                $coldata .= html_writer::tag('div', format_string(get_string('notanswered', 'choice')), array('class'=>'option'));
-            } else if ($optionid > 0) {
-                $coldata .= html_writer::tag('div', format_string($choices->options[$optionid]->text), array('class'=>'option'));
-            }
-            $numberofuser = 0;
-            if (!empty($options->user) && count($options->user) > 0) {
-                $numberofuser = count($options->user);
-            }
-
-            $coldata .= html_writer::tag('div', ' ('.$numberofuser. ')', array('class'=>'numberofuser', 'title' => get_string('numberofuser', 'choice')));
-            $columns[] = $coldata;
-        }
-
-        $table->head = $columns;
-
-        $coldata = '';
-        $columns = array();
-        foreach ($choices->options as $optionid => $options) {
-            $coldata = '';
-            if ($choices->showunanswered || $optionid > 0) {
-                if (!empty($options->user)) {
-                    foreach ($options->user as $user) {
-                        $data = '';
-                        if (empty($user->imagealt)){
-                            $user->imagealt = '';
-                        }
-
-                        if ($choices->viewresponsecapability && $choices->deleterepsonsecapability  && $optionid > 0) {
-                            $attemptaction = html_writer::checkbox('attemptid[]', $user->id,'');
-                            $data .= html_writer::tag('div', $attemptaction, array('class'=>'attemptaction'));
-                        }
-                        $userimage = $this->output->user_picture($user, array('courseid'=>$choices->courseid));
-                        $data .= html_writer::tag('div', $userimage, array('class'=>'image'));
-
-                        $userlink = new moodle_url('/user/view.php', array('id'=>$user->id,'course'=>$choices->courseid));
-                        $name = html_writer::tag('a', fullname($user, $choices->fullnamecapability), array('href'=>$userlink, 'class'=>'username'));
-                        $data .= html_writer::tag('div', $name, array('class'=>'fullname'));
-                        $data .= html_writer::tag('div','', array('class'=>'clearfloat'));
-                        $coldata .= html_writer::tag('div', $data, array('class'=>'user'));
-                    }
-                }
-            }
-
-            $columns[] = $coldata;
-            $count++;
-        }
-
-        $table->data[] = $columns;
-        foreach ($columns as $d) {
-            $table->colclasses[] = 'data';
-        }
-        $html .= html_writer::tag('div', html_writer::table($table), array('class'=>'response'));
-
-        $actiondata = '';
-        if ($choices->viewresponsecapability && $choices->deleterepsonsecapability) {
-            $selecturl = new moodle_url('#');
-
-            $selectallactions = new component_action('click',"select_all_in", array('div',null,'tablecontainer'));
-            $selectall = new action_link($selecturl, get_string('selectall'), $selectallactions);
-            $actiondata .= $this->output->render($selectall) . ' / ';
-
-            $deselectallactions = new component_action('click',"deselect_all_in", array('div',null,'tablecontainer'));
-            $deselectall = new action_link($selecturl, get_string('deselectall'), $deselectallactions);
-            $actiondata .= $this->output->render($deselectall);
-            //below john fixed
-            $actiondata .= html_writer::tag('label', ' ' . get_string('withselected', 'choice') . ' ', array('for'=>'menuaction'));
-
-            $actionurl = new moodle_url('/mod/choice/view.php', array('sesskey'=>sesskey(), 'action'=>'delete_confirmation()'));
-            $select = new single_select($actionurl, 'action', array('delete'=>get_string('delete')), null, array(''=>get_string('moveselectedusersto', 'choice')), 'attemptsform');
-
-            $actiondata .= $this->output->render($select);
-        }
-        $html .= html_writer::tag('div', $actiondata, array('class'=>'responseaction'));
-
-        if ($choices->viewresponsecapability) {
-            $html .= html_writer::end_tag('form');
-        }
-
-        return $html;
-    }
+$choice = get_plugin_directory('mod', 'choice');
+if (file_exists($choice . '/renderer.php')) {
+    require_once($CFG->dirroot . '/theme/mymobile/renderers/mod_choice_renderer.php');
 }
diff --git a/theme/mymobile/renderers/mod_choice_renderer.php b/theme/mymobile/renderers/mod_choice_renderer.php
new file mode 100644 (file)
index 0000000..011ed47
--- /dev/null
@@ -0,0 +1,190 @@
+<?php
+
+include_once ($CFG->dirroot. '/mod/choice/renderer.php');
+
+class theme_mymobile_mod_choice_renderer extends mod_choice_renderer {
+
+    /**
+     * Returns HTML to display choices of option
+     * @param object $options
+     * @param int  $coursemoduleid
+     * @param bool $vertical
+     * @return string
+     */
+    public function display_options($options, $coursemoduleid, $vertical = false) {
+        $layoutclass = 'horizontal';
+        if ($vertical) {
+            $layoutclass = 'vertical';
+        }
+        $target = new moodle_url('/mod/choice/view.php');
+        //changed below to post from target john
+        $attributes = array('method'=>'POST', 'action'=>$target, 'class'=> $layoutclass);
+
+        $html = html_writer::start_tag('form', $attributes);
+        $html .= html_writer::start_tag('ul', array('class'=>'choices', 'data-role'=>'controlgroup' ));
+
+        $availableoption = count($options['options']);
+        foreach ($options['options'] as $option) {
+            $html .= html_writer::start_tag('li', array('class'=>'option'));
+            $option->attributes->name = 'answer';
+            $option->attributes->type = 'radio';
+            $option->attributes->id = 'answer'.html_writer::random_id();
+
+            $labeltext = $option->text;
+            if (!empty($option->attributes->disabled)) {
+                $labeltext .= ' ' . get_string('full', 'choice');
+                $availableoption--;
+            }
+
+            $html .= html_writer::empty_tag('input', (array)$option->attributes);
+            $html .= html_writer::tag('label', $labeltext, array('for'=>$option->attributes->id));
+            $html .= html_writer::end_tag('li');
+        }
+        $html .= html_writer::tag('li','', array('class'=>'clearfloat'));
+        $html .= html_writer::end_tag('ul');
+        $html .= html_writer::tag('div', '', array('class'=>'clearfloat'));
+        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
+        $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=>$coursemoduleid));
+
+        if (!empty($options['hascapability']) && ($options['hascapability'])) {
+            if ($availableoption < 1) {
+               $html .= html_writer::tag('label', get_string('choicefull', 'choice'));
+            } else {
+                $html .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('savemychoice','choice'), 'class'=>'button'));
+            }
+
+            if (!empty($options['allowupdate']) && ($options['allowupdate'])) {
+                $url = new moodle_url('view.php', array('id'=>$coursemoduleid, 'action'=>'delchoice', 'sesskey'=>sesskey()));
+                $html .= html_writer::link($url, get_string('removemychoice','choice'));
+            }
+        } else {
+            $html .= html_writer::tag('label', get_string('havetologin', 'choice'));
+        }
+
+        $html .= html_writer::end_tag('ul');
+        $html .= html_writer::end_tag('form');
+
+        return $html;
+    }
+
+    /**
+     * Returns HTML to display choices result
+     *
+     * TODO: There are differences between this method and the mod choice renderers function.
+     *       This needs to be checked VERY careful as the minor changes look like they
+     *       may lead to regressions.
+     *
+     * @param object $choices
+     * @param bool $forcepublish
+     * @return string
+     */
+    public function display_publish_name_vertical($choices) {
+        $html ='';
+        $html .= html_writer::tag('h2',format_string(get_string("responses", "choice")), array('class'=>'main'));
+
+        $attributes = array('method'=>'POST');
+        $attributes['action'] = new moodle_url('/mod/choice/view.php');
+        $attributes['id'] = 'attemptsform';
+
+        if ($choices->viewresponsecapability) {
+            $html .= html_writer::start_tag('form', $attributes);
+            $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=> $choices->coursemoduleid));
+            $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=> sesskey()));
+            $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'mode', 'value'=>'overview'));
+        }
+
+        $table = new html_table();
+        $table->cellpadding = 0;
+        $table->cellspacing = 0;
+        $table->attributes['class'] = 'results names ';
+        $table->tablealign = 'center';
+        $table->data = array();
+
+        $count = 0;
+        ksort($choices->options);
+
+        $columns = array();
+        foreach ($choices->options as $optionid => $options) {
+            $coldata = '';
+            if ($choices->showunanswered && $optionid == 0) {
+                $coldata .= html_writer::tag('div', format_string(get_string('notanswered', 'choice')), array('class'=>'option'));
+            } else if ($optionid > 0) {
+                $coldata .= html_writer::tag('div', format_string($choices->options[$optionid]->text), array('class'=>'option'));
+            }
+            $numberofuser = 0;
+            if (!empty($options->user) && count($options->user) > 0) {
+                $numberofuser = count($options->user);
+            }
+
+            $coldata .= html_writer::tag('div', ' ('.$numberofuser. ')', array('class'=>'numberofuser', 'title' => get_string('numberofuser', 'choice')));
+            $columns[] = $coldata;
+        }
+
+        $table->head = $columns;
+
+        $coldata = '';
+        $columns = array();
+        foreach ($choices->options as $optionid => $options) {
+            $coldata = '';
+            if ($choices->showunanswered || $optionid > 0) {
+                if (!empty($options->user)) {
+                    foreach ($options->user as $user) {
+                        $data = '';
+                        if (empty($user->imagealt)){
+                            $user->imagealt = '';
+                        }
+
+                        if ($choices->viewresponsecapability && $choices->deleterepsonsecapability  && $optionid > 0) {
+                            $attemptaction = html_writer::checkbox('attemptid[]', $user->id,'');
+                            $data .= html_writer::tag('div', $attemptaction, array('class'=>'attemptaction'));
+                        }
+                        $userimage = $this->output->user_picture($user, array('courseid'=>$choices->courseid));
+                        $data .= html_writer::tag('div', $userimage, array('class'=>'image'));
+
+                        $userlink = new moodle_url('/user/view.php', array('id'=>$user->id,'course'=>$choices->courseid));
+                        $name = html_writer::tag('a', fullname($user, $choices->fullnamecapability), array('href'=>$userlink, 'class'=>'username'));
+                        $data .= html_writer::tag('div', $name, array('class'=>'fullname'));
+                        $data .= html_writer::tag('div','', array('class'=>'clearfloat'));
+                        $coldata .= html_writer::tag('div', $data, array('class'=>'user'));
+                    }
+                }
+            }
+
+            $columns[] = $coldata;
+            $count++;
+        }
+
+        $table->data[] = $columns;
+        foreach ($columns as $d) {
+            $table->colclasses[] = 'data';
+        }
+        $html .= html_writer::tag('div', html_writer::table($table), array('class'=>'response'));
+
+        $actiondata = '';
+        if ($choices->viewresponsecapability && $choices->deleterepsonsecapability) {
+            $selecturl = new moodle_url('#');
+
+            $selectallactions = new component_action('click',"select_all_in", array('div',null,'tablecontainer'));
+            $selectall = new action_link($selecturl, get_string('selectall'), $selectallactions);
+            $actiondata .= $this->output->render($selectall) . ' / ';
+
+            $deselectallactions = new component_action('click',"deselect_all_in", array('div',null,'tablecontainer'));
+            $deselectall = new action_link($selecturl, get_string('deselectall'), $deselectallactions);
+            $actiondata .= $this->output->render($deselectall);
+            //below john fixed
+            $actiondata .= html_writer::tag('label', ' ' . get_string('withselected', 'choice') . ' ', array('for'=>'menuaction'));
+
+            $actionurl = new moodle_url('/mod/choice/view.php', array('sesskey'=>sesskey(), 'action'=>'delete_confirmation()'));
+            $select = new single_select($actionurl, 'action', array('delete'=>get_string('delete')), null, array(''=>get_string('moveselectedusersto', 'choice')), 'attemptsform');
+
+            $actiondata .= $this->output->render($select);
+        }
+        $html .= html_writer::tag('div', $actiondata, array('class'=>'responseaction'));
+
+        if ($choices->viewresponsecapability) {
+            $html .= html_writer::end_tag('form');
+        }
+
+        return $html;
+    }
+}