added mandatory activities files
0 parents
Showing
11 changed files
with
871 additions
and
0 deletions
ajax.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /* | ||
18 | * Handling all ajax request of mandatory activities | ||
19 | * | ||
20 | * @package local_mandatoryactivities | ||
21 | * @author logesh<logesh@teknoturf.com> | ||
22 | */ | ||
23 | |||
24 | define ( 'AJAX_SCRIPT', true ); | ||
25 | define ( 'NO_DEBUG_DISPLAY', true ); | ||
26 | |||
27 | require_once (dirname ( __FILE__ ) . '/../../config.php'); | ||
28 | $action = optional_param ( 'action', '', PARAM_RAW ); | ||
29 | $cmids = optional_param_array ( 'cmids', null, PARAM_RAW ); | ||
30 | $course = optional_param ( 'course', 0, PARAM_RAW ); | ||
31 | |||
32 | |||
33 | Global $DB, $CFG, $USER; | ||
34 | |||
35 | switch ($action) { | ||
36 | |||
37 | case 'savemandatoryids': | ||
38 | |||
39 | $madatorycmids= implode(', ', $cmids); | ||
40 | |||
41 | $sql="select * from {local_mandatory_activities} where course=?"; | ||
42 | $mandatoryactivities = $DB->get_record_sql($sql,array($course)); | ||
43 | |||
44 | if (isset($mandatoryactivities->id)){ | ||
45 | |||
46 | $instance = new stdClass(); | ||
47 | $instance->id=$mandatoryactivities->id; | ||
48 | $instance->course = $course; | ||
49 | $instance->cmid = $madatorycmids; | ||
50 | $instance->mandatory = $mandatoryactivities->mandatory; | ||
51 | |||
52 | $DB->update_record('local_mandatory_activities', $instance); | ||
53 | |||
54 | }else{ | ||
55 | |||
56 | $instance = new stdClass(); | ||
57 | $instance->course = $course; | ||
58 | $instance->cmid = $madatorycmids; | ||
59 | $instance->mandatory = 1; | ||
60 | |||
61 | $DB->insert_record('local_mandatory_activities', $instance); | ||
62 | } | ||
63 | |||
64 | echo json_encode(true); | ||
65 | die(); | ||
66 | |||
67 | case 'getcomparision': | ||
68 | |||
69 | $checkedids = optional_param_array( 'checked', null, PARAM_RAW ); | ||
70 | $mandatoryids = optional_param( 'mandatory', '', PARAM_RAW ); | ||
71 | |||
72 | $newlyaddedids=array(); | ||
73 | $newlyaddedactivities=array(); | ||
74 | $removedids=array(); | ||
75 | $removedactivities=array(); | ||
76 | $unchangedids=array(); | ||
77 | $unchangedactivities=array(); | ||
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"; | ||
80 | $qresult=$DB->get_records_sql($sql); | ||
81 | |||
82 | $allcmids=array(); | ||
83 | foreach ($qresult as $value){ | ||
84 | $allcmids[]=$value->id; | ||
85 | } | ||
86 | |||
87 | if ($mandatoryids && $checkedids){ | ||
88 | |||
89 | $previousestatus=explode(",",$mandatoryids); | ||
90 | foreach($checkedids as $id){ | ||
91 | //iterate to get newly added id's | ||
92 | if (in_array($id, $previousestatus)){ | ||
93 | // | ||
94 | }else{ | ||
95 | $id=number_format($id); | ||
96 | $modaname=$qresult[$id]->name; | ||
97 | $instance=$qresult[$id]->instance; | ||
98 | |||
99 | $sqlactivityname="select name from mdl_$modaname where id=$instance"; | ||
100 | $aname=$DB->get_record_sql($sqlactivityname); | ||
101 | |||
102 | $newlyaddedactivities[]=$aname; | ||
103 | $newlyaddedids[]=$id; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | //iterate to get removed id's | ||
108 | foreach($previousestatus as $id){ | ||
109 | if (in_array($id, $checkedids)){ | ||
110 | // | ||
111 | }else{ | ||
112 | |||
113 | $id=number_format($id); | ||
114 | $modaname=$qresult[$id]->name; | ||
115 | $instance=$qresult[$id]->instance; | ||
116 | |||
117 | $sqlactivityname="select name from mdl_$modaname where id=$instance"; | ||
118 | $aname=$DB->get_record_sql($sqlactivityname); | ||
119 | |||
120 | $removedactivities[]=$aname; | ||
121 | $removedids[]=$id; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | $res=array_diff($allcmids,$newlyaddedids); | ||
126 | $unchangedids=array_diff($res,$removedids); | ||
127 | |||
128 | foreach ($unchangedids as $data){ | ||
129 | $id=number_format($data); | ||
130 | $modaname=$qresult[$data]->name; | ||
131 | $instance=$qresult[$data]->instance; | ||
132 | |||
133 | $sqlactivityname="select name from mdl_$modaname where id=$instance"; | ||
134 | $aname=$DB->get_record_sql($sqlactivityname); | ||
135 | |||
136 | $unchangedactivities[]=$aname; | ||
137 | } | ||
138 | }else{ | ||
139 | |||
140 | foreach ($qresult as $val){ | ||
141 | $modaname=$val->name; | ||
142 | $instance=$val->instance; | ||
143 | |||
144 | $sqlactivityname="select name from mdl_$modaname where id=$instance"; | ||
145 | $aname=$DB->get_record_sql($sqlactivityname); | ||
146 | |||
147 | $unchangedactivities[]=$aname; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | $data = array(); | ||
152 | $data['removed'] = $removedactivities; | ||
153 | $data['newlyadded'] = $newlyaddedactivities; | ||
154 | $data['unchanged'] = $unchangedactivities; | ||
155 | echo json_encode($data); | ||
156 | |||
157 | die(); | ||
158 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
db/install.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | /** | ||
17 | * @package local_mandatoryactivities | ||
18 | * @author 2020 Logesh <logesh@teknoturf.com> | ||
19 | * | ||
20 | */ | ||
21 | /* | ||
22 | * This file does nothing as of now. Just written some empty funcitons to prevent | ||
23 | * installation errors :p | ||
24 | */ | ||
25 | defined('MOODLE_INTERNAL') || die(); | ||
26 | /** | ||
27 | * Post installation procedure | ||
28 | * | ||
29 | * @see upgrade_plugins_modules() | ||
30 | */ | ||
31 | function xmldb_local_mandatoryactivities_install() { | ||
32 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
db/install.xml
0 → 100644
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <XMLDB PATH="local/mandatoryactivities/db" VERSION="20200824" COMMENT="XMLDB file for Moodle local/mandatoryactivities" | ||
3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"> | ||
4 | |||
5 | <TABLES> | ||
6 | <TABLE NAME="local_mandatory_activities" COMMENT="Track list of mandatory activities"> | ||
7 | <FIELDS> | ||
8 | <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> | ||
9 | <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | ||
10 | <FIELD NAME="cmid" TYPE="text" LENGTH="big" NOTNULL="true" SEQUENCE="false"/> | ||
11 | <FIELD NAME="mandatory" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> | ||
12 | </FIELDS> | ||
13 | <KEYS> | ||
14 | <KEY NAME="primary" TYPE="primary" FIELDS="id"/> | ||
15 | </KEYS> | ||
16 | </TABLE> | ||
17 | </TABLES> | ||
18 | </XMLDB> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
db/upgrade.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Plugin upgrade | ||
19 | * | ||
20 | * @package local_mandatoryactivities | ||
21 | * @copyright 2020 Logesh <logesh@teknoturf.com> | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | defined( 'MOODLE_INTERNAL' ) || die(); | ||
26 | function xmldb_local_mandatoryactivities_upgrade($oldversion = 0) { | ||
27 | |||
28 | global $CFG, $DB,$USER; | ||
29 | |||
30 | $dbman = $DB->get_manager(); | ||
31 | |||
32 | |||
33 | return true; | ||
34 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
editsettings.php
0 → 100644
1 | <?php | ||
2 | |||
3 | require_once(dirname(__FILE__) . '/../../config.php'); | ||
4 | |||
5 | global $USER, $CFG, $PAGE, $COURSE,$DB, $context; | ||
6 | |||
7 | $courseid = required_param('courseid', PARAM_INT); | ||
8 | |||
9 | if (!$course = $DB->get_record('course', array('id'=>$courseid))) { | ||
10 | print_error("invalidcourseid"); | ||
11 | } | ||
12 | |||
13 | $PAGE->set_url('/local/mandatoryactivities/editsettings.php?courseid='.$courseid, array('id'=>$courseid)); | ||
14 | |||
15 | require_login($course); | ||
16 | |||
17 | $context = context_course::instance($courseid); | ||
18 | |||
19 | $PAGE->set_pagelayout('incourse'); | ||
20 | $pagename = "Mandatory Activities"; | ||
21 | $PAGE->navbar->add($pagename); | ||
22 | $PAGE->set_title($course->fullname.': '.$pagename); | ||
23 | $PAGE->set_heading($course->fullname.': '.$pagename); | ||
24 | $PAGE->set_title ("Mandatory Activities"); | ||
25 | |||
26 | //get module names | ||
27 | $sqlmod="select name from mdl_modules mm where id in (select distinct module from mdl_course_modules mcm where course=$courseid) order by name Asc"; | ||
28 | $modules=$DB->get_records_sql($sqlmod); | ||
29 | |||
30 | //get mandate activities | ||
31 | $sqlmandate="select * from {local_mandatory_activities} where course=$courseid"; | ||
32 | $mandateacty=$DB->get_record_sql($sqlmandate); | ||
33 | |||
34 | if ($mandateacty){ | ||
35 | $madatorycmids= explode(',', $mandateacty->cmid); | ||
36 | $templatecontext['new'] = true; | ||
37 | }else{ | ||
38 | $madatorycmids=array(); | ||
39 | $templatecontext['new'] = false; | ||
40 | } | ||
41 | |||
42 | |||
43 | $tabledata=""; | ||
44 | $comparisiontable=""; | ||
45 | $i=0;$j=0; | ||
46 | foreach ($modules as $mod){ | ||
47 | $tablenme='mdl_'.$mod->name; | ||
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 | ||
50 | mv.course=$courseid 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); | ||
52 | $span=count($allactivities); | ||
53 | |||
54 | $tabledata .="<tr class='modname' data-modname='$mod->name' id='modname'><td rowspan='$span'>$mod->name</td>"; | ||
55 | |||
56 | foreach ($allactivities as $activity){ | ||
57 | |||
58 | if (in_array($activity->cmid, $madatorycmids)){ | ||
59 | |||
60 | $values='<div class="form-check "> | ||
61 | <label class="form-check-label" for="check1" '; | ||
62 | if (!empty($activity->randomized)) { | ||
63 | $values .='title="Randomized activity cannot be choosed as a mandatory activity"'; | ||
64 | } | ||
65 | $values .='><input type="checkbox" class="form-check-input checkboxesavilable" id="checkboxactivities'.$i.'" name="'.$mod->name.'" data-cmid="'.$activity->cmid.'" checked'; | ||
66 | |||
67 | if (!empty($activity->randomized)) { | ||
68 | $values .=' disabled'; | ||
69 | } | ||
70 | $values .='>'.$activity->name.' | ||
71 | </label> | ||
72 | </div>'; | ||
73 | |||
74 | }else{ | ||
75 | $values='<div class="form-check "> | ||
76 | <label class="form-check-label" for="check1" '; | ||
77 | |||
78 | if (!empty($activity->randomized)) { | ||
79 | $values .='title="Randomized activity cannot be choosed as a mandatory activity"'; | ||
80 | } | ||
81 | |||
82 | $values .='><input type="checkbox" class="form-check-input checkboxesavilable" id="checkboxactivities'.$i.'" name="'.$mod->name.'" data-cmid="'.$activity->cmid.'" '; | ||
83 | |||
84 | if (!empty($activity->randomized)) { | ||
85 | $values .='disabled '; | ||
86 | } | ||
87 | $values .='>'.$activity->name.' | ||
88 | </label> | ||
89 | </div>'; | ||
90 | |||
91 | } | ||
92 | |||
93 | $tabledata .="<td>$values</td></tr>"; | ||
94 | $i=$i+1; | ||
95 | } | ||
96 | |||
97 | $tabledata .="</tr>"; | ||
98 | } | ||
99 | |||
100 | $sql="select cmid from {local_mandatory_activities} where course=?"; | ||
101 | $mandatoryactivities = $DB->get_record_sql($sql,array($courseid)); | ||
102 | |||
103 | if (isset($mandatoryactivities) && !empty($mandatoryactivities)){ | ||
104 | $templatecontext['mandatoryids']=$mandatoryactivities->cmid; | ||
105 | }else{ | ||
106 | $templatecontext['mandatoryids']=false; | ||
107 | } | ||
108 | |||
109 | $templatecontext['wwwroot']=$CFG->wwwroot; | ||
110 | |||
111 | // $templatecontext['comparisiontable']=$comparisiontable; | ||
112 | |||
113 | $templatecontext['tabledata']=$tabledata; | ||
114 | |||
115 | $templatecontext['courseid'] = $courseid; | ||
116 | |||
117 | |||
118 | |||
119 | echo $OUTPUT->header(); | ||
120 | |||
121 | echo $OUTPUT->render_from_template("local_mandatoryactivities/index", $templatecontext); | ||
122 | |||
123 | echo $OUTPUT->footer(); |
lang/en/local_mandatoryactivities.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * Language strings for English is defined here. | ||
19 | * | ||
20 | * @package local_mandatoryactivities | ||
21 | * @copyright 2020 Logesh <logesh@teknoturf.com> | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | defined('MOODLE_INTERNAL') || die(); | ||
26 | |||
27 | $string['pluginname'] = 'mandatoryactivities'; | ||
28 | $string['type'] = 'mandatoryactivity status'; | ||
29 | |||
30 | $string['headerconfig'] = 'Local Plugin Setting'; | ||
31 | $string['descconfig'] = 'Configuration setting of Local mandatory activity plugin'; |
pix/loading.gif
0 → 100644
8.61 KB
settings.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * | ||
19 | * @package local_mandatoryactivities | ||
20 | * @copyright 2020 Logesh <Logesh@teknoturf.com> | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | defined('MOODLE_INTERNAL') || die(); | ||
25 | |||
26 | $prefix = 'local_mandatoryactivities/'; | ||
27 | |||
28 | if ($hassiteconfig) { | ||
29 | |||
30 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
templates/confirmation.mustache
0 → 100644
1 | <style> | ||
2 | input[type="checkbox"][disabled] { | ||
3 | cursor: no-drop; | ||
4 | } | ||
5 | |||
6 | #loadingcomparision{ | ||
7 | |||
8 | display:none; | ||
9 | } | ||
10 | |||
11 | th,td{ | ||
12 | /* text-align: center !important; */ | ||
13 | } | ||
14 | |||
15 | </style> | ||
16 | |||
17 | <div id="loadingcomparision" align="center"> | ||
18 | <img src="{{wwwroot}}/local/mandatoryactivities/pix/loading.gif"/> | ||
19 | </div> | ||
20 | |||
21 | <div id="successalert"> | ||
22 | |||
23 | </div> | ||
24 | |||
25 | <div id="comparisiontable" style="display:none;"> | ||
26 | <div id="accordion2"> | ||
27 | <div class="card"> | ||
28 | <div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;"> | ||
29 | <i id="cccriteria2" class="arrow down" data-toggle="collapse" href="#collapse3" style="cursor:pointer;"></i> | ||
30 | <a id="cccriteria2" class="card-link" data-toggle="collapse" href="#collapse3" style="color: black;font-size: medium;"> | ||
31 | <b>confirm</b> | ||
32 | </a> | ||
33 | </div> | ||
34 | <div id="collapse3" class="collapse show" data-parent="#accordion2"> | ||
35 | <div class="card-body"> | ||
36 | <div class="row"> | ||
37 | <div class="col text-center"> | ||
38 | <table class="activitytable center"> | ||
39 | <tr> | ||
40 | <th style="width:10%">Sl.no</th><th>Activities removed from mandatory</th> | ||
41 | </tr> | ||
42 | <tbody id="removed"> | ||
43 | |||
44 | </tbody> | ||
45 | </table> | ||
46 | </div> | ||
47 | </div> | ||
48 | </div> | ||
49 | </div> | ||
50 | </div> | ||
51 | </div> | ||
52 | |||
53 | <div id="accordion3"> | ||
54 | <div class="card"> | ||
55 | <div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;"> | ||
56 | <a id="cccriteria3" class="card-link" data-toggle="collapse" href="#collapse4" style="color: black;font-size: medium;"> | ||
57 | </a> | ||
58 | </div> | ||
59 | <div id="collapse4" class="collapse show" data-parent="#accordion3"> | ||
60 | <div class="card-body"> | ||
61 | <div class="row"> | ||
62 | <div class="col text-center"> | ||
63 | <table class="activitytable center"> | ||
64 | <tr> | ||
65 | <th style="width:10%">Sl.no</th><th>Newly Added mandatory activies</th> | ||
66 | </tr> | ||
67 | <tbody id="added"> | ||
68 | |||
69 | </tbody> | ||
70 | </table> | ||
71 | </div> | ||
72 | </div> | ||
73 | </div> | ||
74 | </div> | ||
75 | </div> | ||
76 | </div> | ||
77 | |||
78 | <div id="accordion4"> | ||
79 | <div class="card"> | ||
80 | <div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;"> | ||
81 | <a id="cccriteria4" class="card-link" data-toggle="collapse" href="#collapse5" style="color: black;font-size: medium;"> | ||
82 | </a> | ||
83 | </div> | ||
84 | <div id="collapse5" class="collapse show" data-parent="#accordion4"> | ||
85 | <div class="card-body"> | ||
86 | <div class="row"> | ||
87 | <div class="col text-center"> | ||
88 | <table class="activitytable center"> | ||
89 | <tr> | ||
90 | <th style="width:10%">Sl.no</th><th>Unchanged activies </th> | ||
91 | </tr> | ||
92 | <tbody id="unchanged"> | ||
93 | |||
94 | </tbody> | ||
95 | </table> | ||
96 | </div> | ||
97 | </div> | ||
98 | </div> | ||
99 | </div> | ||
100 | </div> | ||
101 | </div | ||
102 | |||
103 | <div id="accordion5"> | ||
104 | <div class="card"> | ||
105 | <div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;"> | ||
106 | <i id="cccriteria5" data-toggle="collapse" href="#collapse6" style="cursor:pointer;"></i> | ||
107 | <a id="cccriteria5" class="card-link" data-toggle="collapse" href="#collapse6" style="color: black;font-size: medium;"></a> | ||
108 | </div> | ||
109 | <div id="collapse6" class="collapse show" data-parent="#accordion5"> | ||
110 | <div class="card-body"> | ||
111 | <div class="row"> | ||
112 | <div class="col text-center"> | ||
113 | <button type="button" class="btn btn-info" id="previousepagem">Previous page</button> | ||
114 | <button type="button" class="btn btn-info" id="savemandatoryconfirm">Save Changes</button> | ||
115 | <button type="button" class="btn btn-info" id="cancelmandatory">Cancel</button></td></tr> | ||
116 | </div> | ||
117 | </div> | ||
118 | </div> | ||
119 | </div> | ||
120 | </div> | ||
121 | </div> | ||
122 | |||
123 | </div> | ||
124 | |||
125 | <script> | ||
126 | |||
127 | $(document).ready(function(){ | ||
128 | |||
129 | $(document).on('click', '#savemandatory', function(){ | ||
130 | |||
131 | $('#madatorysection').css("display", "none"); | ||
132 | $('#loadingcomparision').css("display", "block"); | ||
133 | |||
134 | var checkedids=[]; | ||
135 | |||
136 | $('input:checkbox.checkboxesavilable:checked').each(function () { | ||
137 | checkedids.push($(this).attr("data-cmid")); | ||
138 | }); | ||
139 | |||
140 | var rootPath = M.cfg.wwwroot; | ||
141 | var arg = { action:'getcomparision', | ||
142 | checked:checkedids, | ||
143 | course : {{courseid}}, | ||
144 | mandatory:'{{mandatoryids}}'}; | ||
145 | |||
146 | $.ajax({ | ||
147 | url: rootPath+"/local/mandatoryactivities/ajax.php", | ||
148 | type: "POST", | ||
149 | data : arg, | ||
150 | success: function(obj){ | ||
151 | |||
152 | var removedcmids=obj.removed; | ||
153 | var newlyaddedcmids=obj.newlyadded; | ||
154 | var unchangedcmids=obj.unchanged; | ||
155 | |||
156 | $('#loadingcomparision').css("display", "none"); | ||
157 | $('#comparisiontable').css("display", "block"); | ||
158 | |||
159 | |||
160 | if(removedcmids.length > 0){ | ||
161 | |||
162 | var tablecontent1="";var i; | ||
163 | |||
164 | for (i = 0; i < removedcmids.length; i++) { | ||
165 | var slno=i+1; | ||
166 | tablecontent1 += "<tr id='removedrows'><td>"+slno+"</td><td>"+removedcmids[i].name+"</td></tr>"; | ||
167 | } | ||
168 | |||
169 | $('[id=removedrows]').remove(); | ||
170 | $("#removed").append(tablecontent1); | ||
171 | |||
172 | }else{ | ||
173 | |||
174 | tablecontent1 += "<tr id='removedrows'><td colspan='2'>No Activities </td></tr>"; | ||
175 | $('[id=removedrows]').remove(); | ||
176 | $("#removed").append(tablecontent1); | ||
177 | } | ||
178 | |||
179 | |||
180 | if(newlyaddedcmids.length > 0){ | ||
181 | |||
182 | var tablecontent2="";var i; | ||
183 | |||
184 | for (i = 0; i < newlyaddedcmids.length; i++) { | ||
185 | var slno=i+1; | ||
186 | tablecontent2 += "<tr id='addedrows'><td>"+slno+"</td><td>"+newlyaddedcmids[i].name+"</td></tr>"; | ||
187 | } | ||
188 | |||
189 | $('[id=addedrows]').remove(); | ||
190 | $("#added").append(tablecontent2); | ||
191 | |||
192 | }else{ | ||
193 | |||
194 | tablecontent2 += "<tr id='addedrows'><td colspan='2'>No Activities </td></tr>"; | ||
195 | $('[id=addedrows]').remove(); | ||
196 | $("#added").append(tablecontent2); | ||
197 | } | ||
198 | |||
199 | |||
200 | if(unchangedcmids.length > 0){ | ||
201 | |||
202 | var tablecontent3="";var i; | ||
203 | |||
204 | for (i = 0; i < unchangedcmids.length; i++) { | ||
205 | var slno=i+1; | ||
206 | tablecontent3 += "<tr id='unchangedrows'><td>"+slno+"</td><td>"+unchangedcmids[i].name+"</td></tr>"; | ||
207 | } | ||
208 | |||
209 | $('[id=unchangedrows]').remove(); | ||
210 | $("#unchanged").append(tablecontent3); | ||
211 | |||
212 | }else{ | ||
213 | |||
214 | tablecontent3 += "<tr id='unchangedrows'><td colspan='2'>No Activities </td></tr>"; | ||
215 | $('[id=unchangedrows]').remove(); | ||
216 | $("#unchanged").append(tablecontent3); | ||
217 | } | ||
218 | }, | ||
219 | error: function(){ | ||
220 | |||
221 | } | ||
222 | }); | ||
223 | |||
224 | // $('#accordion1').css("display", "none"); | ||
225 | |||
226 | }); | ||
227 | |||
228 | $(document).on('click', '#cccriteria2', function(){ | ||
229 | $('#cccriteria3').click(); | ||
230 | $('#cccriteria4').click(); | ||
231 | $('#cccriteria5').click(); | ||
232 | |||
233 | var vals=$('#cccriteria2').hasClass('down'); | ||
234 | if(vals){ | ||
235 | $('#cccriteria2').removeClass('down'); | ||
236 | $('#cccriteria2').addClass('right'); | ||
237 | }else{ | ||
238 | $('#cccriteria2').removeClass('right'); | ||
239 | $('#cccriteria2').addClass('down'); | ||
240 | } | ||
241 | }); | ||
242 | |||
243 | |||
244 | $(document).on('click', '#savemandatoryconfirm', function(){ | ||
245 | |||
246 | var cmids=[]; | ||
247 | var rootPath = M.cfg.wwwroot; | ||
248 | |||
249 | $('#loadingcomparision').css("display", "block"); | ||
250 | $('#comparisiontable').css("display", "none"); | ||
251 | |||
252 | $.each($("input[type='checkbox']:checked"), function(){ | ||
253 | cmids.push($(this).attr("data-cmid")); | ||
254 | }); | ||
255 | |||
256 | var arg = { | ||
257 | action:'savemandatoryids', | ||
258 | cmids :cmids, | ||
259 | course : {{courseid}} | ||
260 | }; | ||
261 | |||
262 | $.ajax({ | ||
263 | url: rootPath+"/local/mandatoryactivities/ajax.php", | ||
264 | type: "POST", | ||
265 | data : arg, | ||
266 | success: function(obj){ | ||
267 | |||
268 | $('#loadingcomparision').css("display", "none"); | ||
269 | |||
270 | var alerttags='<div class="alert alert-success"><strong>Successfully Ssved</strong></div>'; | ||
271 | $('#successalert').append(alerttags); | ||
272 | |||
273 | setTimeout(function(){ | ||
274 | var redirecturl=rootPath+"/local/mandatoryactivities/editsettings.php?courseid="+{{courseid}}; | ||
275 | location.replace(redirecturl); | ||
276 | }, 1500); | ||
277 | |||
278 | }, | ||
279 | error: function(){ | ||
280 | |||
281 | //var redirecturl=rootPath+"local/coursecompletion/index.php?courseid="+{{courseid}}; | ||
282 | //location.replace(redirecturl); | ||
283 | } | ||
284 | }); | ||
285 | }); | ||
286 | |||
287 | |||
288 | $(document).on('click', '#previousepagem', function(){ | ||
289 | |||
290 | $('#comparisiontable').css("display", "none"); | ||
291 | $('#madatorysection').css("display", "block"); | ||
292 | |||
293 | |||
294 | }); | ||
295 | |||
296 | |||
297 | |||
298 | |||
299 | }); | ||
300 | |||
301 | </script> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
templates/index.mustache
0 → 100644
1 | <!DOCTYPE html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <style> | ||
5 | .activitytable { | ||
6 | |||
7 | border-collapse: collapse; | ||
8 | width: 100%; | ||
9 | } | ||
10 | |||
11 | td, th { | ||
12 | border: 1px solid #dddddd; | ||
13 | text-align: left; | ||
14 | padding: 4px; | ||
15 | } | ||
16 | .arrow { | ||
17 | border: solid black; | ||
18 | border-width: 0 3px 3px 0; | ||
19 | display: inline-block; | ||
20 | padding: 3px; | ||
21 | } | ||
22 | |||
23 | .right { | ||
24 | transform: rotate(-45deg); | ||
25 | -webkit-transform: rotate(-45deg); | ||
26 | transition-duration: 0.5s; | ||
27 | } | ||
28 | |||
29 | .down { | ||
30 | transform: rotate(45deg); | ||
31 | -webkit-transform: rotate(45deg); | ||
32 | transition-duration: 0.5s; | ||
33 | } | ||
34 | |||
35 | </style> | ||
36 | </head> | ||
37 | <body> | ||
38 | |||
39 | <div class="container" id="madatorysection"> | ||
40 | <div id="accordion"> | ||
41 | <div class="card"> | ||
42 | <div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;"> | ||
43 | <i id="cccriteria" class="arrow down" data-toggle="collapse" href="#collapseOne" style="cursor:pointer;"></i> | ||
44 | <a id="cccriteria" class="card-link" data-toggle="collapse" href="#collapseOne" style="color: black;font-size: medium;"> | ||
45 | <b>Mandatory Activity Settings</b> | ||
46 | </a> | ||
47 | </div> | ||
48 | <div id="collapseOne" class="collapse show" data-parent="#accordion"> | ||
49 | <div class="card-body"> | ||
50 | <table class="activitytable"> | ||
51 | <tr> | ||
52 | <th>Activity type</th> <th>Completion criteria</th> | ||
53 | </tr> | ||
54 | {{{tabledata}}} | ||
55 | </table> | ||
56 | </div> | ||
57 | </div> | ||
58 | </div> | ||
59 | </div> | ||
60 | |||
61 | <div id="accordion1"> | ||
62 | <div class="card"> | ||
63 | <div class="card-header" style="background-color: rgb(255 255 255);border-bottom:none;"> | ||
64 | <i id="cccriteria1" data-toggle="collapse" href="#collapse2" style="cursor:pointer;"></i> | ||
65 | <a id="cccriteria1" class="card-link" data-toggle="collapse" href="#collapse2" style="color: black;font-size: medium;"> | ||
66 | <b></b> | ||
67 | </a> | ||
68 | </div> | ||
69 | <div id="collapse2" class="collapse show" data-parent="#accordion1"> | ||
70 | <div class="card-body"> | ||
71 | <div class="row"> | ||
72 | <div class="col text-center"> | ||
73 | <button type="button" class="btn btn-info" id="savemandatory">Continue</button> | ||
74 | <button type="button" class="btn btn-info" id="cancelmandatory">Cancel</button></td></tr> | ||
75 | </div> | ||
76 | </div> | ||
77 | </div> | ||
78 | </div> | ||
79 | </div> | ||
80 | </div> | ||
81 | </div> | ||
82 | </body> | ||
83 | </html> | ||
84 | |||
85 | {{> local_mandatoryactivities/confirmation }} | ||
86 | |||
87 | <script> | ||
88 | |||
89 | $(document).ready(function(){ | ||
90 | |||
91 | $(document).on('click', '#cccriteria', function(){ | ||
92 | |||
93 | var vals=$('#cccriteria').hasClass('down'); | ||
94 | $('#cccriteria1').click() | ||
95 | if(vals){ | ||
96 | $('#cccriteria').removeClass('down'); | ||
97 | $('#cccriteria').addClass('right'); | ||
98 | }else{ | ||
99 | $('#cccriteria').removeClass('right'); | ||
100 | $('#cccriteria').addClass('down'); | ||
101 | } | ||
102 | }); | ||
103 | |||
104 | |||
105 | $(document).on('click', '#cancelmandatory', function(){ | ||
106 | |||
107 | var rootPath = M.cfg.wwwroot; | ||
108 | var redirecturl=rootPath+"/course/view.php?id="+{{courseid}}; | ||
109 | location.replace(redirecturl); | ||
110 | |||
111 | }); | ||
112 | }); | ||
113 | |||
114 | </script> |
version.php
0 → 100644
1 | <?php | ||
2 | // This file is part of Moodle - http://moodle.org/ | ||
3 | // | ||
4 | // Moodle is free software: you can redistribute it and/or modify | ||
5 | // it under the terms of the GNU General Public License as published by | ||
6 | // the Free Software Foundation, either version 3 of the License, or | ||
7 | // (at your option) any later version. | ||
8 | // | ||
9 | // Moodle is distributed in the hope that it will be useful, | ||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | // GNU General Public License for more details. | ||
13 | // | ||
14 | // You should have received a copy of the GNU General Public License | ||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | /** | ||
18 | * | ||
19 | * @package local_mandatoryactivities | ||
20 | * @copyright 2020 Logesh <logesh@teknoturf.com> | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | defined('MOODLE_INTERNAL') || die(); | ||
25 | |||
26 | $plugin->component = 'local_mandatoryactivities'; | ||
27 | $plugin->release = '0.0.1'; | ||
28 | $plugin->version = 2020082400; | ||
29 | $plugin->requires = 2017051500; | ||
30 | $plugin->maturity = MATURITY_ALPHA; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment