Return an appropriate icon (green tick, red cross, etc.) for a grade.
@param float $fraction grade on a scale 0..1.
@param bool $selected whether to show a big or small icon. (Deprecated)
@return string html fragment.
4160
protected function feedback_image($fraction, $selected = true) {
        $feedbackclass = question_state::graded_state_for_fraction($fraction)->get_feedback_class();

        return $this->output->pix_icon('i/grade_' . $feedbackclass, get_string($feedbackclass, 'question'));
    }
497772
function(select, option, type) {
        // Add disabled attr if disabled
        var disabledClass = (option.is(':disabled')) ? 'disabled ' : '';
        var optgroupClass = (type === 'optgroup-option') ? 'optgroup-option ' : '';
        var multipleCheckbox = multiple ? '<input type="checkbox"' + disabledClass + '/><label></label>' : '';

        // add icons
        var icon_url = option.data('icon');
        var classes = option.attr('class');
        if (!!icon_url) {
          var classString = '';
          if (!!classes) classString = ' class="' + classes + '"';

          // Check for multiple type.
          options.append($('<li class="' + disabledClass + optgroupClass + '"><img alt="" src="' + icon_url + '"' + classString + '><span>' + multipleCheckbox + option.html() + '</span></li>'));
          return true;
        }

        // Check for multiple type.
        options.append($('<li class="' + disabledClass + optgroupClass + '"><span>' + multipleCheckbox + option.html() + '</span></li>'));
      }
544255
protected function get_course_header($element) {
        global $OUTPUT;

        $icon = '';
        // If object is a category, display expand/contract icon.
        if ($element['type'] == 'category') {
            // Load language strings.
            $strswitchminus = $this->get_lang_string('aggregatesonly', 'grades');
            $strswitchplus  = $this->get_lang_string('gradesonly', 'grades');
            $strswitchwhole = $this->get_lang_string('fullmode', 'grades');

            $url = new moodle_url($this->gpr->get_return_url(null, array('target' => $element['eid'], 'sesskey' => sesskey())));

            if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) {
                $url->param('action', 'switch_plus');
                $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_plus', $strswitchplus), null, null);
                $showing = get_string('showingaggregatesonly', 'grades');
            } else if (in_array($element['object']->id, $this->collapsed['gradesonly'])) {
                $url->param('action', 'switch_whole');
                $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_whole', $strswitchwhole), null, null);
                $showing = get_string('showinggradesonly', 'grades');
            } else {
                $url->param('action', 'switch_minus');
                $icon = $OUTPUT->action_icon($url, new pix_icon('t/switch_minus', $strswitchminus), null, null);
                $showing = get_string('showingfullmode', 'grades');
            }
        }

        $name = $element['object']->get_name();
        $courseheaderid = 'courseheader_' . clean_param($name, PARAM_ALPHANUMEXT);
        $courseheader = html_writer::tag('span', $name, array('id' => $courseheaderid,
                'title' => $name, 'class' => 'gradeitemheader'));
        $courseheader .= html_writer::label($showing, $courseheaderid, false, array('class' => 'accesshide'));
        $courseheader .= $icon;

        return $courseheader;
    }
303817
protected function renderDegreeOptionsLine(string $selected, int $pad): string
    {
        return (! isset($selected) || $selected === "" || $selected === "-")
            ? sprintf('<option value="%s" selected="selected">%s</option>%s%s', '-', '&mdash;', "\n", $this->getSpaces($pad))
            : sprintf('<option value="%s">%s</option>%s%s', '-', '&mdash;', "\n", $this->getSpaces($pad));
    }
672626
public function renderSubmit(Submit $select)
	{
		$attributes = $select->getAttributes();

		if ( ! isset($attributes['class']))
		{
			$attributes['class'] = '';
		}

		$attributes['class'] .= ' btn btn-default';

		return Html::tag('button', $attributes, $select->getValue());
	}
