Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 14... Línea 14...
14
// You should have received a copy of the GNU General Public License
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/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea -... Línea 17...
-
 
17
namespace core_courseformat\external;
17
namespace core_courseformat\external;
18
 
18
 
19
use core\exception\moodle_exception;
19
use core_external\external_api;
20
use core_external\external_api;
20
use core_external\external_function_parameters;
21
use core_external\external_function_parameters;
21
use core_external\external_multiple_structure;
-
 
22
use core_external\external_value;
-
 
23
use moodle_exception;
22
use core_external\external_multiple_structure;
24
use coding_exception;
23
use core_external\external_value;
Línea 25... Línea 24...
25
use context_course;
24
use context_course;
26
use core_courseformat\base as course_format;
25
use core_courseformat\base as course_format;
Línea 104... Línea 103...
104
        $targetsectionid = $params['targetsectionid'];
103
        $targetsectionid = $params['targetsectionid'];
105
        $targetcmid = $params['targetcmid'];
104
        $targetcmid = $params['targetcmid'];
Línea 106... Línea 105...
106
 
105
 
Línea 107... Línea 106...
107
        self::validate_context(context_course::instance($courseid));
106
        self::validate_context(context_course::instance($courseid));
Línea 108... Línea -...
108
 
-
 
109
        $courseformat = course_get_format($courseid);
-
 
110
 
-
 
111
        // Create a course changes tracker object.
-
 
112
        $defaultupdatesclass = 'core_courseformat\\stateupdates';
-
 
113
        $updatesclass = 'format_' . $courseformat->get_format() . '\\courseformat\\stateupdates';
-
 
114
        if (!class_exists($updatesclass)) {
107
 
115
            $updatesclass = $defaultupdatesclass;
-
 
116
        }
-
 
117
        $updates = new $updatesclass($courseformat);
-
 
118
 
-
 
119
        if (!is_a($updates, $defaultupdatesclass)) {
-
 
120
            throw new coding_exception("The \"$updatesclass\" class must extend \"$defaultupdatesclass\"");
-
 
121
        }
-
 
122
 
-
 
123
        // Get the actions class from the course format.
-
 
124
        $actionsclass = 'format_'. $courseformat->get_format().'\\courseformat\\stateactions';
-
 
125
        if (!class_exists($actionsclass)) {
108
        $format = course_get_format($courseid);
Línea 126... Línea 109...
126
            $actionsclass = 'core_courseformat\\stateactions';
109
 
127
        }
110
        $updates = $format->get_stateupdates_instance();
128
        $actions = new $actionsclass();
111
        $actions = $format->get_stateactions_instance();
Línea 129... Línea 112...
129
 
112
 
Línea 130... Línea 113...
130
        if (!is_callable([$actions, $action])) {
113
        if (!is_callable([$actions, $action])) {
131
            throw new moodle_exception("Invalid course state action $action in ".get_class($actions));
114
            throw new moodle_exception("Invalid course state action $action in ".get_class($actions));
Línea 132... Línea 115...
132
        }
115
        }
-
 
116
 
-
 
117
        $course = $format->get_course();
-
 
118
 
133
 
119
        // Execute the action.
Línea 134... Línea 120...
134
        $course = $courseformat->get_course();
120
        $actions->$action($updates, $course, $ids, $targetsectionid, $targetcmid);
135
 
121
 
Línea 136... Línea 122...
136
        // Execute the action.
122
        // Dispatch the hook for post course content update.