a7ec8fdb by logesh

update script and ui bugs fixed

1 parent 0c218c34
......@@ -76,12 +76,12 @@ switch ($action) {
$unchangedids=array();
$unchangedactivities=array();
$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 ($qresult as $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($previousestatus as $id){
if (in_array($id, $checkedids)){
foreach($previousestatus as $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";
$aname=$DB->get_record_sql($sqlactivityname);
$removedactivities[]=$aname;
$removedids[]=$id;
}
}
}
......@@ -126,6 +129,7 @@ switch ($action) {
$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;
......@@ -134,6 +138,7 @@ switch ($action) {
$aname=$DB->get_record_sql($sqlactivityname);
$unchangedactivities[]=$aname;
}
}
}else{
......
......@@ -47,10 +47,13 @@ foreach ($modules as $mod){
$tablenme='mdl_'.$mod->name;
$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";
$allactivities=$DB->get_records_sql($sqlactivities);
$span=count($allactivities);
if (!empty($span)){
$tabledata .="<tr class='modname' data-modname='$mod->name' id='modname'><td rowspan='$span'>$mod->name</td>";
foreach ($allactivities as $activity){
......@@ -95,6 +98,7 @@ foreach ($modules as $mod){
}
$tabledata .="</tr>";
}
}
$sql="select cmid from {local_mandatory_activities} where course=?";
......
......@@ -29,3 +29,6 @@ $string['type'] = 'mandatoryactivity status';
$string['headerconfig'] = 'Local Plugin Setting';
$string['descconfig'] = 'Configuration setting of Local mandatory activity plugin';
$string['mandatorystring'] = 'Enter the mandatory title string';
$string['mandatorystringdesc'] = 'Enter the string to display for mandatory activities.';
\ No newline at end of file
......
......@@ -27,4 +27,16 @@ $prefix = 'local_mandatoryactivities/';
if ($hassiteconfig) {
$settings = new admin_settingpage('local_mandatoryactivities', get_string('pluginname', 'local_mandatoryactivities'));
$ADMIN->add('localplugins', $settings);
$settings->add(new admin_setting_heading('headerconfig',get_string('headerconfig', 'local_mandatoryactivities'),get_string('descconfig', 'local_mandatoryactivities')));
$settings->add(new admin_setting_configtext('local_mandatory_string',
get_string('mandatorystring', 'local_mandatoryactivities'),get_string('mandatorystringdesc', 'local_mandatoryactivities')," This is a high value activity ",PARAM_TEXT));
}
\ No newline at end of file
......
......@@ -62,7 +62,7 @@ th,td{
<div class="col text-center">
<table class="activitytable center">
<tr>
<th style="width:10%">Sl.no</th><th>Newly Added mandatory activies</th>
<th style="width:10%">Sl.no</th><th>Newly Added mandatory activities</th>
</tr>
<tbody id="added">
......@@ -87,7 +87,7 @@ th,td{
<div class="col text-center">
<table class="activitytable center">
<tr>
<th style="width:10%">Sl.no</th><th>Unchanged activies </th>
<th style="width:10%">Sl.no</th><th>Unchanged activities </th>
</tr>
<tbody id="unchanged">
......
<?php
require_once(dirname(__FILE__) . '/../../config.php');
global $USER, $CFG, $PAGE, $COURSE,$DB, $context;
function updatemoduleids(){
global $USER,$CFG,$DB;
$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')
group by course)";
$insert=$DB->execute($sql);
}
updatemoduleids();
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!