Revert "MDL-36704: wrap pending conditions in span tags"
authorDan Poltawski <dan@moodle.com>
Thu, 20 Dec 2012 00:45:04 +0000 (08:45 +0800)
committerDan Poltawski <dan@moodle.com>
Thu, 20 Dec 2012 00:45:04 +0000 (08:45 +0800)
lib/conditionlib.php [changed mode: 0755->0644]
lib/tests/conditionlib_test.php [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index a4b7d20..71d36c7
@@ -303,8 +303,7 @@ class condition_info_section extends condition_info_base {
                         array($this->item->groupingid, $userid));
                 if (!$gotit && !has_capability('moodle/site:accessallgroups', $context, $userid)) {
                     $available = false;
-                    $information .= html_writer::tag('span',
-                        get_string('groupingnoaccess', 'condition'), array('class'=>"conditionalrule groupingnoaccess"));
+                    $information .= get_string('groupingnoaccess', 'condition');
                 }
             } else {
                 // Request is for current user - use cache
@@ -333,8 +332,7 @@ class condition_info_section extends condition_info_base {
                 $usergroupings = $CONDITIONLIB_PRIVATE->groupingscache[$this->item->course];
                 if ($usergroupings !== true && !array_key_exists($this->item->groupingid, $usergroupings)) {
                     $available = false;
-                    $information .= html_writer::tag('span',
-                        get_string('groupingnoaccess', 'condition'), array('class'=>"conditionalrule groupingnoaccess"));
+                    $information .= get_string('groupingnoaccess', 'condition');
                 }
             }
         }
@@ -778,9 +776,9 @@ abstract class condition_info_base {
                 if (empty($modinfo->cms[$cmid])) {
                     continue;
                 }
-                $information .= html_writer::tag('span',
-                    get_string('requires_completion_' . $expectedcompletion, 'condition', $modinfo->cms[$cmid]->name).' ',
-                    array('class'=>"conditionalrule requires_completion"));
+                $information .= get_string(
+                        'requires_completion_' . $expectedcompletion,
+                        'condition', $modinfo->cms[$cmid]->name) . ' ';
             }
         }
 
@@ -799,8 +797,7 @@ abstract class condition_info_base {
                 } else {
                     $string = 'range';
                 }
-                $information .= html_writer::tag('span', get_string('requires_grade_'.$string, 'condition', $minmax->name).' ',
-                    array('class'=>"conditionalrule requires_grade"));
+                $information .= get_string('requires_grade_'.$string, 'condition', $minmax->name).' ';
             }
         }
 
@@ -862,22 +859,19 @@ abstract class condition_info_base {
 
         if ($this->item->availablefrom && $this->item->availableuntil) {
             if ($shortfrom && $shortuntil && $daybeforeuntil == $this->item->availablefrom) {
-                $information .= html_writer::tag('span',
-                    get_string('requires_date_both_single_day', 'condition', self::show_time($this->item->availablefrom, true)),
-                    array('class'=>"conditionalrule requires_date_both_single_day"));
+                $information .= get_string('requires_date_both_single_day', 'condition',
+                        self::show_time($this->item->availablefrom, true));
             } else {
-                $information .= html_writer::tag('span',
-                    get_string('requires_date_both', 'condition',
-                        (object)array('from' => self::show_time($this->item->availablefrom, $shortfrom),
-                        'until' => self::show_time($displayuntil, $shortuntil))),
-                    array('class'=>"conditionalrule requires_date_both"));
+                $information .= get_string('requires_date_both', 'condition', (object)array(
+                         'from' => self::show_time($this->item->availablefrom, $shortfrom),
+                         'until' => self::show_time($displayuntil, $shortuntil)));
             }
         } else if ($this->item->availablefrom) {
-            $information .= html_writer::tag('span', get_string('requires_date', 'condition',
-                self::show_time($this->item->availablefrom, $shortfrom)), array('class'=>"conditionalrule requires_date"));
+            $information .= get_string('requires_date', 'condition',
+                self::show_time($this->item->availablefrom, $shortfrom));
         } else if ($this->item->availableuntil) {
-            $information .= html_writer::tag('span', get_string('requires_date_before', 'condition',
-                self::show_time($displayuntil, $shortuntil)), array('class'=>"conditionalrule requires_date_before"));
+            $information .= get_string('requires_date_before', 'condition',
+                self::show_time($displayuntil, $shortuntil));
         }
 
         $information = trim($information);
@@ -977,9 +971,9 @@ abstract class condition_info_base {
                 }
                 if (!$thisisok) {
                     $available = false;
-                    $information .= html_writer::tag('span',
-                        get_string('requires_completion_' . $expectedcompletion, 'condition', $modinfo->cms[$cmid]->name).' ',
-                        array('class'=>"conditionalrule requires_completion"));
+                    $information .= get_string(
+                        'requires_completion_' . $expectedcompletion,
+                        'condition', $modinfo->cms[$cmid]->name) . ' ';
                 }
             }
         }
@@ -1005,9 +999,7 @@ abstract class condition_info_base {
                     } else {
                         $string = 'range';
                     }
-                    $information .= html_writer::tag('span',
-                        get_string('requires_grade_' . $string, 'condition', $minmax->name).' ',
-                        array('class'=>"conditionalrule requires_grade"));
+                    $information .= get_string('requires_grade_' . $string, 'condition', $minmax->name) . ' ';
                 }
             }
         }
