Rudimentary course reset usage implemented
This commit is contained in:
parent
0d793fce8f
commit
83014fb9ac
1 changed files with 21 additions and 10 deletions
|
@ -1199,23 +1199,34 @@ class studyplanservice extends \external_api
|
|||
return success::structure();
|
||||
}
|
||||
public static function course_period_timing($page_id, $period, $course_id){
|
||||
$page = studyplanpage::findById($page_id);
|
||||
$course = \get_course($course_id);
|
||||
$coursecontext = \context_course::instance($course_id);
|
||||
$page = studyplanpage::findById($page_id);
|
||||
// Check for studyplan edit permissions
|
||||
webservicehelper::require_capabilities(self::CAP_EDIT,$page->studyplan()->context());
|
||||
|
||||
if(webservicehelper::has_capabilities("moodle/course:update",$coursecontext)){
|
||||
//TODO: Actually perform the timing changes, while also updating the module times
|
||||
// Like what happens on a course "reset"
|
||||
|
||||
$periods = period::findForPage($page);
|
||||
if(array_key_exists($period,$periods)){
|
||||
$pstart = $periods[$period];
|
||||
$pend = $periods[$period];
|
||||
|
||||
return success::success()->model();
|
||||
} else {
|
||||
// probably should return a nice message
|
||||
return success::fail("You do not have date change permissions on this course")->model();
|
||||
if(webservicehelper::has_capabilities("moodle/course:update",$coursecontext)){
|
||||
// Actually perform the timing changes, while also updating the module times
|
||||
// Like what happens on a course "reset"
|
||||
$status = reset_course_userdata([
|
||||
'id' => $course->id,
|
||||
'reset_start_date' => $pstart->startdate()->getTimestamp(),
|
||||
'reset_end_date' => $pend->enddate()->getTimestamp(),
|
||||
]);
|
||||
|
||||
// TODO: parse status
|
||||
|
||||
return success::success()->model();
|
||||
} else {
|
||||
// probably should return a nice message
|
||||
return success::fail("You do not have date change permissions on this course")->model();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue