-- Phase - 4 changes
-- Milestone : 1
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '4', 'ReportsController', 'assignment-report-for-students,get-question-content', 'allow', 'Student');


-- Milestone : 2
CREATE TABLE IF NOT EXISTS `teachers_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `teacher_id` bigint(20) DEFAULT NULL,
  `problem_set_id` int(11) DEFAULT NULL,
  `class_id` int(11) DEFAULT NULL,
  `action_type` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `problem_set_id` (`problem_set_id`),
  KEY `teacher_id` (`teacher_id`),
  KEY `class_id` (`class_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Add teachers'' logs on some specific events like signup,login,create problemSets.' AUTO_INCREMENT=1 ;
 ALTER TABLE `teachers_log`
  ADD CONSTRAINT `teachers_log_ibfk_3` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  ADD CONSTRAINT `teachers_log_ibfk_1` FOREIGN KEY (`teacher_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  ADD CONSTRAINT `teachers_log_ibfk_2` FOREIGN KEY (`problem_set_id`) REFERENCES `problem_sets` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE `teachers_log` CHANGE `created_at` `created_at` DATETIME NULL DEFAULT NULL ;
UPDATE `user_rules` SET `privileges_actions` = 'index,logout,change-password,change-status,change-user-status,download-teachers-data,download-students-data' WHERE `user_rules`.`id` = 1;
UPDATE `user_rules` SET `privileges_actions` = 'index,change-password,logout,pages,change-status,varification-email,contact,vanilla-authenticate,redirect-to-vanilla,frontend-user-login,search,feature-page,search-data,blog,post-details,search-tutorial-pages,rstudio-login,login,redirect-to-rstudio' WHERE `user_rules`.`id` =22;
UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name' WHERE `user_rules`.`id` =25;
UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name' WHERE `user_rules`.`id` =25;
CREATE TABLE IF NOT EXISTS `students_assignments_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `student_id` bigint(20) DEFAULT NULL COMMENT 'Foreign Key From users.id',
  `assignment_id` bigint(20) DEFAULT NULL COMMENT 'Foreign Key From students_assignments.id',
  `question_id` int(11) DEFAULT NULL COMMENT 'Foreign Key From questions.id',
  `question_start_time` datetime DEFAULT NULL,
  `question_end_time` datetime DEFAULT NULL,
  `input_submitted_at` datetime DEFAULT NULL,
  `total_hints_count` int(11) DEFAULT NULL,
  `total_used_hints_count` int(11) DEFAULT NULL,
  `pt_slug` varchar(255) DEFAULT NULL,
  `input` text,
  `hint_delay` int(11) DEFAULT NULL,
  `action_type` varchar(255) DEFAULT NULL,
  `system_response` varchar(255) DEFAULT NULL,
  `score` decimal(5,2) DEFAULT NULL,
  `score_updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `student_id` (`student_id`),
  KEY `assignment_id` (`assignment_id`),
  KEY `question_id` (`question_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
 ALTER TABLE `students_assignments_log`
  ADD CONSTRAINT `students_assignments_log_ibfk_1` FOREIGN KEY (`student_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  ADD CONSTRAINT `students_assignments_log_ibfk_3` FOREIGN KEY (`assignment_id`) REFERENCES `students_assignments` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  ADD CONSTRAINT `students_assignments_log_ibfk_4` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON UPDATE NO ACTION;


-- Milestone : 3
ALTER TABLE `students_assignments_log` DROP `score_updated_at` ;


-- Phase - 5 changes (Need to replace tables user_rules, user_rules_menu)

--
-- Table structure for table `user_rights`
--

-- M-1
CREATE TABLE IF NOT EXISTS `user_rights` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `users_id` bigint(20) NOT NULL,
  `user_rules_menu_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='user rights per user' AUTO_INCREMENT=1 ;
ALTER TABLE  `user_rights` ADD INDEX (  `users_id` ) ;
ALTER TABLE  `user_rights` ADD INDEX (  `user_rules_menu_id` ) ;

ALTER TABLE `user_rights` ADD  FOREIGN KEY (`users_id`) REFERENCES `elearning_v5`.`users`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `user_rights` ADD  FOREIGN KEY (`user_rules_menu_id`) REFERENCES `elearning_v5`.`user_rules_menu`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;


-- M-2

ALTER TABLE  `students_assignments_log` CHANGE  `hint_delay`  `hint_delay` VARCHAR( 5 ) NULL DEFAULT NULL ;


-- 16th Feb'16


--
-- Table structure for table `assignment_terms`
--

CREATE TABLE IF NOT EXISTS `assignment_terms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Assignment terms ' AUTO_INCREMENT=1 ;


--
-- Table structure for table `assignment_types`
--

CREATE TABLE IF NOT EXISTS `assignment_types` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Assignment types' AUTO_INCREMENT=1 ;



--
-- Table structure for table `assignment_grade_types`
--

CREATE TABLE IF NOT EXISTS `assignment_grade_types` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Assignment grade types' AUTO_INCREMENT=1 ;

-- M-3 29022016
ALTER TABLE  `teachers_students_problem_sets` CHANGE  `a_terms`  `a_terms_id` INT( 11 ) NULL DEFAULT NULL ,
CHANGE  `a_types`  `a_types_id` INT( 11 ) NULL DEFAULT NULL ,
CHANGE  `a_grade_types`  `a_grade_types_id` INT( 11 ) NULL DEFAULT NULL ;

ALTER TABLE  `teachers_students_problem_sets` ADD INDEX (  `a_terms_id` ) ;
ALTER TABLE  `teachers_students_problem_sets` ADD INDEX (  `a_types_id` ) ;
ALTER TABLE  `teachers_students_problem_sets` ADD INDEX (  `a_grade_types_id` ) ;

ALTER TABLE `teachers_students_problem_sets` ADD  FOREIGN KEY (`a_terms_id`) REFERENCES `elearning_v5`.`assignment_terms`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE `teachers_students_problem_sets` ADD  FOREIGN KEY (`a_types_id`) REFERENCES `elearning_v5`.`assignment_types`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE `teachers_students_problem_sets` ADD  FOREIGN KEY (`a_grade_types_id`) REFERENCES `elearning_v5`.`assignment_grade_types`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;

--CASCADE DELETE
ALTER TABLE `teachers_students_problem_sets` DROP FOREIGN KEY `teachers_students_problem_sets_ibfk_4`;
ALTER TABLE `teachers_students_problem_sets` ADD  CONSTRAINT `teachers_students_problem_sets_ibfk_4` FOREIGN KEY (`a_terms_id`) REFERENCES `elearning_v5`.`assignment_terms`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `teachers_students_problem_sets` DROP FOREIGN KEY `teachers_students_problem_sets_ibfk_5`;
ALTER TABLE `teachers_students_problem_sets` ADD  CONSTRAINT `teachers_students_problem_sets_ibfk_5` FOREIGN KEY (`a_types_id`) REFERENCES `elearning_v5`.`assignment_types`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `teachers_students_problem_sets` DROP FOREIGN KEY `teachers_students_problem_sets_ibfk_6`;
ALTER TABLE `teachers_students_problem_sets` ADD  CONSTRAINT `teachers_students_problem_sets_ibfk_6` FOREIGN KEY (`a_grade_types_id`) REFERENCES `elearning_v5`.`assignment_grade_types`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;


-- changes on 17 11 2016 while vanilla embed
UPDATE  `elearning_v5`.`user_rules` SET  `privileges_actions` = 'index,change-password,logout,pages,change-status,varification-email,contact,vanilla-authenticate,redirect-to-vanilla,frontend-user-login,search,feature-page,search-data,blog,post-details,search-tutorial-pages,rstudio-login,login,redirect-to-rstudio,vanilla-embed' WHERE  `user_rules`.`id` =22;

-- changes on 30 03 2016
UPDATE  `elearning_v5`.`user_rules` SET  `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports' WHERE  `user_rules`.`id` =25;

-- RSTUDIO CR changes on 03 05 2016
ALTER TABLE  `users` ADD  `rstudio_username` VARCHAR( 255 ) NULL AFTER  `password` ;


-- CHANGES FOR P6 STARTED ON 17th May 2016
ALTER TABLE  `problem_sets` ADD  `ps_type` TINYINT NULL DEFAULT  '1' COMMENT  '1=Plain Vanilla, 2=Exam, 3= DI-P, 4=DI-H, 5=DI-M, 6=DI-L' AFTER  `type` ;
ALTER TABLE  `problem_sets` ADD  `di_number` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT  'DI problem set Unique Number' AFTER  `unique_number` ;
UPDATE  `user_rules` SET  `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set' WHERE  `user_rules`.`id` =14;


--
-- Table structure for table `di_problem_sets`
--

CREATE TABLE IF NOT EXISTS `di_problem_sets_rules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `problem_sets_id` int(11) NOT NULL COMMENT 'problem sets id',
  `ps_high_id` int(11) DEFAULT NULL COMMENT 'ps type high',
  `ps_mid_id` int(11) DEFAULT NULL COMMENT 'ps type mid',
  `ps_low_id` int(11) DEFAULT NULL COMMENT 'ps type low',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='DI PROBLEM SETS RULES' AUTO_INCREMENT=1 ;

ALTER TABLE `di_problem_sets_rules` ADD  FOREIGN KEY (`problem_sets_id`) REFERENCES `problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `di_problem_sets_rules` ADD  FOREIGN KEY (`ps_high_id`) REFERENCES `problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `di_problem_sets_rules` ADD  FOREIGN KEY (`ps_mid_id`) REFERENCES `problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `di_problem_sets_rules` ADD  FOREIGN KEY (`ps_low_id`) REFERENCES `problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE  `di_problem_sets_rules` CHANGE  `problem_sets_id`  `ps_primary_id` INT( 11 ) NOT NULL COMMENT  'problem sets id';
ALTER TABLE `di_problem_sets_rules` ADD  FOREIGN KEY (`ps_primary_id`) REFERENCES `elearning_v6`.`problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

ALTER TABLE  `di_problem_sets_rules` ADD  `selected_option` TINYINT NOT NULL COMMENT  '2= 2 options choose, 3=3 options choose' AFTER  `ps_primary_id` ;
ALTER TABLE  `di_problem_sets_rules` ADD  `min_cutoff` INT NOT NULL AFTER  `selected_option` ,ADD  `max_cutoff` INT NOT NULL AFTER  `min_cutoff` ;
ALTER TABLE  `problem_sets` CHANGE  `ps_type`  `ps_type` TINYINT( 4 ) NULL DEFAULT  '1' COMMENT  '1=Plain Vanilla, 2= DI-P, 3=DI-H, 4=DI-M, 5=DI-L';
ALTER TABLE  `problem_sets` CHANGE  `ps_type`  `ps_type` TINYINT( 4 ) NULL DEFAULT  '1' COMMENT  '1=Plain Vanilla, 2= DI';
ALTER TABLE  `di_problem_sets_rules` ADD  `problem_sets_id` INT NOT NULL COMMENT  'PS id' AFTER  `id` ;
ALTER TABLE  `di_problem_sets_rules` ADD INDEX (  `problem_sets_id` ) ;
ALTER TABLE `di_problem_sets_rules` ADD  FOREIGN KEY (`problem_sets_id`) REFERENCES `elearning_v6`.`problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit' WHERE `user_rules`.`id` = 14;


-- Changes on M-2 24th Jun'16 For assign DI secondary PS
--
-- Table structure for table `di_problem_sets_temp_assign`
--

CREATE TABLE IF NOT EXISTS `di_problem_sets_temp_assign` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `di_problem_sets_rules_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Assign DI secondary ps temporary' AUTO_INCREMENT=1 ;
ALTER TABLE  `di_problem_sets_temp_assign` ADD INDEX (  `di_problem_sets_rules_id` ) ;
ALTER TABLE `di_problem_sets_temp_assign` ADD  FOREIGN KEY (`di_problem_sets_rules_id`) REFERENCES `elearning_v6`.`di_problem_sets_rules`(`id`) ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE  `di_problem_sets_temp_assign` ADD  `assign_type` TINYINT NOT NULL DEFAULT  '0' COMMENT  '0=Linear,1=Random';
ALTER TABLE  `di_problem_sets_temp_assign` ADD  `students_assignment_id` INT NOT NULL AFTER  `di_problem_sets_rules_id` ;
ALTER TABLE  `di_problem_sets_temp_assign` CHANGE  `students_assignment_id`  `teachers_st_ass_id` INT( 11 ) NOT NULL ;
ALTER TABLE  `di_problem_sets_temp_assign` ADD  `teachers_st_ps_id` INT NOT NULL AFTER  `di_problem_sets_rules_id` ;
ALTER TABLE  `di_problem_sets_temp_assign` ADD INDEX (  `teachers_st_ps_id` ) ;
ALTER TABLE `di_problem_sets_temp_assign` ADD  FOREIGN KEY (`teachers_st_ps_id`) REFERENCES `elearning_v6`.`teachers_students_problem_sets`(`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'assignment-report-for-students,get-question-content,snapshot-reports' WHERE `user_rules`.`id` = 41;
ALTER TABLE  `di_problem_sets_temp_assign` DROP  `teachers_st_ass_id` ;
ALTER TABLE  `di_problem_sets_temp_assign` ADD INDEX (  `teachers_st_ps_id` ) ;
ALTER TABLE  `di_problem_sets_temp_assign` CHANGE  `teachers_st_ps_id`  `teachers_st_ps_id` BIGINT NOT NULL ;
ALTER TABLE `di_problem_sets_temp_assign` ADD  FOREIGN KEY (`teachers_st_ps_id`) REFERENCES `elearning_v6`.`teachers_students_problem_sets`(`id`) ON DELETE CASCADE ON UPDATE NO ACTION;

-- FOR Assigned Problem Set List
ALTER TABLE `teachers_students_problem_sets`  ADD `ps_type` INT NULL DEFAULT '1' COMMENT '1=Plain Vanilla, 2= DI-P, 3=DI-H, 4=DI-M, 5=DI-L, 6=EX' AFTER `due_date`,  ADD `di_number` VARCHAR(255) NULL AFTER `ps_type`;

-- For paper mode
ALTER TABLE  `teachers_students_problem_sets` CHANGE  `mode`  `mode` TINYINT( 4 ) NOT NULL COMMENT  '0=test, 1=tutor, 2=Paper';

UPDATE  `elearning_v6`.`user_rules` SET  `privileges_actions` = 'enroll-students,enroll-class,enroll-section,assignments,take-assignment,hints-updation,question-attempt,report,check-answers,question-completion,assignment-completion,paper-test' WHERE  `user_rules`.`id` =19;

ALTER TABLE `teachers_students_problem_sets`  ADD `report_options` TINYINT(1) NULL COMMENT '1=show reports once finished,2=delayed report' AFTER `di_number`,  ADD `report_release_time` DATETIME NULL AFTER `report_options`;

-- Phase-7

UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'index,logout,change-password,change-status,change-user-status,download-teachers-data,download-students-data,download-problem-set-data' WHERE `user_rules`.`id` = 1;

UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'change-password,index,create,update,delete,auto-generate-password,pending-teachers,teachers-index,teachers-info,student-index,student-info,change-user-status,teacher-status,user-information,view,super-admin-index,create-super-admin,super-admin-delete,login-as-teacher-student,teacher-view,student-view,resend' WHERE `user_rules`.`id` = 7;

-- DEV queries 
CREATE TABLE IF NOT EXISTS `ml_problem_sets_rules` (
`id` int(11) NOT NULL COMMENT 'PS id',
  `problem_sets_id` int(11) NOT NULL COMMENT 'problem sets id',
  `ps_primary_id` int(11) NOT NULL,
  `ema_length` int(11) NOT NULL COMMENT 'Exponential Moving Average Length(5-­10)',
  `average` int(11) NOT NULL COMMENT 'EMA Threshold'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


ALTER TABLE `ml_problem_sets_rules`
 ADD PRIMARY KEY (`id`), ADD KEY `problem_sets_id` (`problem_sets_id`), ADD KEY `ps_primary_id` (`ps_primary_id`);

 ALTER TABLE `ml_problem_sets_rules`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'PS id';

/*ALTER TABLE `ml_problem_sets_rules`
ADD CONSTRAINT `ml_problem_sets_rules_ibfk_8` FOREIGN KEY (`ps_primary_id`) REFERENCES `problem_sets` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `ml_problem_sets_rules_ibfk_7` FOREIGN KEY (`problem_sets_id`) REFERENCES `problem_sets` (`id`) ON DELETE CASCADE;*/

ALTER TABLE `ml_problem_sets_rules` ADD CONSTRAINT `ml_problem_sets_rules_ibfk_7` FOREIGN KEY (`problem_sets_id`) REFERENCES `elearning_v6`.`problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT; ALTER TABLE `ml_problem_sets_rules` ADD CONSTRAINT `di_problem_sets_rules_ibfk_8` FOREIGN KEY (`ps_primary_id`) REFERENCES `elearning_v6`.`problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

ALTER TABLE `ml_problem_sets_rules` DROP FOREIGN KEY `di_problem_sets_rules_ibfk_8`;
ALTER TABLE `ml_problem_sets_rules` ADD  CONSTRAINT `ml_problem_sets_rules_ibfk_8` FOREIGN KEY (`ps_primary_id`) REFERENCES `elearning_v6`.`problem_sets`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `problem_sets` CHANGE `ps_type` `ps_type` TINYINT(4) NULL DEFAULT '1' COMMENT '1=Plain Vanilla, 2= DI,3=ML';

UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit' WHERE `user_rules`.`id` = 14;
-- DEV queries

=====================1-12-2016====================================================================
ALTER TABLE `students_assignments` ADD `ema_length` INT(11) NULL DEFAULT '0' AFTER `total_time`;

===================9-12-2016======================================================================
UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students' WHERE `user_rules`.`id` = 25;

===================13-12-2016==================================================================
UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'assignment-report-for-students,get-question-content,snapshot-reports,individual-reports' WHERE `user_rules`.`id` = 41;

=================15-12-2016====================================================================
UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports' WHERE `user_rules`.`id` = 25;

UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'assignment-report-for-students,get-question-content,snapshot-reports,individual-reports,generate-file-individual-reports' WHERE `user_rules`.`id` = 41;
=================29-12-2016=======================================================================
ALTER TABLE `teachers_students_problem_sets` CHANGE `ps_type` `ps_type` INT(11) NULL DEFAULT '1' COMMENT '1=Plain Vanilla, 2= DI-P, 3=DI-H, 4=DI-M, 5=DI-L, 6=EX,7=ML';

ALTER TABLE `teachers_students_problem_sets` ADD `unique_number` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `classes_id`;

===================5-1-2017========================================================================
UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'index,change-password,logout,pages,change-status,varification-email,contact,vanilla-authenticate,redirect-to-vanilla,frontend-user-login,search,feature-page,search-data,blog,post-details,search-tutorial-pages,rstudio-login,login,redirect-to-rstudio,vanilla-embed,search-student-names' WHERE `user_rules`.`id` = 22;
===================16-1-2017=======================================================================
ALTER TABLE `students_assignments_log` ADD `ema_length` INT(11) NULL DEFAULT '0' AFTER `score`;

=======================Track Template 27/03/2017=======================================================================

CREATE TABLE IF NOT EXISTS `track_questions` (
`id` int(11) NOT NULL,
  `question_id` int(11) DEFAULT NULL,
  `template_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


ALTER TABLE `track_questions`
 ADD PRIMARY KEY (`id`), ADD KEY `question_id` (`question_id`,`template_id`), ADD KEY `template_id` (`template_id`);

 ALTER TABLE `track_questions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;


ALTER TABLE `track_questions`
ADD CONSTRAINT `template_id_foreign` FOREIGN KEY (`template_id`) REFERENCES `templates` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;


UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'index,logout,change-password,change-status,change-user-status,download-teachers-data,download-students-data,download-problem-set-data,download-track-questions-data' WHERE `user_rules`.`id` = 1;

=============Tutorial Page===========================================================================
====statics tutorial page=============================================================================================
INSERT INTO `elearning_v6`.`tutorial_pages` (`id`, `page_title`, `url_key`, `static_page`, `page_content`, `meta_title`, `meta_keyword`, `meta_description`, `status`, `created_at`, `updated_at`) VALUES (NULL, 'Statistics Help Pages FrontEnd', 'statistics-tutorials-frontend', '1', '<p>STATISTICS HELP PAGES</p>

<div class="portlet light">
<div class="portlet-body">
<div class="panel-group accordion" id="accordion1"><!-- START TAB -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_10">Graphing and Summarizing Data </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_10">
<div class="panel-body">
<table border="1" cellpadding="5" cellspacing="0" style="width:100%;">
  <tbody>
    <tr>
      <td style="width: 50%; border-color: rgb(204, 204, 204);">Topic</td>
    </tr>
    <tr>
      <td style="border-color: rgb(204, 204, 204);"><a class="btn blue btn-sm" href="http://www.boston.com/" target="_blank">Linear Regression - Basic </a></td>
    </tr>
    <tr>
      <td style="border-color: rgb(204, 204, 204);">111</td>
    </tr>
    <tr>
      <td style="border-color: rgb(204, 204, 204);">seven</td>
    </tr>
  </tbody>
</table>
</div>
</div>
</div>
<!-- START/END TAB -->

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><span style="display: none;">&nbsp;</span><span style="display: none;">&nbsp;</span><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_20">Normal Distribution </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_20">
<div class="panel-body" style="overflow-y:auto;">
<table border="1" cellpadding="5" cellspacing="0" style="line-height: 20.8px; width: 817px;">
  <tbody>
    <tr>
      <td style="width: 805px; border-color: rgb(204, 204, 204);">Topic</td>
    </tr>
    <tr>
      <td style="border-color: rgb(204, 204, 204);"><a class="btn blue btn-sm" href="http://www.boston.com/" target="_blank">Linear Regression - Basic</a></td>
    </tr>
    <tr>
      <td style="border-color: rgb(204, 204, 204);">four</td>
    </tr>
    <tr>
      <td style="border-color: rgb(204, 204, 204);">seven</td>
    </tr>
  </tbody>
</table>
</div>
</div>
</div>
<!-- START/END TAB -->

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_30">Linear Regression </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_30">
<div class="panel-body">
<p>Text THREE Here .....</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_40">Non-Linear Regression </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_40">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_50">Surveys &amp; Experiments </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_50">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_60">Probability </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_60">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_70">Random Variables </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_70">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_80">Binomial &amp; Geometric Distributions </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_80">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_90">Sampling Distributions </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_90">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_100">Hypothesis Testing </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_100">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_110">Inference for Means </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_110">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_120">Inference for Proportions</a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_120">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a class="accordion-toggle" data-parent="#accordion1" data-toggle="collapse" href="#collapse_130">Chi-Square </a></h4>
</div>

<div class="panel-collapse collapse" id="collapse_130">
<div class="panel-body">
<p>Text FOUR Here ...</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END ACCORDIAN ALL INFORMATION -->

<table cellpadding="2">
  <tbody>
    <tr>
      <td style="vertical-align: top;">
      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Numerical Measures &amp; Graphics</strong><br />
      Measures of Center<br />
      Standard Deviation &ndash; Measures of Spread<br />
      Percentiles &ndash;&nbsp;Quartiles &ndash; IQR &ndash; 5 Number Summary<br />
      Boxplots<br />
      Histograms<br />
      Stem-And-Leaf<br />
      Ogive Plots<br />
      Describing Distributions</span></span></p>

      <p><strong><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;">Technology</span></span></strong><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><span style="line-height: 22.4px;">TI - Calculating Numerical Summaries</span><br style="font-family: verdana, geneva, sans-serif; font-size: 14px; line-height: 22.4px;" />
      <span style="line-height: 22.4px;">TI - Boxplot and Histograms</span></span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;">R - Calculating Numerical Summaries</span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;">R - Histograms</span></span><br />
      <span style="font-family:verdana,geneva,sans-serif;"><span style="font-size:14px;">R - Boxplots</span></span><br />
      <span style="font-family:verdana,geneva,sans-serif;">R -&nbsp;<span style="font-size: 14px; line-height: 22.4px;">Stem-And-Leaf</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Normal Distribution</strong><br />
      Intro To the Normal<br />
      Constructing the Normal Density Curve<br />
      Using the z-table<br />
      Emperical Rule Link<br />
      TI - Normal Distribution Calculations</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;">R - Normal Distribution Calculations<br />
      Assessing Normality<br />
      Normal Distribution &ndash; Solving for x</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Linear Regression</strong><br />
      Scatterplots<br />
      Correlation<br />
      Fitting Linear Model (TI-83 or R)<br />
      Assumptions for using Linear Regression<br />
      Residuals &amp; Residual Plots<br />
      Outliers and Influential Observations<br />
      Inference &ndash; Linear Regression<br />
      Confidence Interval &ndash; Linear Regression<br />
      Animation &ndash; Confidence Interval Linear Regression<br />
      Hypothesis Test &ndash; Linear Regression<br />
      Interpreting Linear Regression Computer Output<br />
      Linear Regression &ndash; Formula Calculations</span></span></p>
      </td>
      <td style="vertical-align: top;">
      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Non-Linear Regression</strong><br />
      *&nbsp;Exponential Growth<br />
      *&nbsp;Power Law</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Design of Experiments &amp; Surveys</strong><br />
      *&nbsp;Using table of Random Digits<br />
      *&nbsp;Designing an Experiment</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Probability</strong><br />
      Probability Rules<br />
      P(A or B)<br />
      P(A &amp; B)<br />
      Bayes Theorem</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Discrete and Continuous Random Variables</strong><br />
      *&nbsp;Difference between Discrete &amp; Continuous<br />
      *&nbsp;Density Curves<br />
      *&nbsp;Calculating the Mean &amp; SD of Discrete RV&rsquo;s<br />
      *&nbsp;Rules for means and variances</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Binomial &amp; Geometric Distributions</strong><br />
      Binomial Distribution<br />
      Binomial Distribution &ndash; CDF Function<br />
      Normal Approximation &ndash; Binomial Distribution<br />
      Geometric Distribution</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Sampling Distributions</strong><br />
      *&nbsp;Difference Between Statistics and Parameters<br />
      *&nbsp;Sample proportions<br />
      *&nbsp;Sample means<br />
      *&nbsp;Central Limit Theorem Animation<br />
      *&nbsp;Sampling Animation &ndash; Only Normal Data<br />
      *&nbsp;Biased and Unbiased Estimators</span></span></p>
      </td>
      <td style="vertical-align: top;">
      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Inference</strong><br />
      Introduction to Hypothesis Testing<br />
      Relationship Between P-value and Conclusion<br />
      Type 1 and Type 2 Errors &ndash; Hypothesis Testing</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;">1 Sample Mean<br />
      Confidence Interval &ndash; 1 Proportion<br />
      Confidence Interval &ndash;&nbsp;1 Sample Mean w/ Sigma<br />
      Reading the t-table &ndash; z*<br />
      Confidence Interval &ndash; 1 Sample Mean w/o Sigma<br />
      t-distribution<br />
      Reading the t-table &ndash; t*<br />
      Confidence Interval &ndash; Difference of Means<br />
      Confidence Interval &ndash; Matched Pairs<br />
      Confidence Interval &ndash; Difference of Proportions<br />
      Sample Size Calculation &ndash; 1 Proportion<br />
      Sample Size Calculation &ndash; 1 Sample Mean<br />
      Hypothesis Test &ndash; Conclusion<br />
      Hypothesis Test &ndash; 1 Sample Mean w/Sigma<br />
      Hypothesis Test &ndash; 1 Sample Mean w/o Sigma<br />
      Hypothesis Test &ndash; Difference of Means<br />
      Hypothesis Test &ndash; Matched Pairs<br />
      Hypothesis Test &ndash; 1 Proportion<br />
      Hypothesis Test &ndash; 2 Proportions<br />
      Hypothesis Test &ndash; Chi-Square<br />
      Chi-Square Distribution<br />
      Chi-Square &ndash; Goodness of Fit</span></span></p>
      </td>
    </tr>
  </tbody>
</table>
', 'Statistics Help Pages Frontend', 'Statistics Help Pages Frontend', 'Statistics Tutorials Page Frontend- updated
', '1', '2015-06-11 00:00:00', NULL);


INSERT INTO `elearning_v6`.`user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '36', '36', 'Statistics Tutorials Page Frontend', '', 'tutorial-pages/update/statistics-tutorials-frontend', '2', '1');

INSERT INTO `elearning_v6`.`user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '47', '37', 'Statistics Tutorials Page Frontend', '', 'tutorial-pages/update/statistics-tutorials-frontend', '2', '1');
====r tutorial page=============================================================================================
INSERT INTO `elearning_v6`.`tutorial_pages` (`id`, `page_title`, `url_key`, `static_page`, `page_content`, `meta_title`, `meta_keyword`, `meta_description`, `status`, `created_at`, `updated_at`) VALUES (NULL, 'R Help Page Frontend', 'r-tutorials-frontend', '1', '<p><span style="font-family:verdana,geneva,sans-serif;"><span style="font-size:16px;"><strong>R HELP PAGES</strong></span></span></p>

<hr />
<table style="width: 100%;">
  <tbody>
    <tr>
      <td style="width: 25%; vertical-align: top;">
      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>OVERVIEW</strong><br />
      <a href="http://localhost/elearning_v4/intro-to-rstudio">Introduction to RStudio</a></span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>WORKING WITH DATA</strong><br />
      <a href="http://localhost/elearning_v4/r-math-functions">Math Functions</a><br />
      <a href="http://localhost/elearning_v4/r-entering-data">Entering Data</a><br />
      <a href="http://localhost/elearning_v4/r-statistical-functions">Statistical Functions</a></span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><a href="http://www.stats4stem.org/r-vector-arithmetic">Vector Arithmetic</a><br />
      <span style="line-height: 20.8px;">Indexing and Subsetting</span></span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><a href="http://stats4stem.org/r-sampling-simulation"><span style="line-height: 20.8px;">Sampling</span></a><br style="line-height: 20.8px;" />
      <a href="http://localhost/elearning_v4/r-data-frame"><span style="line-height: 20.8px;">Data Frames</span></a><br style="line-height: 20.8px;" />
      <a href="http://localhost/elearning_v4/r-matrices-and-matrix-computations"><span style="line-height: 20.8px;">Matrices and Matrix Computations</span></a><br style="line-height: 20.8px;" />
      <span style="line-height: 20.8px;">Chi-square Distribution</span></span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Working With Google Drive</strong></span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;">Uploading Google Sheets Dataset</span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;">Uploading RStudio Graphics&nbsp;to Google Docs</span></span></p>
      </td>
      <td style="width: 25%; vertical-align: top;">
      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Basic&nbsp;Graphics</strong><br />
      Bar and Pie Charts<br />
      <a href="http://www.stats4stem.org/r-stem-and-leaf">Stem-and-Leaf</a><br />
      <a href="http://www.stats4stem.org/r-histogram">Histograms</a><br />
      <a href="http://www.stats4stem.org/r-boxplots"><span style="line-height: 20.8px;">Boxplots</span></a><br />
      <a href="http://www.stats4stem.org/r-scatterplot" style="line-height: 20.8px;">Scatterplots</a></span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong style="font-family: verdana, geneva, sans-serif; font-size: 14px; line-height: 22.4px;">Advanced Graphics</strong></span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><a href="http://www.stats4stem.org/r-colors">Colors</a></span></span><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><a href="http://www.stats4stem.org/r-points-symbols">Points and Symbols</a><br />
      <span style="line-height: 20.8px;">Lines</span><br style="line-height: 20.8px;" />
      Axis, Text, and Legends<br style="line-height: 20.8px;" />
      <a href="http://www.stats4stem.org/r-categorical-scatterplots-legends"><span style="line-height: 20.8px;"><span style="font-family: verdana, geneva, sans-serif; font-size: 14px; line-height: 22.4px;">Categorical Scatterplots and Legends</span></span></a><br style="line-height: 20.8px;" />
      <a href="http://stats4stem.org/r-multiple-plot-layout"><span style="line-height: 20.8px;">Multiple Plot Layout</span></a></span></span></p>
      </td>
      <td style="width: 25%; vertical-align: top;">
      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Distributions</strong><br />
      <a href="http://www.stats4stem.org/r-normal-distribution">Normal Distribution</a><br style="line-height: 20.8px;" />
      <span style="line-height: 20.8px;">Uniform Distribution</span><br />
      <span style="line-height: 20.8px;"><a href="http://www.stats4stem.org/r-binomial-distribution"><span style="line-height: 20.8px;">Binomial Distribution</span></a></span><br style="line-height: 20.8px;" />
      <a href="http://www.stats4stem.org/r-t-distribution"><span style="line-height: 20.8px;">t Distribuion</span></a><br />
      <a href="http://stats4stem.org/r-chi-square-distribution">Chi-square Distribution</a></span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><b>Linear Regression</b><br />
      <a href="http://www.stats4stem.org/r-scatterplot" target="_blank">Scatterplots</a><br />
      <a href="http://www.stats4stem.org/linear-regression-basic">Linear Regression - Basic</a><br />
      Linear Regression - Inference</span></span></p>

      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><b style="line-height: 20.8px;">Nonlinear Regression</b><br style="line-height: 20.8px;" />
      <a href="http://www.stats4stem.org/r-nonlinear-exponential-growth-model">Exponential Growth</a><br style="line-height: 20.8px;" />
      <a href="http://www.stats4stem.org/r-nonlinear-power-law-model"><span style="line-height: 20.8px;">Power Law</span></a></span></span></p>
      </td>
      <td style="width: 25%; vertical-align: top;">
      <p><span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><strong>Inference</strong></span></span><br />
      <a href="http://www.stats4stem.org/r-one-sample-mean-sigma"><span style="font-family: ''Open Sans'', sans-serif; font-size: 14px; line-height: 20.8px;">One Sample Mean -&nbsp;<span style="color: rgb(0, 0, 0); font-family: Times; font-size: medium; line-height: normal;">&sigma;</span></span></a><br />
      <span style="font-size:14px;"><span style="font-family:verdana,geneva,sans-serif;"><span style="font-family: ''Open Sans'', sans-serif; line-height: 20.8px;"><a href="http://www.stats4stem.org/r-one-proportion">One Proportion</a>&nbsp;</span><br style="box-sizing: border-box; color: rgb(0, 0, 0); font-family: ''Open Sans'', HelveticaNeue, ''Helvetica Neue'', Helvetica, Arial, sans-serif; font-size: 12.96px; line-height: 19.44px;" />
      <span style="font-family: ''Open Sans'', sans-serif; line-height: 20.8px;"><a href="http://www.stats4stem.org/r-one-sample-mean-s">One Sample Mean - s</a>&nbsp;</span><br style="box-sizing: border-box; color: rgb(0, 0, 0); font-family: ''Open Sans'', HelveticaNeue, ''Helvetica Neue'', Helvetica, Arial, sans-serif; font-size: 12.96px; line-height: 19.44px;" />
      <a href="http://www.stats4stem.org/r-matched-pairs"><span style="font-family: ''Open Sans'', sans-serif; font-size: 14px; line-height: 20.8px;">Matched Pairs</span></a><br style="box-sizing: border-box; color: rgb(0, 0, 0); font-family: ''Open Sans'', HelveticaNeue, ''Helvetica Neue'', Helvetica, Arial, sans-serif; font-size: 12.96px; line-height: 19.44px;" />
      <a href="http://www.stats4stem.org/r-difference-of-means"><span style="font-family: ''Open Sans'', sans-serif; line-height: 20.8px;">Difference of Means</span></a><br style="box-sizing: border-box; color: rgb(0, 0, 0); font-family: ''Open Sans'', HelveticaNeue, ''Helvetica Neue'', Helvetica, Arial, sans-serif; font-size: 12.96px; line-height: 19.44px;" />
      <a href="http://www.stats4stem.org/r-difference-of-proportions"><span style="font-family: ''Open Sans'', sans-serif; line-height: 20.8px;">Difference of Proportions</span></a><br style="box-sizing: border-box; color: rgb(0, 0, 0); font-family: ''Open Sans'', HelveticaNeue, ''Helvetica Neue'', Helvetica, Arial, sans-serif; font-size: 12.96px; line-height: 19.44px;" />
      <span style="font-family: ''Open Sans'', sans-serif; line-height: 20.8px;"><a href="http://stats4stem.org/r-chi-square-hypothesis-testing">Chi-Square</a>&nbsp;</span></span></span></p>
      </td>
    </tr>
  </tbody>
</table>', 'R Help Page Frontend', 'R Help Page Frontend', 'R Tutorials Page Frontend', '1', '2015-06-11 00:00:00', NULL);

INSERT INTO `elearning_v6`.`user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '36', '36', 'R Tutorials Page Frontend', '', 'tutorial-pages/update/r-tutorials-frontend', '3', '1');

INSERT INTO `elearning_v6`.`user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '47', '37', 'R Tutorials Page Frontend', '', 'tutorial-pages/update/r-tutorials-frontend', '3', '1');
===============================Quick Edit Permission for admin and super admin ==========================================
UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit' WHERE `user_rules`.`id` = 5;
UPDATE `elearning_v6`.`user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit' WHERE `user_rules`.`id` = 6;



=======================P8 mysql chnages===================================================================================================================================================================================================================================

==Moving Settings Tab==========================
UPDATE `elearning_v8`.`user_rules` SET `privileges_actions` = 'index,create,update,delete,set-dates,class-progress,assignmnt-report,problem-set-report-by-assignments,student-progress,assignment-list,manage-tabs,settings' WHERE `user_rules`.`id` = 24;

===CHANGE  “Assigned Problem Set”=============
UPDATE `elearning_v8`.`user_rules` SET `privileges_actions` = 'index,create,update,delete,set-dates,class-progress,assignmnt-report,problem-set-report-by-assignments,student-progress,assignment-list,manage-tabs,settings,edit' WHERE `user_rules`.`id` = 24;

ALTER TABLE `students_assignments_answers` CHANGE `freetext_answer` `freetext_answer` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

-- Timezones
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'time-zonesController', 'index,create,update,delete', 'allow', NULL), (NULL, '2', 'time-zonesController', 'index,create,update,delete', 'allow', NULL);
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '52', 'Time Zones', 'fa fa-clock-o', 'time-zones/index', '13', '1'), (NULL, 'admin', '0', '53', 'Time Zones', 'fa fa-clock-o', 'time-zones/index', '13', '1');

-- Tut pages
ALTER TABLE `tutorial_pages` ADD `allowed_search_for` TINYINT NOT NULL DEFAULT '0' AFTER `meta_description`; 

ALTER TABLE `tutorial_pages` CHANGE `allowed_search_for` `allowed_search_for` VARCHAR(255) NULL DEFAULT NULL; 

-- CREATE QUESTIONS AND PROBLEM SETS FOR TEACHERS
UPDATE `user_rules` SET `privileges_actions` = 'index,change-password,logout,pages,change-status,varification-email,contact,vanilla-authenticate,redirect-to-vanilla,frontend-user-login,search,feature-page,search-data,blog,post-details,search-tutorial-pages,rstudio-login,login,redirect-to-rstudio,vanilla-embed,search-student-names,resources,questions-problemsets' WHERE `user_rules`.`id` = 22; 
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'QuestionsController', 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit', 'allow', 'Teacher'); 

UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create' WHERE `user_rules`.`id` = 14; 

/* updated by pragnesh */
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'QuestionsController', 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit', 'allow', 'teacher');
UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create,migrate-all-questions,' WHERE `user_rules`.`id` = 14;

/* Change Problem Set Type Text on 16082018 */
UPDATE `problem_types` SET `type` = 'Algebra (Numeric Answer)' WHERE `problem_types`.`id` = 1;
UPDATE `problem_types` SET `type` = 'Multiple Choice' WHERE `problem_types`.`id` = 2;
UPDATE `problem_types` SET `type` = 'Check All That Apply' WHERE `problem_types`.`id` = 3;
UPDATE `problem_types` SET `type` = 'Fill-In' WHERE `problem_types`.`id` = 4;


--Grading Report

UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report' WHERE `user_rules`.`id` = 25;

ALTER TABLE `students_assignments_details` ADD `teachers_feedback` TEXT NULL DEFAULT NULL AFTER `score`;

UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report,update-teacher-feedback' WHERE `user_rules`.`id` = 25;

-- PP PC ISSUE ON 31072018

-- Learning block
INSERT INTO `problem_types` (`id`, `type`, `slug`) VALUES (NULL, 'Learning Block', 'lb'); 

-- SECTION LOCK / UNLOCK
ALTER TABLE `classes_sections` ADD `is_locked` TINYINT NOT NULL DEFAULT '0' COMMENT '0 = open, 1=locked' AFTER `status`; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,update-lock-status' WHERE `user_rules`.`id` = 20; 

-- 18-10-2018 - Hints from server
UPDATE `user_rules` SET `privileges_actions` = 'enroll-students,enroll-class,enroll-section,assignments,take-assignment,hints-updation,question-attempt,report,check-answers,question-completion,assignment-completion,paper-test,get-hints-by-question-in-tutor-ass' WHERE `user_rules`.`id` = 19; 
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'StudentsController', 'get-hints-by-question-in-tutor-ass', 'allow', 'teacher'); 


-- LA
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '9', 'Learning Assignment', 'icon-question', 'problem-sets/index', '6', '1'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '10', 'Learning Assignment', 'icon-question', 'problem-sets/index', '6', '1'); 
UPDATE `user_rules_menu` SET `url` = 'problem-sets/la/index' WHERE `user_rules_menu`.`id` = 71; 
UPDATE `user_rules_menu` SET `url` = 'problem-sets/la/index' WHERE `user_rules_menu`.`id` = 70; 

ALTER TABLE `problem_sets` ADD `is_LA` TINYINT NOT NULL DEFAULT '0' COMMENT '0=PS, 1=LA' AFTER `ps_type`; 

-- NEW COPY - TUTORIAL PAGES
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,check-tutorial-pages-url-key,new-copy' WHERE `user_rules`.`id` = 36; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,check-tutorial-pages-url-key,new-copy' WHERE `user_rules`.`id` = 37; 

-- LA NUMBER FIELD
ALTER TABLE `problem_sets` ADD `LA_number` VARCHAR(255) NULL DEFAULT NULL AFTER `di_number`; 

--LA 2
ALTER TABLE `teachers_students_problem_sets` CHANGE `mode` `mode` TINYINT(4) NOT NULL COMMENT '0=test, 1=tutor, 2=Paper, 3=LA'; 
UPDATE `user_rules` SET `privileges_actions` = 'enroll-students,enroll-class,enroll-section,assignments,take-assignment,hints-updation,question-attempt,report,check-answers,question-completion,assignment-completion,paper-test,get-hints-by-question-in-tutor-ass,la-test' WHERE `user_rules`.`id` = 19; 

UPDATE `user_rules_menu` SET `label` = 'Lessons' WHERE `user_rules_menu`.`id` = 71; 
UPDATE `user_rules_menu` SET `label` = 'Lessons' WHERE `user_rules_menu`.`id` = 70; 

--Teacher TimeZone Set Permission Query 19-04-2019
ALTER TABLE `users` ADD `time_zone_id` INT NULL AFTER `unique_timestamp`; 
UPDATE `user_rules` SET `privileges_actions` = 'set-teachers-settings,set-time-zone' WHERE `user_rules`.`id` = 35;
--UPDATE PROBLEM SET TABLE LA_number Field
UPDATE `problem_sets` SET `LA_number` = REPLACE(`LA_number`, '#LN-', '#LSN-') WHERE `LA_number` LIKE ('#LN-%');
-- STUDENT REPORT ISSUES PERMISSION
UPDATE `user_rules` SET `privileges_actions` = 'index,change-password,logout,pages,varification-email,contact,frontend-user-login,search,feature-page,search-data,blog,post-details,search-tutorial-pages,rstudio-login,login,resources,reports-issues' WHERE `user_rules`.`id` = 23;

-- ADMIN EXPORT QUESTION ISSUES CSV --
UPDATE `user_rules` SET `privileges_actions` = 'index,logout,change-password,change-status,change-user-status,download-teachers-data,download-students-data,download-problem-set-data,download-track-questions-data,download-registration-data,download-track-template-questions-data,download-questions-issues' WHERE `user_rules`.`id` = 1;

-- Teacher Question Issues Report Listing --
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'Question-Error-ReportingController', 'index', 'allow', 'teacher');

-- STUDENT Question Issues Report Listing --
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '4', 'Question-Error-ReportingController', 'reports-issues', 'allow', 'Student');

--
-- Table structure for table `question_error_reporting`
--

CREATE TABLE `question_error_reporting` (
  `id` int(11) NOT NULL,
  `user_id` bigint(20) NOT NULL,
  `teachers_students_assignments_id` int(11) NOT NULL,
  `questions_id` int(11) NOT NULL,
  `reason` int(11) NOT NULL,
  `freeResponse` text,
  `created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `question_error_reporting`
--
ALTER TABLE `question_error_reporting`
  ADD PRIMARY KEY (`id`),
  ADD KEY `userId` (`user_id`),
  ADD KEY `questionsId` (`questions_id`),
  ADD KEY `teachers_students_assignments_id` (`teachers_students_assignments_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `question_error_reporting`
--
ALTER TABLE `question_error_reporting`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

----- Timezone Update For Existing teachers ------
UPDATE `users` SET `time_zone_id`=379 WHERE role_id = '3' AND `time_zone_id` IS NULL;  
----- Teacher Question Manage Tabs -------------
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,manage-tabs' WHERE `user_rules`.`id` = 55;

----- Teacher Allowed tabs For tutorials -----------
UPDATE `user_rules` SET `privileges_actions` = 'set-teachers-settings,set-time-zone,manage-tutorials' WHERE `user_rules`.`id` = 35;
----- Teacher Question Manage Tabs -------------
UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create,migrate-all-questions,lesson-list,list' WHERE `user_rules`.`id` = 14; 
------ Students Hint Time Access ---------
UPDATE `user_rules` SET `privileges_actions` = 'enroll-students,enroll-class,enroll-section,assignments,take-assignment,hints-updation,question-attempt,report,check-answers,question-completion,assignment-completion,paper-test,get-hints-by-question-in-tutor-ass,la-test,hint-time' WHERE `user_rules`.`id` = 19;

-------- Teachers Courses Controller Access ----------

CREATE TABLE `courses` (
  `id` int(11) NOT NULL,
  `users_id` bigint(20) NOT NULL,
  `unique_number` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `created_date` datetime NOT NULL,
  `updated_date` datetime NOT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `courses`
--
ALTER TABLE `courses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `users` (`users_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `courses`
--
ALTER TABLE `courses`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
----------------------End Courses -----------------------  
-------------------- Courses Problem Sets --------------------

--
-- Table structure for table `courses_problem_sets`
--

CREATE TABLE `courses_problem_sets` (
  `id` int(11) NOT NULL,
  `courses_id` int(11) NOT NULL,
  `problem_sets_id` int(11) NOT NULL,
  `is_LA` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `courses_problem_sets`
--
ALTER TABLE `courses_problem_sets`
  ADD PRIMARY KEY (`id`),
  ADD KEY `problem_sets` (`problem_sets_id`),
  ADD KEY `courses_id` (`courses_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `courses_problem_sets`
--
ALTER TABLE `courses_problem_sets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `courses_problem_sets`
--
ALTER TABLE `courses_problem_sets`
  ADD CONSTRAINT `courses_problem_sets_ibfk_1` FOREIGN KEY (`courses_id`) REFERENCES `courses` (`id`) ON DELETE CASCADE;

ALTER TABLE `courses_problem_sets`
  ADD CONSTRAINT `problem_sets_ibfk_2` FOREIGN KEY (`problem_sets_id`) REFERENCES `problem_sets` (`id`) ON DELETE CASCADE;

------------------- Courses Controller access ----------------------------
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'CoursesController', 'index', 'allow', 'teacher');

----- Create Course ----------
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses' WHERE `user_rules`.`id` = 59; 

----- DI Problemsets duplicate row issues changes ----
ALTER TABLE `teachers_students_problem_sets` ADD `flags` INT NULL DEFAULT NULL AFTER `di_number`;
------------ Classes Controller ------
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,roster-view,change-section,reset-password,student-login,drop-student,ajax-section,ajax-assignmentlist,create-fake-student,ajax-students,get-ajax-section,get-ajax-class' WHERE `user_rules`.`id` = 13; 

--------------- date:07-08-2019 ----------------------
UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create,migrate-all-questions,lesson-list,list,lesson-plans' WHERE `user_rules`.`id` = 14;

-----------------------
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'lession-plans-notesController', 'index,create,update,delete,new-copy,test-drive,content-delete,view', 'allow', 'teacher'); 

------- Add course problem sets table new column
ALTER TABLE `courses_problem_sets` ADD `lession_plans_notes_id` BIGINT NOT NULL AFTER `is_LA`;
ALTER TABLE `courses_problem_sets` CHANGE `problem_sets_id` `problem_sets_id` INT(11) NULL, CHANGE `is_LA` `is_LA` INT(11) NULL DEFAULT '0'; 
ALTER TABLE `courses_problem_sets` CHANGE `lession_plans_notes_id` `lession_plans_notes_id` BIGINT(20) NULL;  

-------------------Lession plans & notes ------------

CREATE TABLE `lession_plans_notes` (
  `id` bigint(20) NOT NULL,
  `users_id` bigint(20) NOT NULL,
  `lpn_number` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `is_LPN` tinyint(4) NOT NULL DEFAULT '1',
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_date` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `lession_plans_notes`
--
ALTER TABLE `lession_plans_notes`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `lession_plans_notes`
--
ALTER TABLE `lession_plans_notes`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
-------------------Lession plans & notes ------------


CREATE TABLE `lession_plans_notes_options` (
  `id` bigint(20) NOT NULL,
  `lession_plans_id` bigint(20) NOT NULL,
  `content` text,
  `status` tinyint(4) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `lession_plans_notes_options`
--
ALTER TABLE `lession_plans_notes_options`
  ADD PRIMARY KEY (`id`),
  ADD KEY `lession_plans_id` (`lession_plans_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `lession_plans_notes_options`
--
ALTER TABLE `lession_plans_notes_options`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `lession_plans_notes_options`
--
ALTER TABLE `lession_plans_notes_options`
  ADD CONSTRAINT `lpn_ibfk_2` FOREIGN KEY (`lession_plans_id`) REFERENCES `lession_plans_notes` (`id`) ON DELETE CASCADE;
  -------------------Lession plans & notes options ------------
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn' WHERE `user_rules`.`id` = 59; 

------------------------------ 14-08-2019 ---------------------------------------
ALTER TABLE `lesson_plans_notes_options` CHANGE `lession_plans_id` `lesson_plans_id` BIGINT(20) NOT NULL; 

ALTER TABLE `courses_problem_sets` CHANGE `lession_plans_notes_id` `lesson_plans_notes_id` BIGINT(20) NULL DEFAULT NULL; 

UPDATE `user_rules` SET `privileges_controller` = 'lesson-plans-notesController' WHERE `user_rules`.`id` = 60; 

------------------------------ 02-09-2019 ------------------------------
INSERT INTO `problem_types` (`id`, `type`, `slug`) VALUES (NULL, 'Ungraded', 'un'); 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,test-drive,content-delete,view,notes' WHERE `user_rules`.`id` = 60; 
ALTER TABLE `lesson_plans_notes_options` ADD `title` TEXT NOT NULL AFTER `lesson_plans_id`; 
ALTER TABLE `lesson_plans_notes_options` CHANGE `title` `title` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; 

------------------------------- 16-09-2019 ------------------------------

CREATE TABLE `cms_page_accordions` (
  `id` int(11) NOT NULL,
  `pages_id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `content` longtext NOT NULL,
  `sequence` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `cms_page_accordion`
--
ALTER TABLE `cms_page_accordions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `pages` (`pages_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `cms_page_accordion`
--
ALTER TABLE `cms_page_accordions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;


UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,check-page-title,content-delete' WHERE `user_rules`.`id` = 3; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,check-page-title,content-delete' WHERE `user_rules`.`id` = 4; 

------------------- 18-09-2019 ---------------------------
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '4', 'QuestionsController', 'view', 'allow', 'student'); 

UPDATE `user_rules` SET `privileges_actions` = 'enroll-students,enroll-class,enroll-section,assignments,take-assignment,hints-updation,question-attempt,report,check-answers,question-completion,assignment-completion,paper-test,get-hints-by-question-in-tutor-ass,la-test,hint-time,lessons,view-lessons' WHERE `user_rules`.`id` = 19; 

--------------------- 19-09-2019 --------------------------
UPDATE `user_rules` SET `privileges_actions` = 'set-teachers-settings,set-time-zone,manage-tutorials,pre-built' WHERE `user_rules`.`id` = 35; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,learning-blocks' WHERE `user_rules`.`id` = 55; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks' WHERE `user_rules`.`id` = 54; 


---------------------- 20-09-2019 -------------------------
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'pre-builtController', 'index,create,update,delete,new-copy,view,check-tab-title,change-tab-order', 'allow', 'superadmin'); 
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'pre-builtController', 'index,create,update,delete,new-copy,view,check-tab-title,change-tab-order', 'allow', 'admin'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '62', 'Prebuilt Tab', 'fa fa-book', 'pre-built/index', '14', '1'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '63', 'Prebuilt Tab', 'fa fa-book', 'pre-built/index', '14', '1'); 

ALTER TABLE `cms_page_accordions` ADD `type` TINYINT NOT NULL DEFAULT '1' AFTER `sequence`; 
ALTER TABLE `cms_page_accordions` CHANGE `type` `type` TINYINT(4) NULL DEFAULT '1'; 



--
-- Table structure for table `pre_built_tabs`
--

CREATE TABLE `pre_built_tabs` (
  `id` int(11) NOT NULL,
  `tab_title` varchar(255) NOT NULL,
  `url_key` varchar(255) DEFAULT NULL,
  `position` int(11) DEFAULT NULL,
  `created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `pre_built_tabs`
--
ALTER TABLE `pre_built_tabs`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `pre_built_tabs`
--
ALTER TABLE `pre_built_tabs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

---------------- 21-09-2019 ---------------------------
UPDATE `user_rules` SET `privileges_actions` = 'set-teachers-settings,set-time-zone,manage-tutorials,pre-built,get-prebuilt-content' WHERE `user_rules`.`id` = 35; 


--------------- 26-09-2019 ------------------------------

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,migrate-all-questions,get-public-url,view-couple-problems' WHERE `user_rules`.`id` = 9; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,migrate-all-questions,get-public-url,view-couple-problems' WHERE `user_rules`.`id` = 10; 
UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create,migrate-all-questions,lesson-list,list,lesson-plans,view-couple-problems' WHERE `user_rules`.`id` = 14; 


----------------------------------- 27/09/2019 -----------------------
ALTER TABLE `questions` ADD `couple_problem_sets_id` INT NULL AFTER `questions_options_order`, ADD INDEX (`couple_problem_sets_id`); 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps' WHERE `user_rules`.`id` = 5; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps' WHERE `user_rules`.`id` = 6; 

----------------------------------- 09/10/2019 -----------------------


-- --------------------------------------------------------

--
-- Table structure for table `my_courses`
--

CREATE TABLE `my_courses` (
  `id` int(11) NOT NULL,
  `course_id` int(11) NOT NULL,
  `class_id` int(11) NOT NULL,
  `created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `my_courses`
--
ALTER TABLE `my_courses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `courses_id` (`course_id`),
  ADD KEY `class_id` (`class_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `my_courses`
--
ALTER TABLE `my_courses`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `my_courses`
--
ALTER TABLE `my_courses`
  ADD CONSTRAINT `my_courses_ibfk_3` FOREIGN KEY (`class_id`) REFERENCES `classes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
  ADD CONSTRAINT `my_courses_ibfk_4` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;



INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'my-coursesController', 'index,create,update,delete,new-copy,test-drive,content-delete,view,my-courses-order', 'allow', 'teacher'); 

UPDATE `user_rules` SET `privileges_actions` = 'index,change-password,logout,pages,change-status,varification-email,contact,vanilla-authenticate,redirect-to-vanilla,frontend-user-login,search,feature-page,search-data,blog,post-details,search-tutorial-pages,rstudio-login,login,redirect-to-rstudio,vanilla-embed,search-student-names,resources,questions-problemsets,home-pages,home-teachers' WHERE `user_rules`.`id` = 22;


-- --------------------------------------------------------

--
-- Table structure for table `my_courses_problem_sets`
--

CREATE TABLE `my_courses_problem_sets` (
  `id` int(11) NOT NULL,
  `users_id` int(11) NOT NULL,
  `my_courses_id` int(11) NOT NULL,
  `problem_sets_id` int(11) DEFAULT NULL,
  `is_LA` int(11) DEFAULT NULL,
  `lesson_plans_notes_id` int(11) DEFAULT NULL,
  `position` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `my_courses_problem_sets`
--
ALTER TABLE `my_courses_problem_sets`
  ADD PRIMARY KEY (`id`),
  ADD KEY `users_id` (`users_id`),
  ADD KEY `my_courses_id` (`my_courses_id`),
  ADD KEY `problem_sets_id` (`problem_sets_id`),
  ADD KEY `lesson_plans_notes_id` (`lesson_plans_notes_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `my_courses_problem_sets`
--
ALTER TABLE `my_courses_problem_sets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `my_courses_problem_sets`
--
ALTER TABLE `my_courses_problem_sets`
  ADD CONSTRAINT `my_courses_problem_sets_ibfk_3` FOREIGN KEY (`my_courses_id`) REFERENCES `my_courses` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;


UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,test-drive,content-delete,view,my-courses-order,delete-material' WHERE `user_rules`.`id` = 64; 
UPDATE `user_rules` SET `privileges_actions` = 'set-teachers-settings,set-time-zone,manage-tutorials,pre-built,get-prebuilt-content,home' WHERE `user_rules`.`id` = 35;

------------------- 15/10/2019 --------------------------------
UPDATE `user_rules_menu` SET `label` = 'Problem Sets' WHERE `user_rules_menu`.`id` = 21; 
UPDATE `user_rules_menu` SET `label` = 'Problem Sets' WHERE `user_rules_menu`.`id` = 22; 

UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create,migrate-all-questions,lesson-list,list,lesson-plans,view-couple-problems,problem-sets-list' WHERE `user_rules`.`id` = 14;

---------------- 16/10/2019 ------------------------------

-- --------------------------------------------------------

--
-- Table structure for table `license_master`
--

CREATE TABLE `license_master` (
  `id` int(11) NOT NULL,
  `questions_id` int(11) DEFAULT NULL,
  `lesson_plans_id` bigint(20) DEFAULT NULL,
  `title` varchar(255) NOT NULL,
  `type` tinyint(4) NOT NULL,
  `reference` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `license_master`
--
ALTER TABLE `license_master`
  ADD PRIMARY KEY (`id`),
  ADD KEY `lesson_plans_id` (`lesson_plans_id`),
  ADD KEY `questions_id` (`questions_id`) USING BTREE;

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `license_master`
--
ALTER TABLE `license_master`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `license_master`
--
ALTER TABLE `license_master`
  ADD CONSTRAINT `license_master_ibfk_4` FOREIGN KEY (`questions_id`) REFERENCES `questions` (`id`) ON DELETE CASCADE;

ALTER TABLE `license_master`
  ADD CONSTRAINT `license_master_ibfk_3` FOREIGN KEY (`lesson_plans_id`) REFERENCES `lesson_plans_notes` (`id`) ON DELETE CASCADE;

  ------------------ 17/10/2019 -----------------------------------------
UPDATE `user_rules` SET `role_id` = '4' WHERE `user_rules`.`id` = 57;
UPDATE `user_rules` SET `role_id` = '3' WHERE `user_rules`.`id` = 58;
UPDATE `user_rules` SET `privileges_actions` = 'index,reports-issues,question-info' WHERE `user_rules`.`id` = 57;
UPDATE `user_rules` SET `privileges_actions` = 'index,question-info' WHERE `user_rules`.`id` = 58;  

----Prebuilt tab
UPDATE `user_rules_menu` SET `label` = 'Collections' WHERE `user_rules_menu`.`id` = 72; 
UPDATE `user_rules_menu` SET `label` = 'Collections' WHERE `user_rules_menu`.`id` = 73;  

---- learrning block backend
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '5', 'Learning Blocks', 'icon-question', 'questions/learning-blocks', '3', '1');
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks' WHERE `user_rules`.`id` = 5; 
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks' WHERE `user_rules`.`id` = 6;


----------------- 19/10/2019 -------------
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '65', 'Notes', 'icon-question', 'lesson-plans-notes/notes', '7', '1');
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'lesson-plans-notesController', 'index,create,update,delete,new-copy,test-drive,content-delete,view,notes', 'allow', 'superadmin'); 
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'lesson-plans-notesController', 'index,create,update,delete,new-copy,test-drive,content-delete,view,notes', 'allow', 'admin'); 

INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '65', 'Lesson Plans', 'icon-question', 'lesson-plans-notes/index', '7', '1');

------------courses backend

INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'CoursesController', 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list', 'allow', 'superadmin'); 
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'CoursesController', 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list', 'allow', 'admin'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '67', 'Modules', 'icon-question', 'courses/index', '7', '1');


------------------
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps' WHERE `user_rules`.`id` = 5;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps' WHERE `user_rules`.`id` = 6;

-------- front rights
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps' WHERE `user_rules`.`id` = 54;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps' WHERE `user_rules`.`id` = 55;

----------- front add to module
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list,add-to-module' WHERE `user_rules`.`id` = 59;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list,add-to-module' WHERE `user_rules`.`id` = 67;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list,add-to-module' WHERE `user_rules`.`id` = 68;

UPDATE `user_rules_menu` SET `label` = 'Lesson Plans' WHERE `user_rules_menu`.`id` = 75;
UPDATE `user_rules_menu` SET `url` = 'lesson-plans-notes/index' WHERE `user_rules_menu`.`id` = 75;

UPDATE `user_rules_menu` SET `label` = 'Notes' WHERE `user_rules_menu`.`id` = 76;
UPDATE `user_rules_menu` SET `url` = 'lesson-plans-notes/notes' WHERE `user_rules_menu`.`id` = 76;


--------my folders
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'my-foldersController', 'index,create,update,view,delete,new-copy,delete-ps,assign,view-courses,get-portlet,courses-list,add-to-module,my-folder-modules-order,delete-module', 'allow', 'teacher');
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,view,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list,add-to-module,my-folder-modules-order,delete-module' WHERE `user_rules`.`id` = 69;

-----Course To Module 
UPDATE courses SET unique_number = REPLACE(unique_number,'#COURSE','#MODULE');

---- 24-10-2019 ---------
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 54;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 55;

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 5;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 6;

UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create,migrate-all-questions,lesson-list,list,lesson-plans,view-couple-problems,problem-sets-list' WHERE `user_rules`.`id` = 14; 

--- pending
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 54;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 55;

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 5;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block' WHERE `user_rules`.`id` = 6;


----------- rights
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'QuestionsController', 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block', 'allow', 'admin');
UPDATE `user_rules_menu` SET `user_rules_id` = '70' WHERE `user_rules_menu`.`id` = 74;
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '66', 'Lesson Plans', 'icon-question', 'lesson-plans-notes/index', '7', '1');
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '66', 'Notes', 'icon-question', 'lesson-plans-notes/notes', '7', '1'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '68', 'Modules', 'icon-question', 'courses/index', '7', '1');

--------- 31-10-2019 ----------
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'QuestionsController', 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block', 'allow', 'superadmin');
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '71', 'Learning Blocks', 'icon-question', 'questions/learning-blocks', '3', '1');



-------------05-11-2019 ---------------
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'CategoryController', 'index,create,update,delete,new-copy,category-sorted-order', 'allow', 'superadmin');
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'CategoryController', 'index,create,update,delete,new-copy,category-sorted-order', 'allow', 'admin');

INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '72', 'Tag Content', 'icon-question', 'category/tag-questions', '15', '1');
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '82', '72', 'Tag Questions', 'icon-question', 'category/tag-questions', '1', '1'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '82', '72', 'Tag Learning Blocks', 'icon-question', 'category/tag-learning-blocks', '2', '1');


INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '73', 'Tag Content', 'icon-question', 'category/tag-questions', '15', '1');
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '85', '73', 'Tag Questions', 'icon-question', 'category/tag-questions', '1', '1'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '85', '73', 'Tag Learning Blocks', 'icon-question', 'category/tag-learning-blocks', '2', '1');

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks' WHERE `user_rules`.`id` = 34;




UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks' WHERE `user_rules`.`id` = 72;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks' WHERE `user_rules`.`id` = 73;


------------
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block,view' WHERE `user_rules`.`id` = 5;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block,view' WHERE `user_rules`.`id` = 6;


-------- report isseus 
UPDATE `user_rules` SET `privileges_actions` = 'index,question-info,reports-issues' WHERE `user_rules`.`id` = 58; 


-------------16-11-2019 question tabs
ALTER TABLE `questions` CHANGE `content` `content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL;
ALTER TABLE `questions` ADD `is_allowed_tab` TINYINT NULL DEFAULT '0' AFTER `status`; 
ALTER TABLE `questions` ADD `number_of_tabs` INT NULL DEFAULT NULL AFTER `is_allowed_tab`; 
ALTER TABLE `questions` CHANGE `is_allowed_tab` `is_allowed_tab` TINYINT(4) NULL DEFAULT NULL;


---------- Quick assign grade library for frq
UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report,update-teacher-feedback,quick-assign-grade-library' WHERE `user_rules`.`id` = 25;

ALTER TABLE `students_assignments_details` ADD `number_of_times_used` INT NULL DEFAULT '1' AFTER `total_time`;


------ DATA SETS FEATURE ADD TO MODULE
ALTER TABLE `courses_problem_sets` ADD `data_sets_id` INT NULL DEFAULT NULL  AFTER `lesson_plans_notes_id`;
ALTER TABLE `courses_problem_sets` ADD CONSTRAINT `courses_problem_sets_ibfk_3` FOREIGN KEY (`data_sets_id`) REFERENCES `data_sets_master` (`id`) ON DELETE CASCADE;

-------------- 03-12-2019  automated feedback --------------------

ALTER TABLE `teachers_settings` ADD `automated_feedback` TINYINT NULL DEFAULT '0' AFTER `hints_delay`, ADD `min_grade` INT NULL AFTER `automated_feedback`, ADD `max_grade` INT NULL AFTER `min_grade`;

------------- 04-12-2019 
UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report,update-teacher-feedback,quick-assign-grade-library,add-to-quick-grade' WHERE `user_rules`.`id` = 25;
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'quick-gradeController', 'index,create,update,view,delete,new-copy,upload', 'allow', 'teacher');

--------- 05-12-2019
UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report,update-teacher-feedback,quick-assign-grade-library,add-to-quick-grade,add-to-assign-grade' WHERE `user_rules`.`id` = 25;
UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report,update-teacher-feedback,quick-assign-grade-library,add-to-quick-grade,add-to-assign-grade,quick-assign-grade' WHERE `user_rules`.`id` = 25;



----------------- 09-12-2019 -------- myfolder feature ------------
ALTER TABLE `courses_problem_sets` ADD CONSTRAINT `lesson_plans_notes_ibfk_1` FOREIGN KEY (`lesson_plans_notes_id`) REFERENCES `lesson_plans_notes` (`id`) ON DELETE CASCADE;



---------------10-12-2019 ------------------
ALTER TABLE `my_courses_problem_sets` ADD CONSTRAINT `my_courses_problem_sets_ibfk_1` FOREIGN KEY (`problem_sets_id`) REFERENCES `problem_sets` (`id`) ON DELETE CASCADE;
ALTER TABLE `my_courses_problem_sets` CHANGE `lesson_plans_notes_id` `lesson_plans_notes_id` BIGINT(11) NULL DEFAULT NULL; 
ALTER TABLE `my_courses_problem_sets` ADD CONSTRAINT `my_courses_problem_sets_ibfk_2` FOREIGN KEY (`lesson_plans_notes_id`) REFERENCES `lesson_plans_notes` (`id`) ON DELETE CASCADE;


---------------Setting Profile tab -----
ALTER TABLE `users` ADD `nick_name` VARCHAR(255) NULL AFTER `teaching_statistics`, ADD `bio` TEXT NULL AFTER `nick_name`, ADD `website` VARCHAR(255) NULL AFTER `bio`, ADD `twitter` VARCHAR(255) NULL AFTER `website`;


-----------------12-12-2019 question error reporting ----
ALTER TABLE `question_error_reporting` CHANGE `teachers_students_assignments_id` `teachers_students_assignments_id` INT(11) NULL DEFAULT '0'; 

INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'Question-Error-ReportingController', 'index,question-info,reports-issues', 'allow', 'superadmin');
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'Question-Error-ReportingController', 'index,question-info,reports-issues', 'allow', 'admin');

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,view,delete,new-copy,delete-ps,assign,view-courses,get-portlet,courses-list,add-to-module,my-folder-modules-order,delete-module,pages,get-module-data' WHERE `user_rules`.`id` = 69;

--------------- 16-12-2019 r-coding feature
ALTER TABLE `questions` ADD `r_code_type` TINYINT NULL DEFAULT '0' AFTER `number_of_tabs`; 

-------------- 16-12-2019 tag question tooltip
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block,view,get-question-content' WHERE `user_rules`.`id` = 5;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block,view,get-question-content' WHERE `user_rules`.`id` = 6;

--------------------------------------START: NEW PENDING FOR PROD SERVER ------------------------------

----- 17-12-2019
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks,update-tag-category,get-sub-category,get-question-content' WHERE `user_rules`.`id` = 72;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks,update-tag-category,get-sub-category,get-question-content' WHERE `user_rules`.`id` = 73;

----TABS
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,set-dates,class-progress,assignmnt-report,problem-set-report-by-assignments,student-progress,assignment-list,manage-tabs,settings,edit,assignments-list' WHERE `user_rules`.`id` = 24;

---------------Collection Sub Tabs and accordions 
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'pre-built-sub-tabsController', 'index,create,update,delete,new-copy,view,check-sub-tab-title,change-tab-order', 'allow', 'superadmin');
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'pre-built-sub-tabsController', 'index,create,update,delete,new-copy,view,check-sub-tab-title,change-tab-order', 'allow', 'admin');

------------------Collection sub tab accordions rules
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'pre-built-accordionsController', 'index,create,update,delete,new-copy,view,check-sub-tab-title,change-tab-order', 'allow', 'superadmin');
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '2', 'pre-built-accordionsController', 'index,create,update,delete,new-copy,view,check-sub-tab-title,change-tab-order', 'allow', 'admin');

ALTER TABLE `pre_built_accordions` CHANGE `content` `content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; 


------------Frontend teacher side collection 
UPDATE `user_rules` SET `privileges_actions` = 'set-teachers-settings,set-time-zone,manage-tutorials,pre-built,get-prebuilt-content,home,modules,set-teachers-automated-feedback-settings,get-collection-sub-tabs,get-accordions' WHERE `user_rules`.`id` = 35;


-------------quick grade library
ALTER TABLE `quick_grade` CHANGE `number_of_times_used` `number_of_times_used` INT(11) NULL DEFAULT '1'; 


----------- License referrence
ALTER TABLE `license_master` CHANGE `reference` `reference` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; 

ALTER TABLE `users` ADD `git_hub_link` TEXT NULL AFTER `twitter`, ADD `linked_in_link` TEXT NULL AFTER `git_hub_link`; 
ALTER TABLE `users` ADD `is_public_visible` TINYINT NOT NULL DEFAULT '0' AFTER `status`; 
ALTER TABLE `users` CHANGE `is_public_visible` `is_public_visible` TEXT NOT NULL; 

UPDATE `user_rules` SET `privileges_actions` = 'profile,change-password,check-email,check-nick-name' WHERE `user_rules`.`id` = 17; 

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps,learning-block,get-questions-tabs-content,profile-question-list' WHERE `user_rules`.`id` = 54;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,learning-blocks,add-to-ps,learning-block,get-questions-tabs-content,profile-question-list' WHERE `user_rules`.`id` = 55;

ALTER TABLE `users` ADD `profile_image` BLOB NULL AFTER `linked_in_link`; 

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,check-tutorial-pages-url-key,new-copy,profile-question-list,profile-lb-list,profile-ps-list,profile-modules-list,profile-lessons-list' WHERE `user_rules`.`id` = 36; 

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,check-tutorial-pages-url-key,new-copy,profile-question-list,profile-lb-list,profile-ps-list,profile-modules-list,profile-lessons-list' WHERE `user_rules`.`id` = 37;

UPDATE `user_rules` SET `privileges_actions` = 'pages,profile-question-list,profile-lb-list,profile-ps-list,profile-modules-list,profile-lessons-list' WHERE `user_rules`.`id` = 38; 

UPDATE `user_rules` SET `privileges_actions` = 'pages,profile-question-list,profile-lb-list,profile-ps-list,profile-modules-list,profile-lessons-list' WHERE `user_rules`.`id` = 39;  


UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report,update-teacher-feedback,quick-assign-grade-library,add-to-quick-grade,add-to-assign-grade,quick-assign-grade,get-student-answer' WHERE `user_rules`.`id` = 25;

UPDATE `user_rules` SET `privileges_actions` = 'enroll-students,enroll-class,enroll-section,assignments,take-assignment,hints-updation,question-attempt,report,check-answers,question-completion,assignment-completion,paper-test,get-hints-by-question-in-tutor-ass,la-test,hint-time,lessons,view-lessons,get-lessons' WHERE `user_rules`.`id` = 19;

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks,update-tag-category,get-sub-category,get-question-content,update-question-license,update-question-license-reference' WHERE `user_rules`.`id` = 72;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks,update-tag-category,get-sub-category,get-question-content,update-question-license,,update-question-license-reference' WHERE `user_rules`.`id` = 73;


----------------------------------------- START : NEW PENDING FOR PROD SERVER -----------------------------

ALTER TABLE `questions` ADD `is_archive` TINYINT NULL DEFAULT '0' AFTER `status`;

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block,view,get-question-content,archive-question' WHERE `user_rules`.`id` = 5;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,create-couple-ps,update-couple-ps,learning-blocks,add-to-ps,learning-block,view,get-question-content,archive-question' WHERE `user_rules`.`id` = 6;

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,view,learning-blocks,add-to-ps,learning-block,get-questions-tabs-content,profile-question-list,archive-question' WHERE `user_rules`.`id` = 54;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,hint-delete,option-delete,sub-questions,check-questions-number,new-copy,change-status,sub-questions-order,create-variablize,answers-order,hints-order,get-group-templates,remove-variablize,get-template-from-server,quick-edit,learning-blocks,add-to-ps,learning-block,get-questions-tabs-content,profile-question-list,archive-question' WHERE `user_rules`.`id` = 55;


UPDATE `user_rules_menu` SET `label` = 'Instructional',`url` = 'instructional' WHERE `user_rules_menu`.`id` = 81;
UPDATE `user_rules_menu` SET `label` = 'Instructional',`url` = 'instructional' WHERE `user_rules_menu`.`id` = 74;

ALTER TABLE `problem_sets` ADD `is_archive` TINYINT NULL DEFAULT '0' AFTER `status`;

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,migrate-all-questions,get-public-url,view-couple-problems,archive-ps' WHERE `user_rules`.`id` = 9;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,migrate-all-questions,get-public-url,view-couple-problems,archive-ps' WHERE `user_rules`.`id` = 10;
UPDATE `user_rules` SET `privileges_actions` = 'index,update,delete,new-copy,delete-question,view-problems,check-problem-sets-number,questions-order,assign,sections-list-by-class,students-list-by-class,di-problem-set,di-problem-set-edit,di-new-copy,ml-problem-set-edit,problem-set-di-ml,ml-problem-set-edit,ml-new-copy,count-problem-sets-questions,ra-problem-set,ra-new-copy,ra-problem-set-edit,create,migrate-all-questions,lesson-list,list,lesson-plans,view-couple-problems,problem-sets-list,archive-ps' WHERE `user_rules`.`id` = 14;

ALTER TABLE `courses` ADD `is_archive` TINYINT NULL DEFAULT '0' AFTER `status`;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list,add-to-module,archive-module' WHERE `user_rules`.`id` = 59;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list,add-to-module,archive-module' WHERE `user_rules`.`id` = 67;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,delete-ps,assign,view-courses,delete-lpn,courses-list,add-to-module,archive-module' WHERE `user_rules`.`id` = 68;

ALTER TABLE `lesson_plans_notes` ADD `is_archive` TINYINT NULL DEFAULT '0' AFTER `status`;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,test-drive,content-delete,view,notes,archive-lpn' WHERE `user_rules`.`id` = 60;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,test-drive,content-delete,view,notes,archive-lpn' WHERE `user_rules`.`id` = 65;
UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,test-drive,content-delete,view,notes,archive-lpn' WHERE `user_rules`.`id` = 66;


UPDATE `user_rules_menu` SET `label` = 'Tag Instructional' WHERE `user_rules_menu`.`id` = 84; 
UPDATE `user_rules_menu` SET `url` = 'tag-questions/instructional' WHERE `user_rules_menu`.`id` = 84; 

UPDATE `user_rules_menu` SET `label` = 'Tag Instructional' WHERE `user_rules_menu`.`id` = 87;
UPDATE `user_rules_menu` SET `url` = 'tag-questions/instructional' WHERE `user_rules_menu`.`id` = 87; 


------question issues report admin
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '77', 'Question Bug Reports', 'fa fa-bar-chart', 'question-error-reporting/questions-report', '7', '1');
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '78', 'Question Bug Reports', 'fa fa-bar-chart', 'question-error-reporting/questions-report', '7', '1');

---- Teachers Data For K2S
UPDATE `user_rules_menu` SET `parent_id` = '1' WHERE `user_rules_menu`.`id` = 125;
UPDATE `user_rules_menu` SET `parent_id` = '1' WHERE `user_rules_menu`.`id` = 126;

---- Teachers Data For K2P
UPDATE `user_rules_menu` SET `parent_id` = '1' WHERE `user_rules_menu`.`id` = 125;
UPDATE `user_rules_menu` SET `parent_id` = '1' WHERE `user_rules_menu`.`id` = 124;

---- Teachers Data For K2C
UPDATE `user_rules_menu` SET `parent_id` = '1' WHERE `user_rules_menu`.`id` = 125;
UPDATE `user_rules_menu` SET `parent_id` = '1' WHERE `user_rules_menu`.`id` = 126;

---- Teachers Data For K2S and K2C
UPDATE `user_rules_menu` SET `parent_id` = '0' WHERE `user_rules_menu`.`id` = 125;
UPDATE `user_rules_menu` SET `parent_id` = '0' WHERE `user_rules_menu`.`id` = 126;

---- Teachers Data For K2P
UPDATE `user_rules_menu` SET `parent_id` = '0' WHERE `user_rules_menu`.`id` = 125;
UPDATE `user_rules_menu` SET `parent_id` = '0' WHERE `user_rules_menu`.`id` = 124;


---- Teachers Data For K2S and K2C
UPDATE `user_rules_menu` SET `class` = 'fa fa-book' WHERE `user_rules_menu`.`id` = 125;
UPDATE `user_rules_menu` SET `class` = 'fa fa-book' WHERE `user_rules_menu`.`id` = 126;


---- Teachers Data For K2P
UPDATE `user_rules_menu` SET `class` = 'fa fa-book' WHERE `user_rules_menu`.`id` = 124;
UPDATE `user_rules_menu` SET `class` = 'fa fa-book' WHERE `user_rules_menu`.`id` = 125;


---- Teachers Data For K2S and K2C
UPDATE `user_rules_menu` SET `position` = '1' WHERE `user_rules_menu`.`id` = 125;
UPDATE `user_rules_menu` SET `position` = '1' WHERE `user_rules_menu`.`id` = 126;

---- Teachers Data For K2P
UPDATE `user_rules_menu` SET `position` = '1' WHERE `user_rules_menu`.`id` = 124;
UPDATE `user_rules_menu` SET `position` = '1' WHERE `user_rules_menu`.`id` = 125;

---quick reports
UPDATE `user_rules` SET `privileges_actions` = 'assignment-reports,assignment-list,problemset-report,snapshot-reports,problem-set-report-by-assignments,student-progress,assignment-pdf-report,assignment-spredsheet-report,update-ungraded-question,problemset-report-ajax,manage-tabs,intercom-report-name,intercom-graph-name,generate-file-reports,individual-reports,assignment-report-for-students,generate-file-individual-reports,generate-file-summarized-assignments-reports,get-question-content,question-report,grading-report,update-teacher-feedback,quick-assign-grade-library,add-to-quick-grade,add-to-assign-grade,quick-assign-grade,get-student-answer,quick-reports' WHERE `user_rules`.`id` = 25;

---collection ps
ALTER TABLE `problem_sets` ADD `is_collection` TINYINT NULL DEFAULT NULL AFTER `is_LA`;
UPDATE `teachers_settings`  SET general_settings="";


-------------Table Save and load table data

UPDATE `user_rules` SET `privileges_actions` = 'index,create,update,delete,new-copy,category-sorted-order,tag-questions,tag-learning-blocks,update-tag-category,get-sub-category,get-question-content,update-question-license,update-question-license-reference,view,new-copy-replace,new-copy,get-app-ps,update-question-ps,remove-question-ps,get-app-lsn,question-fr,question-status,get-table-data' WHERE `user_rules`.`id` = 104;

CREATE TABLE `assignment_table` (
  `id` int(11) NOT NULL,
  `users_id` bigint(20) NOT NULL,
  `name` varchar(255) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT '0',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `assignment_table`
--
ALTER TABLE `assignment_table`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `assignment_table`
--
ALTER TABLE `assignment_table`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;




CREATE TABLE `assignment_table_data` (
  `id` bigint(20) NOT NULL,
  `assignment_table_id` int(11) NOT NULL,
  `assignment_id` int(11) NOT NULL,
  `position` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `assignment_table_data`
--
ALTER TABLE `assignment_table_data`
  ADD PRIMARY KEY (`id`),
  ADD KEY `assignment_table_data_ibfk_1` (`assignment_table_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `assignment_table_data`
--
ALTER TABLE `assignment_table_data`
  MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `assignment_table_data`
--
ALTER TABLE `assignment_table_data`
  ADD CONSTRAINT `assignment_table_data_ibfk_1` FOREIGN KEY (`assignment_table_id`) REFERENCES `assignment_table` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;

 -- Course to Course binders settings
 UPDATE teachers_settings
 SET `general_settings` = replace(`general_settings`, 'My Courses', 'My Course Binders') 
-- classes added 
 UPDATE teachers_settings SET `general_settings` = replace(`general_settings`, '["Getting Started"', '["Classes","Getting Started"') 
--
 update teachers_settings set general_settings = '["Classes","Getting Started","My Course Binders","Assignment Reports","Community","My Profile","Settings"]';

--
ALTER TABLE `users` ADD `fs-restore-id` INT NULL AFTER `schools_id`, ADD UNIQUE `fs-restore-id` (`fs-restore-id`);
ALTER TABLE `users` CHANGE `fs-restore-id` `fs_restore_id` INT NULL DEFAULT NULL;
UPDATE `user_rules` SET `privileges_actions` = 'index,change-password,logout,pages,change-status,varification-email,contact,vanilla-authenticate,redirect-to-vanilla,frontend-user-login,search,feature-page,search-data,blog,post-details,search-tutorial-pages,rstudio-login,login,redirect-to-rstudio,vanilla-embed,search-student-names,resources,questions-problemsets,home-pages,home-teachers,assignments,maintenance,save-fs-restore-id' WHERE `user_rules`.`id` = 22;
ALTER TABLE `users` CHANGE `fs_restore_id` `fs_restore_id` VARCHAR(255) NULL DEFAULT NULL;


-- tutor default for ps
ALTER TABLE `problem_sets` CHANGE `mode` `mode` TINYINT NOT NULL DEFAULT '1' COMMENT '0=Test,1=Tutor'; 

/*Add column for forever editable*/
ALTER TABLE `problem_sets` ADD `is_forever_editable` TINYINT(1) NOT NULL DEFAULT '0' AFTER `approved_for_questions`;

-- auto teachers data for ever first login
ALTER TABLE `users` ADD `is_ever_first_login` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_logged_in`; 

--Add date time field for sorting the my course binder data in desc (like when the teacher added the cb to my cb it will show on top)
ALTER TABLE `my_folders` ADD `my_cb_add_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `is_k2s_position`;

-- Change Default order for Home Menu--
UPDATE `teachers_settings`
SET `general_settings` = replace(general_settings, '["Classes","Getting Started","My Course Binders","Assignment Reports","Community","My Profile","Settings"]', '["My Course Binders","Classes","Getting Started","Assignment Reports","Community","My Profile","Settings"]');

ALTER TABLE `classes` ADD `course_type` TINYINT(1) NOT NULL AFTER `class_last_date`;

-- pre approved teachers
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '1', 'PreApprovedTeachersController', 'index,update,delete,create', 'allow', 'superadmin'); 
INSERT INTO `user_rules_menu` (`id`, `category`, `parent_id`, `user_rules_id`, `label`, `class`, `url`, `position`, `status`) VALUES (NULL, 'admin', '0', '105', 'Pre Approved Teachers', 'fa fa-check', 'pre-approved-teachers/index', '1', '1'); 
ALTER TABLE `c` ADD `is_easy_access` TINYINT(1) NOT NULL DEFAULT '0' AFTER `is_logged_in`; 