739236
public function determine_format() {
        if ($this->grade->grade_item->load_scale()) {
            $scale = $this->grade->grade_item->load_scale();

            $options = array(-1 => get_string('nograde'));

            foreach ($scale->scale_items as $i => $name) {
                $options[$i + 1] = $name;
            }

            return new dropdown_attribute(
                $this->get_name(),
                $options,
                $this->get_label(),
                $this->get_value(),
                $this->is_disabled()
            );
        } else {
            return new text_attribute(
                $this->get_name(),
                $this->get_value(),
                $this->get_label(),
                $this->is_disabled()
            );
        }
    }
728427
public function getIcon()
    {
        $data = ArrayData::create([]);

        $iconClass = $this->config()->get('icon');
        if ($iconClass) {
            $data->IconClass = $iconClass;

            // Add versioned states (rendered as a circle over the icon)
            if ($this->hasExtension(Versioned::class)) {
                $data->IsVersioned = true;
                if ($this->isOnDraftOnly()) {
                    $data->VersionState = 'draft';
                    $data->VersionStateTitle = _t(
                        'SilverStripe\\Versioned\\VersionedGridFieldState\\VersionedGridFieldState.ADDEDTODRAFTHELP',
                        'Item has not been published yet'
                    );
                } elseif ($this->isModifiedOnDraft()) {
                    $data->VersionState = 'modified';
                    $data->VersionStateTitle = $data->VersionStateTitle = _t(
                        'SilverStripe\\Versioned\\VersionedGridFieldState\\VersionedGridFieldState.MODIFIEDONDRAFTHELP',
                        'Item has unpublished changes'
                    );
                }
            }

            return $data->renderWith(__CLASS__ . '/PreviewIcon');
        }

        return null;
    }
853203
public function getIconString($icon, $class = '', $width = '', $height = '')
    {
        $string = $this->loadFile(__DIR__.'/../../resources/assets/icons/'.$icon.'.svg');
        $string = substr_replace($string, ' class="'.$class.'"', 4, 0);

        if ($width) {
            $string = substr_replace($string, 'width="'.$width.'"', strpos($string, 'width='), 10);
            $string = substr_replace($string, 'height="'.$height.'"', strpos($string, 'height='), 11);
        }

        return $string;
    }
280635
public function getAwesomeIconCSS()
    {
        // Initialise Variables:
        
        $css = array();
        
        // Obtain Default ModelAdmin Icon:
        
        $dma_icon = Config::inst()->get('ModelAdmin', 'menu_icon', Config::FIRST_SET);
        
        // Obtain Viewable Menu Items:
        
        $menu_items = CMSMenu::get_viewable_menu_items();
        
        // Iterate Viewable Menu Items:
        
        foreach ($menu_items as $class => $item) {
            
            // Obtain Bitmap Icon:
            
            $bmp_icon = Config::inst()->get($class, 'menu_icon', Config::FIRST_SET);
            
            // Does this class have an awesome icon?
            
            if ($icon = Config::inst()->get($class, 'awesome_icon', Config::FIRST_SET)) {
                
                // Fix the prefix of the icon class name:
                
                $icon = $this->prefix($icon);
                
            } elseif ($class == 'Help') {
                
                // The icon for the Help menu item:
                
                $icon = 'fa-question-circle';
                
            } elseif ($bmp_icon == $dma_icon) {
                
                // Replace default ModelAdmin icon:
                
                $icon = 'fa-database';
                
            } else {
                
                // By default, fallback to the bitmap icon:
                
                $icon = false;
                
            }
            
            // Define CSS for this icon:
            
            if ($icon) {
                
                // Disable Bitmap Icon:
                
                $css[] = ".icon.icon-16.icon-" . strtolower($class) . " {";
                $css[] = "  background-image: none !important;";
                $css[] = "}";
                
                // Enable Awesome Icon:
                
                $css[] = ".icon.icon-16.icon-" . strtolower($class) . ":before {";
                $css[] = "  content: \"\\" . $this->getIconUnicode($icon) . "\";";
                $css[] = "}";
                
            }
        }
        
        // Answer CSS String:
        
        return implode("\n", $css);
    }
