19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../Base.php");
23 require_once(__DIR__ .
"/CommonFieldRendering.php");
45 $f = $this->getFieldFactory();
49 ->rating($label, $byline)
50 ->withNameFrom($this->name_source);
55 $f = $this->getFieldFactory();
56 $rating =
$f->rating(
"label",
"byline");
57 $this->assertInstanceOf(\
ILIAS\
UI\
Component\Input\Container\Form\FormInput::class, $rating);
58 $this->assertInstanceOf(Field\Rating::class, $rating);
64 $expected = $this->getFormWrappedHtml(
68 <fieldset class="input-group il-input-rating"> 69 <legend class="il-input-rating__text" id="id_1_desc"></legend> 70 <div class="il-input-rating__stars" role="radiogroup"> 71 <div class="il-input-rating__options"> 72 <input aria-describedby="id_1_desc" type="radio" id="id_1-5" name="name_0" value="5" class="il-input-rating-scaleoption" /> 73 <label class="glyphicon-star il-input-rating-star" for="id_1-5" aria-label="5stars"></label> 75 <input aria-describedby="id_1_desc" type="radio" id="id_1-4" name="name_0" value="4" class="il-input-rating-scaleoption" /> 76 <label class="glyphicon-star il-input-rating-star" for="id_1-4" aria-label="4stars"></label> 78 <input aria-describedby="id_1_desc" type="radio" id="id_1-3" name="name_0" value="3" class="il-input-rating-scaleoption" /> 79 <label class="glyphicon-star il-input-rating-star" for="id_1-3" aria-label="3stars"></label> 81 <input aria-describedby="id_1_desc" type="radio" id="id_1-2" name="name_0" value="2" class="il-input-rating-scaleoption" /> 82 <label class="glyphicon-star il-input-rating-star" for="id_1-2" aria-label="2stars"></label> 84 <input aria-describedby="id_1_desc" type="radio" id="id_1-1" name="name_0" value="1" class="il-input-rating-scaleoption" /> 85 <label class="glyphicon-star il-input-rating-star" for="id_1-1" aria-label="1stars"></label> 87 <div class="il-input-rating__none"> 88 <label for="id_1-0" aria-label="reset_stars">reset_stars</label> 89 <input aria-describedby="id_1_desc" type="radio" id="id_1-0" name="name_0" value="0" checked="checked"/> 97 $this->assertEquals($expected, $this->render($rating));
103 ->withAdditionalText(
'question text')
105 ->withValue(FiveStarRatingScale::GOOD)
106 ->withCurrentAverage(3);
108 $expected = $this->brutallyTrimHTML(
109 '<fieldset class="c-input" data-il-ui-component="rating-field-input" data-il-ui-input-name="name_0" disabled="disabled" tabindex="0"> 111 <div class="c-input__field"> 113 <fieldset class="input-group il-input-rating disabled"> 114 <legend class="il-input-rating__text" id="id_1_desc">question text</legend> 116 <div class="il-input-rating__stars" role="radiogroup"> 118 <div class="il-input-rating__options" title="rating_average"> 120 <div class="il-input-rating__average"> 121 <div class="il-input-rating__average_value" style="width:60%;"></div> 124 <input aria-describedby="id_1_desc" type="radio" id="id_1-5" name="name_0" value="5" class="il-input-rating-scaleoption" disabled="disabled"/> 125 <label class="glyphicon-star il-input-rating-star" for="id_1-5" aria-label="5stars"></label> 127 <input aria-describedby="id_1_desc" type="radio" id="id_1-4" name="name_0" value="4" class="il-input-rating-scaleoption" disabled="disabled" checked="checked"/> 128 <label class="glyphicon-star il-input-rating-star" for="id_1-4" aria-label="4stars"></label> 130 <input aria-describedby="id_1_desc" type="radio" id="id_1-3" name="name_0" value="3" class="il-input-rating-scaleoption" disabled="disabled"/> 131 <label class="glyphicon-star il-input-rating-star" for="id_1-3" aria-label="3stars"></label> 133 <input aria-describedby="id_1_desc" type="radio" id="id_1-2" name="name_0" value="2" class="il-input-rating-scaleoption" disabled="disabled"/> 134 <label class="glyphicon-star il-input-rating-star" for="id_1-2" aria-label="2stars"></label> 136 <input aria-describedby="id_1_desc" type="radio" id="id_1-1" name="name_0" value="1" class="il-input-rating-scaleoption" disabled="disabled"/> 137 <label class="glyphicon-star il-input-rating-star" for="id_1-1" aria-label="1stars"></label> 140 <div class="il-input-rating__none"> 141 <label for="id_1-0" aria-label="reset_stars">reset_stars</label> 142 <input aria-describedby="id_1_desc" type="radio" id="id_1-0" name="name_0" value="0" /> 149 <div class="c-input__help-byline">byline</div> 153 $this->assertEquals($expected, $this->render($rating));
158 $f = $this->getFieldFactory();
159 $rating =
$f->rating(
"label",
null)->withNameFrom($this->name_source);
161 $this->testWithError($rating);
162 $this->testWithNoByline($rating);
163 $this->testWithRequired($rating);
164 $this->testWithDisabled($rating);
165 $this->testWithAdditionalOnloadCodeRendersId($rating);
171 $this->assertNull($rating->getCurrentAverage());
172 $this->assertEquals(2.1, $rating->withCurrentAverage(2.1)->getCurrentAverage());
177 $this->expectException(\InvalidArgumentException::class);
178 $rating = $this->
buildRating()->withCurrentAverage(7);
FiveStarRatingScale
This is the scale for the Rating Input.
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...