a7ec8fdb by logesh

update script and ui bugs fixed

1 parent 0c218c34
...@@ -76,7 +76,7 @@ switch ($action) { ...@@ -76,7 +76,7 @@ switch ($action) {
76 $unchangedids=array(); 76 $unchangedids=array();
77 $unchangedactivities=array(); 77 $unchangedactivities=array();
78 78
79 $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"; 79 $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";
80 $qresult=$DB->get_records_sql($sql); 80 $qresult=$DB->get_records_sql($sql);
81 81
82 $allcmids=array(); 82 $allcmids=array();
...@@ -92,6 +92,7 @@ switch ($action) { ...@@ -92,6 +92,7 @@ switch ($action) {
92 if (in_array($id, $previousestatus)){ 92 if (in_array($id, $previousestatus)){
93 // 93 //
94 }else{ 94 }else{
95 if (isset($qresult[$id])){
95 $id=number_format($id); 96 $id=number_format($id);
96 $modaname=$qresult[$id]->name; 97 $modaname=$qresult[$id]->name;
97 $instance=$qresult[$id]->instance; 98 $instance=$qresult[$id]->instance;
...@@ -103,16 +104,17 @@ switch ($action) { ...@@ -103,16 +104,17 @@ switch ($action) {
103 $newlyaddedids[]=$id; 104 $newlyaddedids[]=$id;
104 } 105 }
105 } 106 }
107 }
106 108
107 //iterate to get removed id's 109 //iterate to get removed id's
108 foreach($previousestatus as $id){ 110 foreach($previousestatus as $id1){
109 if (in_array($id, $checkedids)){ 111 if (in_array($id1, $checkedids)){
110 // 112 //
111 }else{ 113 }else{
112 114 if (isset($qresult[$id1])){
113 $id=number_format($id); 115 $id=number_format($id1);
114 $modaname=$qresult[$id]->name; 116 $modaname=$qresult[$id1]->name;
115 $instance=$qresult[$id]->instance; 117 $instance=$qresult[$id1]->instance;
116 118
117 $sqlactivityname="select name from mdl_$modaname where id=$instance"; 119 $sqlactivityname="select name from mdl_$modaname where id=$instance";
118 $aname=$DB->get_record_sql($sqlactivityname); 120 $aname=$DB->get_record_sql($sqlactivityname);
...@@ -121,11 +123,13 @@ switch ($action) { ...@@ -121,11 +123,13 @@ switch ($action) {
121 $removedids[]=$id; 123 $removedids[]=$id;
122 } 124 }
123 } 125 }
126 }
124 127
125 $res=array_diff($allcmids,$newlyaddedids); 128 $res=array_diff($allcmids,$newlyaddedids);
126 $unchangedids=array_diff($res,$removedids); 129 $unchangedids=array_diff($res,$removedids);
127 130
128 foreach ($unchangedids as $data){ 131 foreach ($unchangedids as $data){
132 if (isset($qresult[$data])){
129 $id=number_format($data); 133 $id=number_format($data);
130 $modaname=$qresult[$data]->name; 134 $modaname=$qresult[$data]->name;
131 $instance=$qresult[$data]->instance; 135 $instance=$qresult[$data]->instance;
...@@ -135,6 +139,7 @@ switch ($action) { ...@@ -135,6 +139,7 @@ switch ($action) {
135 139
136 $unchangedactivities[]=$aname; 140 $unchangedactivities[]=$aname;
137 } 141 }
142 }
138 }else{ 143 }else{
139 144
140 foreach ($qresult as $val){ 145 foreach ($qresult as $val){
......
...@@ -47,10 +47,13 @@ foreach ($modules as $mod){ ...@@ -47,10 +47,13 @@ foreach ($modules as $mod){
47 $tablenme='mdl_'.$mod->name; 47 $tablenme='mdl_'.$mod->name;
48 48
49 $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 49 $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
50 mv.course=$courseid and mcm.module=(select id from mdl_modules mm where name ='$mod->name') order by mv.id asc"; 50 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";
51 $allactivities=$DB->get_records_sql($sqlactivities); 51 $allactivities=$DB->get_records_sql($sqlactivities);
52 $span=count($allactivities); 52 $span=count($allactivities);
53 53
54 if (!empty($span)){
55
56
54 $tabledata .="<tr class='modname' data-modname='$mod->name' id='modname'><td rowspan='$span'>$mod->name</td>"; 57 $tabledata .="<tr class='modname' data-modname='$mod->name' id='modname'><td rowspan='$span'>$mod->name</td>";
55 58
56 foreach ($allactivities as $activity){ 59 foreach ($allactivities as $activity){
...@@ -95,6 +98,7 @@ foreach ($modules as $mod){ ...@@ -95,6 +98,7 @@ foreach ($modules as $mod){
95 } 98 }
96 99
97 $tabledata .="</tr>"; 100 $tabledata .="</tr>";
101 }
98 } 102 }
99 103
100 $sql="select cmid from {local_mandatory_activities} where course=?"; 104 $sql="select cmid from {local_mandatory_activities} where course=?";
......
...@@ -29,3 +29,6 @@ $string['type'] = 'mandatoryactivity status'; ...@@ -29,3 +29,6 @@ $string['type'] = 'mandatoryactivity status';
29 29
30 $string['headerconfig'] = 'Local Plugin Setting'; 30 $string['headerconfig'] = 'Local Plugin Setting';
31 $string['descconfig'] = 'Configuration setting of Local mandatory activity plugin'; 31 $string['descconfig'] = 'Configuration setting of Local mandatory activity plugin';
32
33 $string['mandatorystring'] = 'Enter the mandatory title string';
34 $string['mandatorystringdesc'] = 'Enter the string to display for mandatory activities.';
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -27,4 +27,16 @@ $prefix = 'local_mandatoryactivities/'; ...@@ -27,4 +27,16 @@ $prefix = 'local_mandatoryactivities/';
27 27
28 if ($hassiteconfig) { 28 if ($hassiteconfig) {
29 29
30
31 $settings = new admin_settingpage('local_mandatoryactivities', get_string('pluginname', 'local_mandatoryactivities'));
32
33 $ADMIN->add('localplugins', $settings);
34
35 $settings->add(new admin_setting_heading('headerconfig',get_string('headerconfig', 'local_mandatoryactivities'),get_string('descconfig', 'local_mandatoryactivities')));
36
37 $settings->add(new admin_setting_configtext('local_mandatory_string',
38 get_string('mandatorystring', 'local_mandatoryactivities'),get_string('mandatorystringdesc', 'local_mandatoryactivities')," This is a high value activity ",PARAM_TEXT));
39
40
41
30 } 42 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -62,7 +62,7 @@ th,td{ ...@@ -62,7 +62,7 @@ th,td{
62 <div class="col text-center"> 62 <div class="col text-center">
63 <table class="activitytable center"> 63 <table class="activitytable center">
64 <tr> 64 <tr>
65 <th style="width:10%">Sl.no</th><th>Newly Added mandatory activies</th> 65 <th style="width:10%">Sl.no</th><th>Newly Added mandatory activities</th>
66 </tr> 66 </tr>
67 <tbody id="added"> 67 <tbody id="added">
68 68
...@@ -87,7 +87,7 @@ th,td{ ...@@ -87,7 +87,7 @@ th,td{
87 <div class="col text-center"> 87 <div class="col text-center">
88 <table class="activitytable center"> 88 <table class="activitytable center">
89 <tr> 89 <tr>
90 <th style="width:10%">Sl.no</th><th>Unchanged activies </th> 90 <th style="width:10%">Sl.no</th><th>Unchanged activities </th>
91 </tr> 91 </tr>
92 <tbody id="unchanged"> 92 <tbody id="unchanged">
93 93
......
1 <?php
2
3 require_once(dirname(__FILE__) . '/../../config.php');
4
5 global $USER, $CFG, $PAGE, $COURSE,$DB, $context;
6
7
8
9 function updatemoduleids(){
10 global $USER,$CFG,$DB;
11
12 $sql="insert into mdl_local_mandatory_activities(course,cmid, mandatory)
13 (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')
14 group by course)";
15
16 $insert=$DB->execute($sql);
17
18
19 }
20
21
22 updatemoduleids();
...\ No newline at end of file ...\ 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!