Skip to content

Commit

Permalink
check how the module info looks
Browse files Browse the repository at this point in the history
  • Loading branch information
roblesjoel committed Jun 8, 2022
1 parent c95dbca commit a0443bb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
9 changes: 8 additions & 1 deletion db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
'classpath' => 'local/rsync/section.php',
'description' => 'Allows you to hide and unhide sections',
'type' => 'write',
),
'local_rsync_remove_file_from_section' => array(
'classname' => 'local_rsync_section',
'methodname' => 'remove_file_from_section',
'classpath' => 'local/rsync/section.php',
'description' => 'Allows you to remove a file from a section',
'type' => 'write',
)
);

// We define the services to install as pre-build services. A pre-build service is not editable by administrator.
$services = array(
'rsync fucntionalities' => array(
'functions' => array ('local_rsync_create_file_resource', 'local_rsync_set_section_visibility'),
'functions' => array ('local_rsync_create_file_resource', 'local_rsync_set_section_visibility', 'local_rsync_remove_file_from_section'),
'restrictedusers' => 0,
'enabled' => 1,
)
Expand Down
32 changes: 30 additions & 2 deletions section.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot. '/course/lib.php'); // contains section visibility
require_once($CFG->dirroot. '/course/lib.php'); // contains section visibility, section info

/**
* Class local_rsync_section
Expand All @@ -45,7 +45,7 @@ public static function set_section_visibilty_parameters(){
}

/**
* Lets the user set the visi
* Lets the user set the visibilty of a section
*
* @param int $courseid course id
* @param int $sectionnumber section number
Expand Down Expand Up @@ -92,11 +92,39 @@ public static function set_section_visibilty($courseid, $sectionnumber, $visibil

return get_string('successmessage_section_visibility', 'local_rsync', array('visibility' => $visibility_long, 'sectionnumber' => $sectionnumber, 'courseid' => $courseid, 'username' => fullname($USER)));
}


/**
* Lets the user remove a file from a section
*
* @param int $courseud course id
* @param int $sectionnumber section number
*/
public static function remove_file_from_section($courseid, $sectionnumber){
$modules = get_array_of_activities($courseid);

foreach($modules as $module){
if($module->section == $sectionnumber){
break;
}
}

return implode(';', $modules);
}

/**
* Returns description of method result value
* @return external_description
*/
public static function set_section_visibilty_returns() {
return new external_value(PARAM_TEXT, 'Section number, course id and username');
}

/**
* Returns description of method result value
* @return external_description
*/
public static function remove_file_from_section_returns() {
return new external_value(PARAM_TEXT, 'File name, section number, course id and username');
}
}

0 comments on commit a0443bb

Please sign in to comment.