INSERT INTO `rq_resource_permissions` (`resource_permissions_id`, `resource_name`, `can_read`, `can_add`, `can_edit`, `can_delete`, `status`, `last_updated`) VALUES (NULL, 'phonics_assessment', '3,1,2,4,5,6', '1,2,4', '1,2,4', '1,2,4', '1', '2017-09-16 20:51:27');



CREATE TABLE `rq_phonics_assessment` (
  `phonics_assessment_id` int(11) NOT NULL,
  `level_id` int(11) NOT NULL DEFAULT '0',
  `mode` tinyint(1) NOT NULL DEFAULT '0',
  `uri` varchar(80) DEFAULT NULL,
  `quiztime` text NOT NULL,
  `random` tinyint(1) NOT NULL DEFAULT '1',
  `random_options` tinyint(1) NOT NULL DEFAULT '0',
  `options_playback` tinyint(1) NOT NULL DEFAULT '0',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `last_updated` datetime DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0: inactive; 1: active',
  `folder_id` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE `rq_phonics_assessment_lang` (
  `phonics_assessment_id` int(11) NOT NULL,
  `lang` varchar(10) NOT NULL,
  `name` varchar(150) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


CREATE TABLE `rq_phonics_assessment_priority` (
  `phonics_assessment_id` int(11) NOT NULL,
  `priority` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `rq_phonics_assessment_questions`
--

CREATE TABLE `rq_phonics_assessment_questions` (
  `question_id` int(11) NOT NULL,
  `phonics_assessment_id` int(11) NOT NULL,
  `type_id` tinyint(1) NOT NULL DEFAULT '0',
  `directions` varchar(1024) NOT NULL,
  `question` varchar(1024) NOT NULL,
  `reading` text NOT NULL,
  `answer` varchar(1024) NOT NULL,
  `hint` varchar(1024) NOT NULL,
  `speech` tinyint(1) NOT NULL DEFAULT '0',
  `audio` tinyint(1) NOT NULL DEFAULT '0',
  `hide` tinyint(1) NOT NULL DEFAULT '0',
  `random_options` tinyint(1) NOT NULL DEFAULT '0',
  `title` varchar(1024) NOT NULL,
  `title_speech` tinyint(1) NOT NULL DEFAULT '0',
  `title_audio` tinyint(1) NOT NULL DEFAULT '0',
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `last_updated` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


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

--
-- Table structure for table `rq_phonics_assessment_questions_files`
--

CREATE TABLE `rq_phonics_assessment_questions_files` (
  `file_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `area_id` int(11) NOT NULL,
  `area` varchar(50) NOT NULL,
  `file_type` varchar(50) NOT NULL,
  `file_name` varchar(80) NOT NULL,
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `status` tinyint(1) NOT NULL DEFAULT '2' COMMENT '0: banned, 1: published, 2: pending'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;



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

--
-- Table structure for table `rq_phonics_assessment_questions_files_lang`
--

CREATE TABLE `rq_phonics_assessment_questions_files_lang` (
  `file_id` int(11) NOT NULL,
  `lang` varchar(10) NOT NULL,
  `title` varchar(255) NOT NULL,
  `caption` text NOT NULL,
  `link` text NOT NULL,
  `link_target` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0: _self, 1: _blank'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;



--
-- Table structure for table `rq_phonics_assessment_questions_files_priority`
--

CREATE TABLE `rq_phonics_assessment_questions_files_priority` (
  `file_id` int(11) NOT NULL,
  `priority` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;



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

--
-- Table structure for table `rq_phonics_assessment_questions_priority`
--

CREATE TABLE `rq_phonics_assessment_questions_priority` (
  `question_id` int(11) NOT NULL,
  `priority` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


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

--
-- Table structure for table `rq_phonics_assessment_rocket_state`
--

CREATE TABLE `rq_phonics_assessment_rocket_state` (
  `phonics_assessment_id` int(11) DEFAULT NULL,
  `user_name` varchar(255) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `rocket_name` varchar(255) NOT NULL,
  `rocket_place` float NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `rq_phonics_assessment_users` (
  `phonics_assessment_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


--
-- Indexes for table `rq_phonics_assessment`
--
ALTER TABLE `rq_phonics_assessment`
  ADD PRIMARY KEY (`phonics_assessment_id`),
  ADD KEY `level_id` (`level_id`,`uri`,`created_time`,`last_updated`,`status`);

--
-- Indexes for table `rq_phonics_assessment_lang`
--
ALTER TABLE `rq_phonics_assessment_lang`
  ADD KEY `phonics_assessment_id` (`phonics_assessment_id`,`lang`,`name`);

--
-- Indexes for table `rq_phonics_assessment_priority`
--
ALTER TABLE `rq_phonics_assessment_priority`
  ADD UNIQUE KEY `phonics_assessment_id` (`phonics_assessment_id`),
  ADD KEY `priority` (`priority`);

--
-- Indexes for table `rq_phonics_assessment_questions`
--
ALTER TABLE `rq_phonics_assessment_questions`
  ADD PRIMARY KEY (`question_id`);

--
-- Indexes for table `rq_phonics_assessment_questions_files`
--
ALTER TABLE `rq_phonics_assessment_questions_files`
  ADD PRIMARY KEY (`file_id`),
  ADD KEY `area_id` (`area_id`,`area`,`file_type`,`created_time`,`status`,`file_name`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `rq_phonics_assessment_questions_files_lang`
--
ALTER TABLE `rq_phonics_assessment_questions_files_lang`
  ADD KEY `file_id` (`file_id`,`lang`);

--
-- Indexes for table `rq_phonics_assessment_questions_files_priority`
--
ALTER TABLE `rq_phonics_assessment_questions_files_priority`
  ADD UNIQUE KEY `file_id` (`file_id`),
  ADD KEY `priority` (`priority`);

--
-- AUTO_INCREMENT for dumped tables
--

--

-- AUTO_INCREMENT for table `rq_phonics_assessment`
--
ALTER TABLE `rq_phonics_assessment`
  MODIFY `phonics_assessment_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT for table `rq_phonics_assessment_questions`
--
ALTER TABLE `rq_phonics_assessment_questions`
  MODIFY `question_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
--
-- AUTO_INCREMENT for table `rq_phonics_assessment_questions_files`
--
ALTER TABLE `rq_phonics_assessment_questions_files`
  MODIFY `file_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

ALTER TABLE `rq_phonics_assessment` DROP `quiztime`, DROP `options_playback`;

ALTER TABLE `rq_phonics_assessment_questions` DROP `type_id`, DROP `directions`, DROP `hint`, DROP `speech`, DROP `audio`, DROP `hide`, DROP `random_options`, DROP `title`, DROP `title_speech`, DROP `title_audio`;

ALTER TABLE `rq_phonics_assessment_questions` ADD `qs_time` TEXT NOT NULL AFTER `answer`;