@@ -1032,10 +1024,9 @@ abstract class condition_info_base {
             if (time() < $this->item->availablefrom) {
                 $available = false;
 
-                $information .= html_writer::tag('span',
-                    get_string('requires_date', 'condition',
-                        self::show_time($this->item->availablefrom, self::is_midnight($this->item->availablefrom))),
-                    array('class'=>"conditionalrule availablefrom"));
+                $information .= get_string('requires_date', 'condition',
+                        self::show_time($this->item->availablefrom,
+                            self::is_midnight($this->item->availablefrom)));
             }
         }
 
old mode 100755 (executable)
new mode 100644 (file)
index a147199..75fed3c
@@ -481,7 +481,7 @@ class conditionlib_testcase extends advanced_testcase {
         condition_info::wipe_session_cache();
 
         $this->assertFalse($ci->is_available($text,false));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_completion_1','condition','xxx').' ',array('class'=>'conditionalrule requires_completion')),$text);
+        $this->assertEquals(get_string('requires_completion_1','condition','xxx'),$text);
         completion_info::wipe_session_cache();
         $completion=new completion_info($DB->get_record('course',array('id'=>$courseid)));
         $completion->update_state($oldcm,COMPLETION_COMPLETE);
@@ -513,7 +513,7 @@ class conditionlib_testcase extends advanced_testcase {
         // Add a condition on a value existing...
         $ci->add_grade_condition($gradeitemid,null,null,true);
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_any','condition','frog').' ',array('class'=>'conditionalrule requires_grade')),$text);
+        $this->assertEquals(get_string('requires_grade_any','condition','frog'),$text);
 
         // Fake it existing
         $DB->insert_record('grade_grades',(object)array(
@@ -529,7 +529,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci->add_grade_condition($gradeitemid,3.78001,null,true);
         condition_info::wipe_session_cache();
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_min','condition','frog').' ',array('class'=>'conditionalrule requires_grade')),$text);
+        $this->assertEquals(get_string('requires_grade_min','condition','frog'),$text);
 
         // ...just on 3.78...
         $ci->wipe_conditions();
@@ -542,7 +542,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci->add_grade_condition($gradeitemid,null,3.78,true);
         condition_info::wipe_session_cache();
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_max','condition','frog').' ',array('class'=>'conditionalrule requires_grade')),$text);
+        $this->assertEquals(get_string('requires_grade_max','condition','frog'),$text);
 
         // ...less than 3.78001
         $ci->wipe_conditions();
@@ -561,7 +561,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci->add_grade_condition($gradeitemid,4,5,true);
         condition_info::wipe_session_cache();
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_range','condition','frog').' ',array('class'=>'conditionalrule requires_grade')),$text);
+        $this->assertEquals(get_string('requires_grade_range','condition','frog'),$text);
     }
 
     public function test_section_is_available() {
@@ -632,7 +632,7 @@ class conditionlib_testcase extends advanced_testcase {
 
         // Completion: Check
         $this->assertFalse($ci->is_available($text, false));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_completion_1', 'condition', 'xxx').' ',array('class'=>'conditionalrule requires_completion')), $text);
+        $this->assertEquals(get_string('requires_completion_1', 'condition', 'xxx'), $text);
         completion_info::wipe_session_cache();
         $completion = new completion_info($DB->get_record('course', array('id' => $courseid)));
         $completion->update_state($cm, COMPLETION_COMPLETE);
@@ -665,7 +665,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci->wipe_conditions();
         $ci->add_grade_condition($gradeitemid, null, null, true);
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_any', 'condition', 'frog').' ',array('class'=>'conditionalrule requires_grade')), $text);
+        $this->assertEquals(get_string('requires_grade_any', 'condition', 'frog'), $text);
 
         // Grade: Fake it existing
         $DB->insert_record('grade_grades', (object)array(
@@ -680,7 +680,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci->add_grade_condition($gradeitemid, 3.78001, null, true);
         condition_info_section::wipe_session_cache();
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_min', 'condition', 'frog').' ',array('class'=>'conditionalrule requires_grade')), $text);
+        $this->assertEquals(get_string('requires_grade_min', 'condition', 'frog'), $text);
 
         // Grade: ...just on 3.78...
         $ci->wipe_conditions();
@@ -693,7 +693,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci->add_grade_condition($gradeitemid, null, 3.78, true);
         condition_info_section::wipe_session_cache();
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_max', 'condition', 'frog').' ',array('class'=>'conditionalrule requires_grade')), $text);
+        $this->assertEquals(get_string('requires_grade_max', 'condition', 'frog'), $text);
 
         // Grade: ...less than 3.78001
         $ci->wipe_conditions();
@@ -712,7 +712,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci->add_grade_condition($gradeitemid, 4, 5, true);
         condition_info_section::wipe_session_cache();
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('requires_grade_range', 'condition', 'frog').' ',array('class'=>'conditionalrule requires_grade')), $text);
+        $this->assertEquals(get_string('requires_grade_range', 'condition', 'frog'), $text);
 
         // Grouping: Not member
         $groupingid = $this->make_grouping($courseid, 'Grouping');
@@ -721,7 +721,7 @@ class conditionlib_testcase extends advanced_testcase {
         $ci = new condition_info_section((object)array('id' => $sectionid),
                 CONDITION_MISSING_EVERYTHING);
         $this->assertFalse($ci->is_available($text));
-        $this->assertEquals(html_writer::tag('span',get_string('groupingnoaccess', 'condition'),array('class'=>'conditionalrule groupingnoaccess')), $text);
+        $this->assertEquals(trim(get_string('groupingnoaccess', 'condition')), $text);
 
         // Grouping: Member
         $this->assertTrue(groups_add_member($groupid, $USER->id));