public static function get_proficiency_of_grade_from_scale_configuration($config, $grade) {
        $config = json_decode($config);
        if (!is_array($config)) {
            throw new coding_exception('Unexpected scale configuration.');
        }

        // Remove the scale ID from the config.
        array_shift($config);

        foreach ($config as $part) {
            if ($part->id == $grade) {
                return (int) $part->proficient;
            }
        }

        return 0;
    }