text: CREATE TABLE B_LEARN_EXCEPTION_LOG (
    DATE_REGISTERED DATETIME NOT NULL DEFAULT GETDATE(),
    CODE INT NOT NULL,
    MESSAGE TEXT NOT NULL,
    FFILE TEXT NOT NULL,
    LINE INT NOT NULL,
    BACKTRACE TEXT NOT NULL
  )
  GO
  
  CREATE TABLE B_LEARN_PUBLISH_PROHIBITION
  (
  	COURSE_LESSON_ID INT NOT NULL ,
  	PROHIBITED_LESSON_ID INT NOT NULL,
  	CONSTRAINT PK_B_LEARN_PUBLISH_PROHIBITION PRIMARY KEY(COURSE_LESSON_ID, PROHIBITED_LESSON_ID)
  )
  GO
  
  CREATE TABLE B_LEARN_RIGHTS
  (
  	LESSON_ID INT NOT NULL ,
  	SUBJECT_ID VARCHAR(100) NOT NULL,
  	TASK_ID INT NOT NULL,
  	CONSTRAINT PK_B_LEARN_RIGHTS PRIMARY KEY(LESSON_ID, SUBJECT_ID)
  )
  GO
  
  CREATE TABLE B_LEARN_RIGHTS_ALL
  (
  	SUBJECT_ID VARCHAR(100) NOT NULL,
  	TASK_ID INT NOT NULL,
  	CONSTRAINT PK_B_LEARN_RIGHTS_ALL PRIMARY KEY( SUBJECT_ID)
  )
  GO
  
  CREATE TABLE B_LEARN_LESSON_EDGES
  (
  	SOURCE_NODE INT NOT NULL ,
  	TARGET_NODE INT NOT NULL ,
  	SORT INT NOT NULL DEFAULT '500',
  	CONSTRAINT PK_B_LEARN_LESSON_EDGES PRIMARY KEY (SOURCE_NODE, TARGET_NODE)
  )
  GO
  CREATE INDEX ix_learn_lesson_edges_t_node ON b_learn_lesson_edges(TARGET_NODE)
  GO
  
  CREATE TABLE B_LEARN_COURSE
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	TIMESTAMP_X DATETIME NOT NULL DEFAULT GETDATE(),
  	ACTIVE CHAR(1) NOT NULL DEFAULT 'Y',
  	CODE VARCHAR(50) NULL,
  	NAME VARCHAR(255) NOT NULL DEFAULT 'NAME',
  	SORT INT NOT NULL DEFAULT '500',
  	PREVIEW_PICTURE INT NULL,
  	PREVIEW_TEXT text NULL,
  	PREVIEW_TEXT_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	DESCRIPTION TEXT NULL,
  	DESCRIPTION_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	ACTIVE_FROM DATETIME NULL,
  	ACTIVE_TO DATETIME NULL,
  	RATING CHAR(1) NULL,
  	RATING_TYPE VARCHAR(50) NULL,
  	SCORM CHAR(1) NOT NULL DEFAULT 'N',
  	LINKED_LESSON_ID INT NULL DEFAULT NULL,
  	JOURNAL_STATUS INT NOT NULL DEFAULT '0',
  	CONSTRAINT PK_B_LEARN_COURSE PRIMARY KEY(ID)
  )
  GO
  
  CREATE INDEX IX_LEARN_COURSE_LESSON ON B_LEARN_COURSE(LINKED_LESSON_ID)
  GO
  
  CREATE TRIGGER B_LEARN_COURSE_UPDATE ON B_LEARN_COURSE FOR UPDATE AS
  BEGIN
  	SET NOCOUNT ON;
  	IF (NOT UPDATE(TIMESTAMP_X))
  	BEGIN
  		UPDATE B_LEARN_COURSE SET
  			TIMESTAMP_X = GETDATE()
  		FROM
  			B_LEARN_COURSE U,
  			INSERTED I,
  			DELETED D
  		WHERE
  			U.ID = I.ID 
  			AND U.ID = D.ID
  	END
  END
  GO
  
  
  CREATE TABLE B_LEARN_COURSE_SITE
  (
  	COURSE_ID INT NOT NULL,
  	SITE_ID CHAR(2) NOT NULL,
  	CONSTRAINT PK_B_LEARN_COURSE_SITE PRIMARY KEY(COURSE_ID, SITE_ID),
  	CONSTRAINT FK_B_LEARN_COURSE1 FOREIGN KEY (COURSE_ID) REFERENCES B_LEARN_COURSE(ID),
  	CONSTRAINT FK_B_LEARN_COURSE2 FOREIGN KEY (SITE_ID) REFERENCES B_LANG(LID)
  )
  GO
  
  
  CREATE TABLE B_LEARN_CHAPTER
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	TIMESTAMP_X DATETIME NOT NULL DEFAULT GETDATE(),
  	ACTIVE CHAR(1) NOT NULL DEFAULT 'Y',
  	COURSE_ID INT NOT NULL,
  	CHAPTER_ID INT NULL,
  	NAME VARCHAR(255) NOT NULL,
  	CODE VARCHAR(50) NULL,
  	SORT INT NOT NULL DEFAULT '500',
  	PREVIEW_PICTURE INT NULL,
  	PREVIEW_TEXT TEXT NULL,
  	PREVIEW_TEXT_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	DETAIL_PICTURE INT NULL,
  	DETAIL_TEXT TEXT NULL,
  	DETAIL_TEXT_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	JOURNAL_STATUS INT NOT NULL DEFAULT '0',
  	CONSTRAINT PK_B_LEARN_CHAPTER PRIMARY KEY (ID)
  )
  GO
  
  CREATE TRIGGER B_LEARN_CHAPTER_UPDATE ON B_LEARN_CHAPTER FOR UPDATE AS
  BEGIN
  	SET NOCOUNT ON;
  	IF (NOT UPDATE(TIMESTAMP_X))
  	BEGIN
  		UPDATE B_LEARN_CHAPTER SET
  			TIMESTAMP_X = GETDATE()
  		FROM
  			B_LEARN_CHAPTER U,
  			INSERTED I,
  			DELETED D
  		WHERE
  			U.ID = I.ID 
  			AND U.ID = D.ID
  	END
  END
  GO
  
  CREATE TABLE B_LEARN_LESSON
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	TIMESTAMP_X DATETIME NOT NULL DEFAULT GETDATE(),
  	DATE_CREATE DATETIME NULL,
  	CREATED_BY INT NULL,
  	ACTIVE CHAR(1) NOT NULL DEFAULT 'Y',
  	COURSE_ID INT NOT NULL DEFAULT '0',
  	CHAPTER_ID INT NULL,
  	NAME VARCHAR(255) NOT NULL DEFAULT 'name',
  	SORT INT NOT NULL DEFAULT '500' ,
  	PREVIEW_PICTURE INT NULL,
  	KEYWORDS TEXT NULL,
  	PREVIEW_TEXT TEXT NULL,
  	PREVIEW_TEXT_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	DETAIL_PICTURE INT NULL,
  	DETAIL_TEXT TEXT NULL,
  	DETAIL_TEXT_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	LAUNCH TEXT NULL,
  
  	CODE VARCHAR( 50 ) NULL DEFAULT NULL,
  	WAS_CHAPTER_ID INT NULL DEFAULT NULL,
  	WAS_PARENT_CHAPTER_ID INT NULL DEFAULT NULL,
  	WAS_PARENT_COURSE_ID INT NULL DEFAULT NULL,
  	WAS_COURSE_ID INT NULL DEFAULT NULL,
  	JOURNAL_STATUS INT NOT NULL DEFAULT '0',
  
  	CONSTRAINT PK_B_LEARN_LESSON PRIMARY KEY (ID)
  )
  GO
  
  CREATE TRIGGER B_LEARN_LESSON_UPDATE ON B_LEARN_LESSON FOR UPDATE AS
  BEGIN
  	SET NOCOUNT ON;
  	IF (NOT UPDATE(TIMESTAMP_X))
  	BEGIN
  		UPDATE B_LEARN_LESSON SET
  			TIMESTAMP_X = GETDATE()
  		FROM
  			B_LEARN_LESSON U,
  			INSERTED I,
  			DELETED D
  		WHERE
  			U.ID = I.ID 
  			AND U.ID = D.ID
  	END
  END
  GO
  
  CREATE TABLE B_LEARN_QUESTION
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	ACTIVE char(1) not null default 'Y',
  	TIMESTAMP_X DATETIME NOT NULL DEFAULT GETDATE(),
  	LESSON_ID INT NOT NULL,
  	QUESTION_TYPE CHAR(1) NOT NULL DEFAULT 'S',
  	NAME VARCHAR(255) NOT NULL,
  	SORT INT NOT NULL DEFAULT '500',
  	DESCRIPTION TEXT NULL,
  	DESCRIPTION_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	COMMENT_TEXT TEXT NULL,
  	FILE_ID INT NULL,
  	SELF CHAR(1) NOT NULL DEFAULT 'N',
  	POINT INT DEFAULT '10' NOT NULL,
  	DIRECTION CHAR(1) DEFAULT 'V' NOT NULL,
  	CORRECT_REQUIRED CHAR(1) NOT NULL DEFAULT 'N',
  	EMAIL_ANSWER CHAR(1) NOT NULL DEFAULT 'N',
  	INCORRECT_MESSAGE TEXT,
  	CONSTRAINT PK_B_LEARN_QUESTION PRIMARY KEY (ID),
  	CONSTRAINT FK_B_LEARN_QUESTION1 FOREIGN KEY (LESSON_ID) REFERENCES B_LEARN_LESSON(ID)
  )
  GO
  
  CREATE INDEX IX_B_LEARN_QUESTION1 ON B_LEARN_QUESTION(LESSON_ID)
  GO
  
  CREATE TRIGGER B_LEARN_QUESTION_UPDATE ON B_LEARN_QUESTION FOR UPDATE AS
  BEGIN
  	SET NOCOUNT ON;
  	IF (NOT UPDATE(TIMESTAMP_X))
  	BEGIN
  		UPDATE B_LEARN_QUESTION SET
  			TIMESTAMP_X = GETDATE()
  		FROM
  			B_LEARN_QUESTION U,
  			INSERTED I,
  			DELETED D
  		WHERE
  			U.ID = I.ID 
  			AND U.ID = D.ID
  	END
  END
  GO
  
  CREATE TABLE B_LEARN_ANSWER
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	QUESTION_ID INT NOT NULL,
  	SORT INT DEFAULT 10 NOT NULL,
  	ANSWER TEXT NOT NULL,
  	CORRECT CHAR(1) NOT NULL,
  	FEEDBACK TEXT,
  	MATCH_ANSWER TEXT,
  	CONSTRAINT PK_B_LEARN_ANSWER PRIMARY KEY (ID),
  	CONSTRAINT FK_B_LEARN_ANSWER1 FOREIGN KEY (QUESTION_ID) REFERENCES B_LEARN_QUESTION(ID)
  )
  GO
  
  CREATE INDEX IX_B_LEARN_ANSWER1 ON B_LEARN_ANSWER(QUESTION_ID)
  GO
  
  
  
  CREATE TABLE B_LEARN_TEST
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	COURSE_ID INT NOT NULL,
  	TIMESTAMP_X DATETIME NOT NULL DEFAULT GETDATE(),
  	SORT INT NOT NULL DEFAULT '500',
  	ACTIVE CHAR(1) NOT NULL DEFAULT 'Y',
  	NAME VARCHAR(255) NOT NULL,
  	DESCRIPTION TEXT NULL,
  	DESCRIPTION_TYPE CHAR(4) NOT NULL DEFAULT 'text',
  	ATTEMPT_LIMIT INT NOT NULL DEFAULT 0,
  	TIME_LIMIT INT DEFAULT '0',
  	COMPLETED_SCORE INT NULL,
  	QUESTIONS_FROM CHAR(1) NOT NULL DEFAULT 'A',
  	QUESTIONS_FROM_ID INT NOT NULL DEFAULT '0',
  	QUESTIONS_AMOUNT INT NOT NULL DEFAULT '0',
  	RANDOM_QUESTIONS CHAR(1) NOT NULL DEFAULT 'Y',
  	RANDOM_ANSWERS CHAR(1) NOT NULL DEFAULT 'Y',
  	APPROVED CHAR(1) NOT NULL DEFAULT 'Y',
  	INCLUDE_SELF_TEST CHAR(1) NOT NULL DEFAULT 'N',
  	PASSAGE_TYPE CHAR(1) NOT NULL DEFAULT '0',
  	PREVIOUS_TEST_ID INT NULL,
  	PREVIOUS_TEST_SCORE INT DEFAULT '0',
  	INCORRECT_CONTROL CHAR(1) NOT NULL DEFAULT 'N',
  	CURRENT_INDICATION INT NOT NULL DEFAULT '0',
  	FINAL_INDICATION INT NOT NULL DEFAULT '0',
  	MIN_TIME_BETWEEN_ATTEMPTS INT NOT NULL DEFAULT '0',
  	SHOW_ERRORS CHAR(1) NOT NULL DEFAULT 'N',
  	NEXT_QUESTION_ON_ERROR CHAR(1) NOT NULL DEFAULT 'Y',
  	CONSTRAINT PK_B_LEARN_TEST PRIMARY KEY (ID)
  )
  GO
  
  CREATE INDEX IX_B_LEARN_TEST1 ON B_LEARN_TEST(COURSE_ID)
  GO
  
  CREATE INDEX IX_B_LEARN_TEST2 ON B_LEARN_TEST(PREVIOUS_TEST_ID)
  GO
  
  CREATE TRIGGER B_LEARN_TEST_UPDATE ON B_LEARN_TEST FOR UPDATE AS
  BEGIN
  	SET NOCOUNT ON;
  	IF (NOT UPDATE(TIMESTAMP_X))
  	BEGIN
  		UPDATE B_LEARN_TEST SET
  			TIMESTAMP_X = GETDATE()
  		FROM
  			B_LEARN_TEST U,
  			INSERTED I,
  			DELETED D
  		WHERE
  			U.ID = I.ID 
  			AND U.ID = D.ID;
  	END
  END
  GO
  
  
  
  CREATE TABLE B_LEARN_ATTEMPT
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	TEST_ID INT NOT NULL,
  	STUDENT_ID INT NOT NULL,
  	DATE_START DATETIME NOT NULL,
  	DATE_END DATETIME NULL,
  	STATUS CHAR(1) NOT NULL DEFAULT 'B',
  	COMPLETED char(1) not null default 'N',
  	SCORE INT DEFAULT '0',
  	MAX_SCORE INT DEFAULT '0',
  	QUESTIONS INT not null default '0',
  	CONSTRAINT PK_B_LEARN_ATTEMPT PRIMARY KEY (ID),
  	CONSTRAINT FK_B_LEARN_ATTEMPT1 FOREIGN KEY (TEST_ID) REFERENCES B_LEARN_TEST(ID)
  )
  GO
  
  CREATE INDEX IX_B_LEARN_ATTEMPT1 ON B_LEARN_ATTEMPT(STUDENT_ID, TEST_ID)
  GO
  
  CREATE TABLE B_LEARN_TEST_RESULT
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	ATTEMPT_ID INT NOT NULL,
  	QUESTION_ID INT NOT NULL,
  	RESPONSE text NULL,
  	POINT INT NOT NULL DEFAULT '0',
  	CORRECT char(1) not null default 'N',
  	ANSWERED CHAR(1) NOT NULL DEFAULT 'N',
  	CONSTRAINT PK_B_LEARN_TEST_RESULT PRIMARY KEY (ID),
  	CONSTRAINT FK_B_LEARN_TEST_RESULT1 FOREIGN KEY (ATTEMPT_ID) REFERENCES B_LEARN_ATTEMPT(ID),
  	CONSTRAINT FK_B_LEARN_TEST_RESULT2 FOREIGN KEY (QUESTION_ID) REFERENCES B_LEARN_QUESTION(ID),
  )
  GO
  
  CREATE INDEX IX_B_LEARN_TEST_RESULT1 ON B_LEARN_TEST_RESULT(ATTEMPT_ID,QUESTION_ID)
  GO
  CREATE INDEX IX_B_LEARN_TEST_RESULT2 ON B_LEARN_TEST_RESULT(QUESTION_ID, ANSWERED, CORRECT)
  GO
  
  
  CREATE TABLE B_LEARN_GRADEBOOK
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	STUDENT_ID INT NOT NULL,
  	TEST_ID INT NOT NULL,
  	RESULT INT NULL,
  	MAX_RESULT INT NULL,
  	ATTEMPTS INT not null default '1',
  	COMPLETED CHAR(1) NOT NULL DEFAULT 'N',
  	EXTRA_ATTEMPTS INT not null default '0',
  	CONSTRAINT PK_B_LEARN_GRADEBOOK PRIMARY KEY (ID),
  	CONSTRAINT FK_B_LEARN_GRADEBOOK1 FOREIGN KEY (TEST_ID) REFERENCES B_LEARN_TEST(ID)
  )
  GO
  
  CREATE UNIQUE INDEX UX_B_LEARN_GRADEBOOK1 ON B_LEARN_GRADEBOOK(STUDENT_ID,TEST_ID)
  GO
  
  CREATE TABLE B_LEARN_STUDENT
  (
  	USER_ID INT NOT NULL,
  	TRANSCRIPT INT NOT NULL,
  	PUBLIC_PROFILE CHAR(1) NOT NULL DEFAULT 'N',
  	RESUME text NULL,
  	CONSTRAINT PK_B_LEARN_STUDENT PRIMARY KEY (USER_ID)
  )
  GO
  
  CREATE TABLE B_LEARN_CERTIFICATION
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	STUDENT_ID INT NOT NULL,
  	COURSE_ID INT NOT NULL,
  	TIMESTAMP_X DATETIME NOT NULL DEFAULT GETDATE(),
  	DATE_CREATE DATETIME NULL,
  	ACTIVE CHAR(1) NOT NULL DEFAULT 'Y',
  	SORT INT NOT NULL DEFAULT '500',
  	FROM_ONLINE CHAR(1) NOT NULL DEFAULT 'Y',
  	PUBLIC_PROFILE CHAR(1) NOT NULL DEFAULT 'Y',
  	SUMMARY INT NOT NULL DEFAULT '0',
  	MAX_SUMMARY INT NOT NULL DEFAULT '0',
  	CONSTRAINT PK_B_LEARN_CERTIFICATION PRIMARY KEY (ID),
  	CONSTRAINT FK_B_LEARN_CERTIFICATION1 FOREIGN KEY (COURSE_ID) REFERENCES B_LEARN_COURSE(ID)
  )
  GO
  
  CREATE INDEX IX_B_LEARN_CERTIFICATION1 ON B_LEARN_CERTIFICATION(STUDENT_ID, COURSE_ID)
  GO
  
  CREATE TRIGGER B_LEARN_CERTIFICATION_UPDATE ON B_LEARN_CERTIFICATION FOR UPDATE AS
  BEGIN
  	SET NOCOUNT ON;
  	IF (NOT UPDATE(TIMESTAMP_X))
  	BEGIN
  		UPDATE B_LEARN_CERTIFICATION SET
  			TIMESTAMP_X = GETDATE()
  			FROM
  		B_LEARN_CERTIFICATION U,
  		INSERTED I,
  		DELETED D
  		WHERE
  		U.ID = I.ID 
  		AND U.ID = D.ID
  	END
  END
  GO
  
  CREATE TABLE B_LEARN_SITE_PATH
  (
    ID int not null IDENTITY (1, 1),
    SITE_ID char(2) not null,
    PATH varchar(255) not null,
    TYPE char(1) null
  )
  GO
  ALTER TABLE B_LEARN_SITE_PATH ADD CONSTRAINT PK_B_LEARN_SITE_PATH PRIMARY KEY (ID)
  GO
  CREATE UNIQUE INDEX IX_LEARN_SITE_PATH_2 ON B_LEARN_SITE_PATH(SITE_ID, TYPE)
  GO
  
  CREATE TABLE B_LEARN_TEST_MARK (
    ID int not null IDENTITY (1, 1),
    TEST_ID int not null,
    SCORE int not null,
    MARK varchar(50) not null,
    DESCRIPTION text null,
    CONSTRAINT PK_B_LEARN_TEST_MARK PRIMARY KEY (ID),
    CONSTRAINT FK_B_LEARN_TEST_MARK1 FOREIGN KEY (TEST_ID) REFERENCES B_LEARN_TEST(ID)
  )
  GO
  
  CREATE TABLE B_LEARN_GROUPS
  (
  	ID INT NOT NULL IDENTITY (1, 1),
  	ACTIVE CHAR(1) NOT NULL DEFAULT 'Y',
  	TITLE VARCHAR(255) NOT NULL DEFAULT ' ',
  	CODE VARCHAR(50) NULL,
  	SORT INT NOT NULL DEFAULT '500',
  	ACTIVE_FROM DATETIME NULL,
  	ACTIVE_TO DATETIME NULL,
  	COURSE_LESSON_ID INT NOT NULL,
  	CONSTRAINT PK_B_LEARN_GROUPS PRIMARY KEY(ID)
  )
  GO
  
  CREATE TABLE B_LEARN_GROUPS_MEMBER (
  	LEARNING_GROUP_ID int NOT NULL DEFAULT '0',
  	USER_ID int NOT NULL DEFAULT '0',
  	CONSTRAINT PK_B_LEARN_GROUPS_MEMBER PRIMARY KEY (LEARNING_GROUP_ID, USER_ID)
  )
  GO
  
  CREATE INDEX B_LEARN_GROUPS_MEMBER_USER_ID_IBK ON B_LEARN_GROUPS_MEMBER(USER_ID)
  GO
  
  CREATE TABLE B_LEARN_GROUPS_LESSON (
  	LEARNING_GROUP_ID int NOT NULL DEFAULT '0',
  	LESSON_ID int NOT NULL DEFAULT '0',
  	DELAY int NOT NULL DEFAULT '0',
  	CONSTRAINT PK_B_LEARN_GROUPS_LESSON PRIMARY KEY (LEARNING_GROUP_ID, LESSON_ID)
  )
  GO
  
  CREATE INDEX B_LEARN_GROUPS_LESSON_LESSON_ID_IBK ON B_LEARN_GROUPS_LESSON(LESSON_ID)
  GO
  