d5d122f0 by logesh

added condition for empty ids.

1 parent a7ec8fdb
......@@ -49,7 +49,12 @@ switch ($action) {
$instance->cmid = $madatorycmids;
$instance->mandatory = $mandatoryactivities->mandatory;
$DB->update_record('local_mandatory_activities', $instance);
if (!empty($madatorycmids)){
$DB->update_record('local_mandatory_activities', $instance);
}else{
$sql="delete from mdl_local_mandatory_activities where course=$course";
$DB->execute($sql);
}
}else{
......@@ -84,7 +89,7 @@ switch ($action) {
$allcmids[]=$value->id;
}
if ($mandatoryids && $checkedids){
if ($mandatoryids || $checkedids){
$previousestatus=explode(",",$mandatoryids);
foreach($checkedids as $id){
......@@ -140,7 +145,41 @@ switch ($action) {
$unchangedactivities[]=$aname;
}
}
}else{
}else if ($checkedids) {
foreach($checkedids as $id){
if (isset($qresult[$id])){
$id=number_format($id);
$modaname=$qresult[$id]->name;
$instance=$qresult[$id]->instance;
$sqlactivityname="select name from mdl_$modaname where id=$instance";
$aname=$DB->get_record_sql($sqlactivityname);
$newlyaddedactivities[]=$aname;
$newlyaddedids[]=$id;
}
}
$res=array_diff($allcmids,$newlyaddedids);
$unchangedids=array_diff($res,$removedids);
foreach ($unchangedids as $data){
if (isset($qresult[$data])){
$id=number_format($data);
$modaname=$qresult[$data]->name;
$instance=$qresult[$data]->instance;
$sqlactivityname="select name from mdl_$modaname where id=$instance";
$aname=$DB->get_record_sql($sqlactivityname);
$unchangedactivities[]=$aname;
}
}
}
else{
foreach ($qresult as $val){
$modaname=$val->name;
......
......@@ -128,14 +128,19 @@ th,td{
$(document).on('click', '#savemandatory', function(){
$('#madatorysection').css("display", "none");
$('#loadingcomparision').css("display", "block");
var checkedids=[];
$('input:checkbox.checkboxesavilable:checked').each(function () {
checkedids.push($(this).attr("data-cmid"));
});
// if(checkedids.length > 0){
$('#madatorysection').css("display", "none");
$('#loadingcomparision').css("display", "block");
var rootPath = M.cfg.wwwroot;
var arg = { action:'getcomparision',
......@@ -220,6 +225,12 @@ th,td{
}
});
// }else{
// alert("Please do select atleast one activity to proceed");
// }
// $('#accordion1').css("display", "none");
......@@ -267,7 +278,7 @@ th,td{
$('#loadingcomparision').css("display", "none");
var alerttags='<div class="alert alert-success"><strong>Successfully Ssved</strong></div>';
var alerttags='<div class="alert alert-success"><strong>Successfully Saved</strong></div>';
$('#successalert').append(alerttags);
setTimeout(function(){
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!