872475
public function get_emoticons($selectable = false) {
        global $CFG;
        $notselectable = ['martin', 'egg'];

        if (empty($CFG->emoticons)) {
            return array();
        }

        $emoticons = $this->decode_stored_config($CFG->emoticons);

        if (!is_array($emoticons)) {
            // Something is wrong with the format of stored setting.
            debugging('Invalid format of emoticons setting, please resave the emoticons settings form', DEBUG_NORMAL);
            return array();
        }
        if ($selectable) {
            foreach ($emoticons as $index => $emote) {
                if (in_array($emote->altidentifier, $notselectable)) {
                    // Skip this one.
                    unset($emoticons[$index]);
                }
            }
        }

        return $emoticons;
    }
1322311
private function getCssSelectorPrecedence($selector)
    {
        $selectorKey = \md5($selector);
        if (!isset($this->caches[static::CACHE_KEY_SELECTOR][$selectorKey])) {
            $precedence = 0;
            foreach ($this->selectorPrecedenceMatchers as $matcher => $value) {
                if (\trim($selector) === '') {
                    break;
                }
                $number = 0;
                $selector = \preg_replace('/' . $matcher . '\\w+/', '', $selector, -1, $number);
                $precedence += ($value * $number);
            }
            $this->caches[static::CACHE_KEY_SELECTOR][$selectorKey] = $precedence;
        }

        return $this->caches[static::CACHE_KEY_SELECTOR][$selectorKey];
    }
224332
private static function selectIcon($sortColumn)
    {
        $icon = config('columnsortable.default_icon_set');

        foreach (config('columnsortable.columns', []) as $value) {
            if (in_array($sortColumn, $value['rows'])) {
                $icon = $value['class'];
            }
        }

        return $icon;
    }
817582
public function pick_action_icon(moodle_url $url, $text, $icon = '', $class = '') {

        $img = $this->output->pix_icon($icon, '');
        $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
        return html_writer::link($url, $img . $txt, array('class' => 'action '.$class));
    }
696852
public function toOptions($selected=0, $id_as_label=false)
    {
        if (count($this->unique) != 1) {
            return '';
        }
        $id_col = $this->unique[0];
        if ($id_as_label) {
            $label_col = $id_col;
        } else {
            // use first non-ID column for the label
            $label_col = array_keys($this->columns);
            foreach ($label_col as $col) {
                if ($col != $id_col) {
                    $label_col = $col;
                    break;
                }
            }
        }
        $ret = array_reduce($this->find($label_col), 
            function ($ret, $obj) use ($selected, $id_col, $label_col) {
                return $ret . sprintf('<option %s value="%d">%s</option>',
                        $selected == $obj->$id_col() ? 'selected' : '',
                        $obj->$id_col(),
                        $obj->$label_col()
                );
            }, 
            ''
        );

        return $ret;
    }
206815
protected function get_sort_icon($reverse) {
        global $OUTPUT;
        if ($reverse) {
            return $OUTPUT->pix_icon('t/sort_desc', get_string('desc'), '', array('class' => 'iconsort'));
        } else {
            return $OUTPUT->pix_icon('t/sort_asc', get_string('asc'), '', array('class' => 'iconsort'));
        }
    }
339823
public function sorter()
    {
        if (!$this->sortable) {
            return '';
        }

        $icon = 'fa-sort';
        $type = 'desc';

        if ($this->isSorted()) {
            $type = $this->sort['type'] == 'desc' ? 'asc' : 'desc';
            $icon .= "-amount-{$this->sort['type']}";
        }

        // set sort value
        $sort = ['column' => $this->name, 'type' => $type];
        if (isset($this->cast)) {
            $sort['cast'] = $this->cast;
        }

        $query = app('request')->all();
        $query = array_merge($query, [$this->grid->model()->getSortName() => $sort]);

        $url = url()->current().'?'.http_build_query($query);

        return "<a class=\"fa fa-fw $icon\" href=\"$url\"></a>";
    }
416132
public function determine_format() {
        if (!$this->grade->grade_item->is_overridable_item()) {
            return new empty_element();
        }
        return new checkbox_attribute(
            $this->get_name(),
            $this->get_label(),
            $this->is_checked(),
            $this->is_disabled()
        );
    }