-- changes for fake students--
ALTER TABLE `users` ADD `is_fake_student ` TINYINT(1) NOT NULL DEFAULT 0 AFTER `is_easy_access`; 
UPDATE `users` SET `is_fake_student` = 1  WHERE `email` LIKE '%fake_%';



--- LTI - ed.link changes ---
ALTER TABLE `users` ADD `is_lti_user` TINYINT(1) NOT NULL DEFAULT '0' AFTER `cf_no_message_board_clicked`, ADD `lti_person_id` VARCHAR(255) NULL AFTER `is_lti_user`, ADD `lti_access_token` VARCHAR(255) NULL AFTER `lti_person_id`, ADD `lti_auth_response` TEXT NULL AFTER `lti_access_token`, ADD UNIQUE `lti_person_id_unique` (`lti_person_id`); 
-- changed following because it's giving wrong date format '0000'
ALTER TABLE `my_folders` CHANGE `my_cb_add_date` `my_cb_add_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP; 
-- rules changes
INSERT INTO `user_rules` (`id`, `role_id`, `privileges_controller`, `privileges_actions`, `permission`, `permission_type`) VALUES (NULL, '3', 'LmsController', 'callback', 'allow', NULL), (NULL, '4', 'LmsController', 'callback', 'allow', NULL); 
-- classes
ALTER TABLE `classes` ADD `lti_class_id` VARCHAR(255) NULL DEFAULT NULL AFTER `id`; 
ALTER TABLE `classes_sections` ADD `is_lti` TINYINT(1) NOT NULL DEFAULT '0' AFTER `status`; 