$sql="select mcm.id,mm.name,mcm.instance from mdl_course_modules mcm join mdl_modules mm on mm.id=mcm.module where mcm.course=$course";
$sql="select mcm.id,mm.name,mcm.instance from mdl_course_modules mcm join mdl_modules mm on mm.id=mcm.module where mcm.course=$course and mcm.visible=1 and mcm.deletioninprogress=0";
$qresult=$DB->get_records_sql($sql);
$allcmids=array();
foreach($qresultas$value){
$allcmids[]=$value->id;
$allcmids[]=$value->id;
}
if($mandatoryids&&$checkedids){
...
...
@@ -92,6 +92,7 @@ switch ($action) {
if(in_array($id,$previousestatus)){
//
}else{
if(isset($qresult[$id])){
$id=number_format($id);
$modaname=$qresult[$id]->name;
$instance=$qresult[$id]->instance;
...
...
@@ -101,24 +102,26 @@ switch ($action) {
$newlyaddedactivities[]=$aname;
$newlyaddedids[]=$id;
}
}
}
//iterate to get removed id's
foreach($previousestatusas$id){
if(in_array($id,$checkedids)){
foreach($previousestatusas$id1){
if(in_array($id1,$checkedids)){
//
}else{
$id=number_format($id);
$modaname=$qresult[$id]->name;
$instance=$qresult[$id]->instance;
if(isset($qresult[$id1])){
$id=number_format($id1);
$modaname=$qresult[$id1]->name;
$instance=$qresult[$id1]->instance;
$sqlactivityname="select name from mdl_$modaname where id=$instance";
$sqlactivities="select mv.*,mcm.id as cmid,mcm.availability as randomized from $tablenme mv join mdl_course_modules mcm on mcm.instance=mv.id where
mv.course=$courseid and mcm.module=(select id from mdl_modules mm where name ='$mod->name') order by mv.id asc";
mv.course=$courseid and mcm.visible=1 and mcm.deletioninprogress=0 and mcm.module=(select id from mdl_modules mm where name ='$mod->name') order by mv.id asc";
get_string('mandatorystring','local_mandatoryactivities'),get_string('mandatorystringdesc','local_mandatoryactivities')," This is a high value activity ",PARAM_TEXT));
$sql="insert into mdl_local_mandatory_activities(course,cmid, mandatory)
(select course, string_agg(id::text,',') as cmid ,1 from mdl_course_modules where id in (select activity_id from mdl_block_lp_track_week_schedule mbltws where module_type='Activity')