MDL-40096 assign: Prevent js error because uniqid() is not unique.
authorDamyon Wiese <damyon@moodle.com>
Mon, 9 Dec 2013 02:24:17 +0000 (10:24 +0800)
committerDamyon Wiese <damyon@moodle.com>
Mon, 9 Dec 2013 02:25:15 +0000 (10:25 +0800)
Use html_writer::random_id instead because it incorporates a static counter.

mod/assign/renderer.php

index f9058c8..7403917 100644 (file)
@@ -55,7 +55,7 @@ class mod_assign_renderer extends plugin_renderer_base {
      * @return string
      */
     public function render_assign_files(assign_files $tree) {
-        $this->htmlid = 'assign_files_tree_'.uniqid();
+        $this->htmlid = html_writer::random_id('assign_files_tree');
         $this->page->requires->js_init_call('M.mod_assign.init_tree', array(true, $this->htmlid));
         $html = '<div id="'.$this->htmlid.'">';
         $html .= $this->htmllize_tree($tree, $tree->dir);