CREATE TABLE `coursemanager_answers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `questionId` int(11) NOT NULL,
  `name` varchar(250) DEFAULT NULL,
  `grade` int(11) DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_bookmarks` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pageId` int(11) DEFAULT NULL,
  `courseId` int(11) DEFAULT NULL,
  `lessonId` int(11) DEFAULT NULL,
  `type` varchar(255) NOT NULL,
  `userId` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_certificates` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `developerId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_courses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `contactId`  int(11) NOT NULL,
  `name` varchar(250) DEFAULT NULL,
  `description` text NOT NULL,
  `objectives` text NOT NULL,
  `grade` int(11) NOT NULL DEFAULT '0',
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  `notification` ENUM('Yes','No') NOT NULL DEFAULT 'No',
  `order` int(11) NOT NULL,
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `completion` int(11) DEFAULT '0',
  `goals` text,
  `contents` text,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_lessons` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  `order` int(11) DEFAULT '0',
  `name` varchar(500) DEFAULT NULL,
  `keywords` varchar(250) DEFAULT NULL,
  `description` text NOT NULL,
  `objectives` text NOT NULL,
  `grade` int(11) NOT NULL DEFAULT '0',
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `completion` int(11) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_pages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `lessonId` int(11) NOT NULL,
  `order` int(11) DEFAULT '0',
  `name` varchar(500) DEFAULT NULL,
  `description` text,
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_questions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `name` varchar(250) DEFAULT NULL,
  `keywords` varchar(250) DEFAULT NULL,
  `description` text NOT NULL,
  `shuffle` int(11) DEFAULT '0',
  `type` enum('Multiple','Single') NOT NULL DEFAULT 'Multiple',
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `answersCorrect` int(11) NOT NULL DEFAULT '0',
  `answersNumber` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_questions_courses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `questionId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_questions_courses_specified` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `questionId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_questions_lessons` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `questionId` int(11) NOT NULL,
  `lessonId` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_questions_pages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `questionId` int(11) NOT NULL,
  `pageId` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_quizes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `lessonId` int(11) DEFAULT NULL,
  `courseId` int(11) DEFAULT NULL,
  `perpage` int(11) DEFAULT '1',
  `name` varchar(250) DEFAULT NULL,
  `description` text NOT NULL,
  `attempts` int(11) DEFAULT '1',
  `shuffle` int(11) DEFAULT '1',
  `type` enum('Formative','Summative') NOT NULL DEFAULT 'Formative',
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `completion` int(11) DEFAULT '0',
  `keywords` varchar(250) DEFAULT NULL,
  `order` int(11) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_quiz_questions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `quizId` int(11) NOT NULL,
  `questionId` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_resources` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `lessonId` int(11) NOT NULL,
  `order` int(11) DEFAULT '0',
  `name` varchar(250) DEFAULT NULL,
  `description` varchar(500) NOT NULL,
  `url` varchar(500) NOT NULL,
  `status` enum('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_user_courses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  `grade` int(11) NOT NULL DEFAULT '0',
  `attempts` int(11) DEFAULT '0',
  `state` enum('Started','Finished','Ready') NOT NULL DEFAULT 'Ready',
  `started` datetime DEFAULT NULL,
  `completed` datetime DEFAULT NULL,
  `expiringnoted` tinyint(1) NOT NULL,
  `expirednoted` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_user_lessons` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `courseId` int(11) NOT NULL,
  `lessonId` int(11) NOT NULL,
  `grade` int(11) NOT NULL DEFAULT '0',
  `state` enum('Started','Finished','Ready') NOT NULL DEFAULT 'Ready',
  `started` datetime DEFAULT NULL,
  `completed` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `courseId` (`courseId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `coursemanager_user_quizes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `userId` int(11) NOT NULL,
  `quizId` int(11) NOT NULL,
  `grade` int(11) NOT NULL DEFAULT '0',
  `attempts` int(11) DEFAULT '0',
  `answers` text,
  `state` enum('Started','Finished','Ready') NOT NULL DEFAULT 'Ready',
  `started` datetime DEFAULT NULL,
  `completed` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;



INSERT INTO `page_pages` ( `parentId`, `keyword`, `status`, `type`, `route`, `template`, `created`, `updated`) VALUES
    (0, 'coursemanager', 'Enabled', 'Module', 'coursemanager', 'default', NOW(), NOW());
INSERT INTO `page_pages_i18n` (`id`, `label`, `content`, `header`, `metaTitle`, `metaDescr`, `metaKeywords`, `locale`) VALUES 
    (LAST_INSERT_ID(), 'Course Manager', 'Course Manager', 'Course Manager', 'Course Manager', 'Course Manager', 'Course Manager', 'en_US');
