{
  "pluginname": "Online Lesson",
  "systemplugin": "0",
  "version": "1.4",
  "table_def": [
    {
      "name": "online_lesson",
      "fields": [
        {
          "name": "courseid",
          "type": "uniqueidentifier",
          "other": "NOT NULL"
        },
        {
          "name": "lesson_no",
          "type": "tinyint",
          "other": "NOT NULL"
        },
		{
          "name": "lesson_order",
          "type": "tinyint",
          "other": "NOT NULL DEFAULT 1"
        },
        {
          "name": "title",
          "type": "varchar(500)",
          "other": "NOT NULL"
        },
        {
          "name": "type",
          "type": "varchar(30)",
          "other": "NOT NULL"
        },
        {
          "name": "material",
          "type": "varchar(7000)",
          "other": "NOT NULL"
        },
        {
          "name": "options",
          "type": "varchar(1000)"
        },
        {
          "name": "status",
          "type": "tinyint",
          "other": "NOT NULL DEFAULT 1"
        },{
          "name": "launchdate",
          "type": "datetime"
        },{
          "name": "expirydate",
          "type": "datetime"
        }
      ]
    },{"name":"online_course_read_tracker","fields":[{"name":"mycourseid","type":"uniqueidentifier","other":"NOT NULL"},{"name":"onlinecourse_lessonid","type":"uniqueidentifier","other":"NOT NULL"},{"name":"read_status","type":"tinyint","other":"NOT NULL"},{"name":"notes","type":"varchar(2000)","other":"NOT NULL"},{"name":"lesson_color_codings","type":"varchar(1000)","other":"NOT NULL"},{"name":"mark","type":"tinyint","other":"NOT NULL DEFAULT 0"},{"name":"responses","type":"varchar(1500)","other":"NOT NULL"}]},
	  {"name":"online_course_resources","fields":[{"name":"lessonid","type":"uniqueidentifier","other":"NOT NULL"},{"name":"documentname","type":"varchar(200)","other":"NOT NULL"},{"name":"link","type":"varchar(500)","other":"NOT NULL"},{"name":"status","type":"tinyint","other":"NOT NULL DEFAULT 1"}]}
  ],
  "sqlcommands_oninstall": [],
  "form": {
    "name": "online_lesson",
    "formtype": "Default",
    "title": "Online Lesson",
    "icon": "mif-file-text",
    "saveButton": "true",
    "savecustomid":6,
	"getrecordcustomid":7,
    "cancelButton": "true",
    "flex_row": "true",
    "flex_justify": "start",
    "width": "800px",
    "field": [
      {
        "name": "courseid",
        "label": "Course",
        "fieldtype": "u",
        "type": "select",
        "option": "SELECT id,title FROM online_course WHERE status=1",
        "required": "Yes"
      },
      {
        "name": "lesson_no",
        "label": "Lesson Number (Numeric)",
        "fieldtype": "n",
        "type": "text",
        "required": "Yes"
      },{
        "name": "lesson_order",
        "label": "Lesson Order (Numeric)",
        "fieldtype": "n",
        "type": "text",
        "required": "Yes"
      },
      {
        "name": "title",
        "label": "Lesson Title",
        "fieldtype": "s",
        "type": "text",
        "required": "Yes",
		"maxlength":"500"
      },
      {
        "name": "type",
        "label": "Lesson Type",
        "fieldtype": "s",
        "type": "select",
        "option": "Reading,Image,Audio,Video,Multiple Option Question,Discussion,Slider,Upload Document Page,Youtube Video",
        "required": "Yes"
      },
      {
        "name": "material",
        "label": "Lesson Material",
        "fieldtype": "s",
        "type": "textarea",
        "required": "Yes"
      },
      {
        "name": "options",
        "label": "Lesson Option",
        "fieldtype": "s",
        "type": "textarea",
		"maxlength":"1000"
      },{
        "name": "launchdate",
        "label": "Launch Date",
        "fieldtype": "dt",
        "type": "datetime"
      }
    ]
  },
  "form_html": "",
  "navbutton": [
    {
      "customid": "1",
      "caption": "Lesson",
      "icon": "mif-file-text fg-orange",
      "btntype": "ribbon-button",
      "btngroup": "Online Course",
      "btntab": "Online Education",
      "btnorder": "3",
      "onclick": "initializePlugin()"
    }
  ],
  "script": "",
  "formbuttons": [
    {
      "name": "addLesson",
      "icon": "mif-plus",
      "onclick": "showNewForm('online_lesson')"
    },
    {
      "name": "activeLesson",
      "caption": "Active Lesson",
      "icon": "mif-file-text",
      "onclick": "getTableFromSqlStatement('1')"
    },
    {
      "name": "inactiveLesson",
      "caption": "Inactive Lesson",
      "icon": "mif-file-text",
      "onclick": "getTableFromSqlStatement('2')"
    },
    {
      "name": "deletedLesson",
      "caption": "Deleted Lesson",
      "icon": "mif-file-text",
      "onclick": "getTableFromSqlStatement('3')"
    },{
      "name": "downloadAssignment",
      "caption": "Download Assignment",
      "icon": "mif-file-text",
      "onclick": "getTableFromSqlStatement('4')"
    },{
      "name": "TestResults",
      "caption": "Student Tests",
      "icon": "mif-file-text",
      "onclick": "getTableFromSqlStatement('4a')"
    }
  ],
  "sqlstatement": [
    {
      "customid": "1",
      "name": "activeLesson",
      "sql": {"action":"Get Table","formname":"online_lesson","fld":"b.title,a.lesson_no,a.title,a.type","tbl":"online_lesson a","join":"INNER JOIN online_course b ON a.courseid=b.id INNER JOIN online_author c ON b.authorid=c.id","whr":"a.status=1"},
      "header": "Course,Lesson No,Title,Type",
      "filter": "1",
      "filter_fields": "a.courseid",
      "filter_fields_operator": "=",
      "filter_fields_caption": "Select Course",
      "filter_fields_type": "s",
      "filter_fields_inputtype": "select",
      "filter_fields_option": [{"fieldname":"a.courseid","option":"SELECT id,title FROM online_course WHERE status=1"}],
      "edit_record": "1",
      "delete_record": "0",
      "restore_record": "0",
      "change_status": "0:Suspend:Lesson Suspended:Lesson Suspension Failed"
    },
    {
      "customid": "2",
      "name": "inactiveLesson",
      "sql": {"action":"Get Table","fld":"b.title,a.lesson_no,a.title,a.type","tbl":"online_lesson a","join":"INNER JOIN online_course b ON a.courseid=b.id","whr":"a.status=0"},
      "header": "Course,Lesson No,Title,Type",
      "filter": "1",
      "filter_fields": "a.courseid",
      "filter_fields_operator": "=",
      "filter_fields_caption": "Select Course",
      "filter_fields_type": "s",
      "filter_fields_inputtype": "select",
      "filter_fields_option": [{"fieldname":"a.courseid","option":"SELECT id,title FROM online_course WHERE status=0"}],
      "edit_record": "0",
      "delete_record": "1",
      "restore_record": "0",
      "change_status": "1:Activate:Lesson Activated:Lesson Activation Failed"
    },
    {
      "customid": "3",
      "name": "deletedLesson",
      "sql": {"action":"Get Table","fld":"b.title,a.lesson_no,a.title,a.type","tbl":"online_lesson a","join":"INNER JOIN online_course b ON a.courseid=b.id","whr":"a.recordstatus=0"},
      "header": "Course,Lesson No,Title,Type",
      "filter": "1",
      "filter_fields": "a.courseid",
      "filter_fields_operator": "=",
      "filter_fields_caption": "Select Course",
      "filter_fields_type": "s",
      "filter_fields_inputtype": "select",
      "filter_fields_option": [{"fieldname":"a.courseid","option":"SELECT id,title FROM online_course WHERE status=1"}],
      "edit_record": "0",
      "delete_record": "0",
      "restore_record": "1"
    },{
      "customid": "4",
      "name": "downloadAssignment",
      "sql": {"action":"Get Table","fld":"c.title,b.title","tbl":"online_course_read_tracker a","join":"INNER JOIN online_lesson b ON a.onlinecourse_lessonid=b.id INNER JOIN online_course c ON b.courseid=c.id INNER JOIN online_course_mycourse e ON e.createdby=a.createdby AND e.courseid=b.courseid","whr":"b.type='Upload Document Page' AND (a.responses is not null and a.responses!='') and e.expirydate>='||TODAY||'","grp":"c.title,b.title,b.courseid"},
      "header": "Course,Lesson Name",
      "filter": "1",
      "filter_fields": "b.courseid",
      "filter_fields_operator": "=",
      "filter_fields_caption": "Select Course",
      "filter_fields_type": "s",
      "filter_fields_inputtype": "select",
      "filter_fields_option": [{"fieldname":"b.courseid","option":"SELECT id,title FROM online_course WHERE status=1"}],
      "edit_record": "0",
      "delete_record": "0",
      "restore_record": "0",
	  "function1":"downloadAssignment:a.onlinecourse_lessonid:Download Assignment",
	  "set_appendix":"5:LESSONID:a.onlinecourse_lessonid:count(*):No. of Assignment Submitted"
    },{
      "customid": "4a",
      "name": "Test",
      "sql": {"action":"Get Table","fld":"c.title,b.title","tbl":"online_course_read_tracker a","join":"INNER JOIN online_lesson b ON a.onlinecourse_lessonid=b.id INNER JOIN online_course c ON b.courseid=c.id INNER JOIN online_course_mycourse e ON e.createdby=a.createdby AND e.courseid=b.courseid","whr":"b.type='Test' AND (a.responses is not null and a.responses!='') and e.expirydate>='||TODAY||'","grp":"c.title,b.title,b.courseid"},
      "header": "Course,Lesson Name",
      "filter": "1",
      "filter_fields": "b.courseid",
      "filter_fields_operator": "=",
      "filter_fields_caption": "Select Course",
      "filter_fields_type": "s",
      "filter_fields_inputtype": "select",
      "filter_fields_option": [{"fieldname":"b.courseid","option":"SELECT id,title FROM online_course WHERE status=1"}],
      "edit_record": "0",
      "delete_record": "0",
      "restore_record": "0",
	  "set_appendix":"5a:LESSONID:a.onlinecourse_lessonid:count(*):No. of Test Submitted"
    },{
      "customid": "5",
      "name": "AssignmentSubmittedBy",																						
      "sql": {"action":"Get Table","param":"LESSONID","fld":"e.fullname,a.createdon,a.modifiedon,CONCAT('<a target=''_blank'' href=''',a.responses,'''>Link</a>'),CONCAT('<input title=''Mark'' onblur=''changeRecordValue(\\\"',a.id,'\\\",\\\"online_course_read_tracker\\\",\\\"mark\\\",$(this).val(),\\\"n\\\",\\\"Mark Saving Successful\\\",\\\"Mark Saving Failed\\\",$(this).parent().parent())'' value=''',a.mark,'''>'),CONCAT('<a href=''#'' title=''Delete'' onclick=''changeRecordValue(\\\"',a.id,'\\\",\\\"online_course_read_tracker\\\",\\\"responses\\\",\\\"\\\",\\\"s\\\",\\\"Deleted Successful\\\",\\\"Deleting Failed\\\",$(this).parent().parent())''>X</a>')","tbl":"online_course_read_tracker a","join":"INNER JOIN online_lesson b ON a.onlinecourse_lessonid=b.id INNER JOIN online_course c ON b.courseid=c.id INNER JOIN online_course_mycourse d ON c.id=d.courseid AND a.createdby=d.createdby INNER JOIN online_course_users e ON d.createdby=e.id","whr":"b.type='Upload Document Page' AND d.expirydate>='||TODAY||' and (a.responses is not null and a.responses!='') and a.onlinecourse_lessonid='||LESSONID||'"},
      "header": "Student Name,Submitted on1,Submitted on2,Assignment Link,Mark,Delete Assignment",
      "filter": "0"
    },{
		"customid":"36l2",
		"name":"GetTestAnswer",
		"sql":{"action":"Get Value","validate":"users","param":"LESSONID,CREATEDBY","outputto":"html","output":"test","tbl":"online_course_read_tracker","fld":"responses","whr":"onlinecourse_lessonid='||LESSONID||' and createdby='||CREATEDBY||'"}
	},{
		"customid":"36l3",
		"name":"GetTestQuestions",
		"sql":{"action":"Get Value","validate":"users","param":"LESSONID","outputto":"html","output":"question","tbl":"online_lesson","fld":"material","whr":"id='||LESSONID||'"}
	},{
      "customid": "5a",
      "name": "TestSubmittedBy",																						
      "sql": {"action":"Get Table","param":"LESSONID","fld":"e.fullname,a.createdon,a.modifiedon,CONCAT('<input title=''Mark'' onblur=''changeRecordValue(\\\"',a.id,'\\\",\\\"online_course_read_tracker\\\",\\\"mark\\\",$(this).val(),\\\"n\\\",\\\"Mark Saving Successful\\\",\\\"Mark Saving Failed\\\",$(this).parent().parent())'' value=''',a.mark,'''>'),CONCAT('<a href=''#'' title=''Delete'' onclick=''changeRecordValue(\\\"',a.id,'\\\",\\\"online_course_read_tracker\\\",\\\"responses\\\",\\\"\\\",\\\"s\\\",\\\"Deleted Successful\\\",\\\"Deleting Failed\\\",$(this).parent().parent())''>X</a>')","tbl":"online_course_read_tracker a","join":"INNER JOIN online_lesson b ON a.onlinecourse_lessonid=b.id INNER JOIN online_course c ON b.courseid=c.id INNER JOIN online_course_mycourse d ON c.id=d.courseid AND a.createdby=d.createdby INNER JOIN online_course_users e ON d.createdby=e.id","whr":"b.type='Test' AND d.expirydate>='||TODAY||' and (a.responses is not null and a.responses!='') and a.onlinecourse_lessonid='||LESSONID||'"},
      "header": "Student Name,Submitted on1,Submitted on2,Mark,Delete Test",
	  "function1":"showTestAnswers:a.onlinecourse_lessonid,a.createdby:View Test Answer",
      "filter": "0"
    },{
		"customid":"6",
		"name":"saveLesson",
		"sql":{"action":"Save Table","validate":"users","outputto":"html","output":"res","command":"insertorupdate","tbl":"online_lesson","fld":"courseid,lesson_no,lesson_order,title,type,material,options,launchdate","fldtype":"u,n,n,s,s,s,s,dt","value":"||courseid||,||lesson_no||,||lesson_order||,||title||,||type||,||material||,||options||,||launchdate||","whr":"id='||ID||'","param":"courseid,lesson_no,lesson_order,title,type,material,options,launchdate,ID","successmsg":"Saving Successful","failuremsg":"Saving Failed"}
	},{
		"customid":"7",
		"name":"getRecord",
		"sql":{"action":"Get Row","validate":"users","outputto":"html","output":"edit","tbl":"online_lesson","fld":"id,courseid,lesson_no,lesson_order,title,type,material,options,launchdate","whr":"id='||ID||'","param":"ID"}
	}
  ]
}