• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ewallah / moodle-availability_language / 6064224035

03 Sep 2023 11:36AM UTC coverage: 2.128% (-97.9%) from 100.0%
6064224035

push

github

ewallah
is available for all

14 of 14 new or added lines in 1 file covered. (100.0%)

1 of 47 relevant lines covered (2.13%)

0.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/classes/frontend.php
1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16

17
/**
18
 * Front-end class.
19
 *
20
 * @package   availability_language
21
 * @copyright 2022 eWallah.net
22
 * @author    Renaat Debleu <info@eWallah.net>
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25

26
namespace availability_language;
27

28
/**
29
 * Front-end class.
30
 *
31
 * @package   availability_language
32
 * @copyright 2022 eWallah.net
33
 * @author    Renaat Debleu <info@eWallah.net>
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
36
class frontend extends \core_availability\frontend {
37

38
    /**
39
     * Additional parameters for the plugin's initInner function.
40
     *
41
     * Returns an array of array of id, name of languages.
42
     *
43
     * @param stdClass $course Course object
44
     * @param cm_info $cm Course-module currently being edited (null if none)
45
     * @param section_info $section Section currently being edited (null if none)
46
     * @return array Array of parameters for the JavaScript function
47
     */
48
    protected function get_javascript_init_params($course, \cm_info $cm = null, \section_info $section = null) {
49
        return [self::convert_associative_array_for_js(get_string_manager()->get_list_of_translations(false), 'id', 'name')];
×
50
    }
51

52
    /**
53
     * Language condition should be available if
54
     *     the course language is not forced, or
55
     *     the module language is not forced, or
56
     *     more than language is installed.
57
     *
58
     * @param stdClass $course Course object
59
     * @param cm_info $cm Course-module currently being edited (null if none)
60
     * @param section_info $section Section currently being edited (null if none)
61
     * @return bool True if available
62
     */
63
    protected function allow_add($course, \cm_info $cm = null, \section_info $section = null) {
64
        // If forced course language.
65
        if ($course->lang != '') {
×
66
            return false;
×
67
        }
68
        // If there is only one language installed.
69
        return count(get_string_manager()->get_list_of_translations(false)) > 1;
×
70
    }
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc