public static function add_legacy_availability_condition($availability, $rec, $show) {
        if (!empty($rec->sourcecmid)) {
            // Completion condition.
            $condition = '{"type":"completion","cm":' . $rec->sourcecmid .
                    ',"e":' . $rec->requiredcompletion . '}';
        } else {
            // Grade condition.
            $minmax = '';
            if (!empty($rec->grademin)) {
                $minmax .= ',"min":' . sprintf('%.5f', $rec->grademin);
            }
            if (!empty($rec->grademax)) {
                $minmax .= ',"max":' . sprintf('%.5f', $rec->grademax);
            }
            $condition = '{"type":"grade","id":' . $rec->gradeitemid . $minmax . '}';
        }

        return self::add_legacy_condition($availability, $condition, $show);
    }
public static function add_legacy_availability_condition($availability, $rec, $show) {
        if (!empty($rec->sourcecmid)) {
            // Completion condition.
            $condition = '{"type":"completion","cm":' . $rec->sourcecmid .
                    ',"e":' . $rec->requiredcompletion . '}';
        } else {
            // Grade condition.
            $minmax = '';
            if (!empty($rec->grademin)) {
                $minmax .= ',"min":' . sprintf('%.5f', $rec->grademin);
            }
            if (!empty($rec->grademax)) {
                $minmax .= ',"max":' . sprintf('%.5f', $rec->grademax);
            }
            $condition = '{"type":"grade","id":' . $rec->gradeitemid . $minmax . '}';
        }

        return self::add_legacy_condition($availability, $condition, $show);
    }
public static function add_legacy_availability_condition ( $ availability , $ rec , $ show ) { if ( ! empty ( $ rec -> sourcecmid ) ) { // Completion condition. $ condition = '{"type":"completion","cm":' . $ rec -> sourcecmid . ',"e":' . $ rec -> requiredcompletion . '}' ; } else { // Grade condition. $ minmax = '' ; if ( ! empty ( $ rec -> grademin ) ) { $ minmax .= ',"min":' . sprintf ( '%.5f' , $ rec -> grademin ) ; } if ( ! empty ( $ rec -> grademax ) ) { $ minmax .= ',"max":' . sprintf ( '%.5f' , $ rec -> grademax ) ; } $ condition = '{"type":"grade","id":' . $ rec -> gradeitemid . $ minmax . '}' ; } return self :: add_legacy_condition ( $ availability , $ condition , $ show ) ; }
Adds a condition from the legacy availability condition.

(For use during restore only.)

This function assumes that the activity either has no conditions, or
that it has an AND tree with one or more conditions.

@param string|null $availability Current availability conditions
@param \stdClass $rec Object containing information from old table
@param bool $show True if 'show' option should be enabled
@return string New availability conditions
Adds a condition from the legacy availability condition .