Rudimentary course reset usage implemented
This commit is contained in:
parent
0d793fce8f
commit
83014fb9ac
|
@ -1199,23 +1199,34 @@ class studyplanservice extends \external_api
|
||||||
return success::structure();
|
return success::structure();
|
||||||
}
|
}
|
||||||
public static function course_period_timing($page_id, $period, $course_id){
|
public static function course_period_timing($page_id, $period, $course_id){
|
||||||
$page = studyplanpage::findById($page_id);
|
|
||||||
$course = \get_course($course_id);
|
$course = \get_course($course_id);
|
||||||
$coursecontext = \context_course::instance($course_id);
|
$coursecontext = \context_course::instance($course_id);
|
||||||
|
$page = studyplanpage::findById($page_id);
|
||||||
// Check for studyplan edit permissions
|
// Check for studyplan edit permissions
|
||||||
webservicehelper::require_capabilities(self::CAP_EDIT,$page->studyplan()->context());
|
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();
|
if(webservicehelper::has_capabilities("moodle/course:update",$coursecontext)){
|
||||||
} else {
|
// Actually perform the timing changes, while also updating the module times
|
||||||
// probably should return a nice message
|
// Like what happens on a course "reset"
|
||||||
return success::fail("You do not have date change permissions on this course")->model();
|
$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 New Issue
Block a user