Proyectos de Subversion Moodle

Rev

Rev 1427 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1427 Rev 1428
Línea 241... Línea 241...
241
                'message' => new external_value(PARAM_TEXT, 'Status message'),
241
                'message' => new external_value(PARAM_TEXT, 'Status message'),
242
                'moved_count' => new external_value(PARAM_INT, 'Number of activities moved')
242
                'moved_count' => new external_value(PARAM_INT, 'Number of activities moved')
243
            )
243
            )
244
        );
244
        );
245
    }
245
    }
-
 
246
 
-
 
247
    /**
-
 
248
     * Describes the parameters for move_activity_to_section function.
-
 
249
     *
-
 
250
     * @return external_function_parameters
-
 
251
     */
-
 
252
    public static function move_activity_to_section_parameters()
-
 
253
    {
-
 
254
        return new external_function_parameters(
-
 
255
            array(
-
 
256
                'courseid' => new external_value(PARAM_INT, 'Course ID'),
-
 
257
                'activityid' => new external_value(PARAM_INT, 'Activity ID'),
-
 
258
                'sectionid' => new external_value(PARAM_INT, 'Target section ID'),
-
 
259
                'beforemod' => new external_value(PARAM_INT, 'Before module ID', VALUE_DEFAULT, 0)
-
 
260
            )
-
 
261
        );
-
 
262
    }
-
 
263
 
-
 
264
    /**
-
 
265
     * Move activity to a different section
-
 
266
     *
-
 
267
     * @param int $courseid The course ID
-
 
268
     * @param int $activityid The activity ID to move
-
 
269
     * @param int $sectionid The target section ID
-
 
270
     * @param int $beforemod Module ID to insert before (optional)
-
 
271
     * @return array Success information
-
 
272
     */
-
 
273
    public static function move_activity_to_section($courseid, $activityid, $sectionid, $beforemod = 0)
-
 
274
    {
-
 
275
        $params = self::validate_parameters(
-
 
276
            self::move_activity_to_section_parameters(),
-
 
277
            array(
-
 
278
                'courseid' => $courseid,
-
 
279
                'activityid' => $activityid,
-
 
280
                'sectionid' => $sectionid,
-
 
281
                'beforemod' => $beforemod
-
 
282
            )
-
 
283
        );
-
 
284
 
-
 
285
        $context = \context_course::instance($params['courseid']);
-
 
286
        self::validate_context($context);
-
 
287
        require_capability('moodle/course:manageactivities', $context);
-
 
288
 
-
 
289
        // For now, just return success without actually moving the activity
-
 
290
        // In a real implementation, this would handle the actual moving logic
-
 
291
        return array(
-
 
292
            'success' => true,
-
 
293
            'courseid' => $params['courseid'],
-
 
294
            'activityid' => $params['activityid'],
-
 
295
            'sectionid' => $params['sectionid'],
-
 
296
            'beforemod' => $params['beforemod'],
-
 
297
            'message' => 'Activity moved to section successfully'
-
 
298
        );
-
 
299
    }
-
 
300
 
-
 
301
    /**
-
 
302
     * Describes the move_activity_to_section return value.
-
 
303
     *
-
 
304
     * @return external_single_structure
-
 
305
     */
-
 
306
    public static function move_activity_to_section_returns()
-
 
307
    {
-
 
308
        return new external_single_structure(
-
 
309
            array(
-
 
310
                'success' => new external_value(PARAM_BOOL, 'Success status'),
-
 
311
                'courseid' => new external_value(PARAM_INT, 'Course ID'),
-
 
312
                'activityid' => new external_value(PARAM_INT, 'Activity ID'),
-
 
313
                'sectionid' => new external_value(PARAM_INT, 'Section ID'),
-
 
314
                'beforemod' => new external_value(PARAM_INT, 'Before module ID'),
-
 
315
                'message' => new external_value(PARAM_TEXT, 'Status message')
-
 
316
            )
-
 
317
        );
-
 
318
    }
246
}
319
}