PageRenderTime 56ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/VideoQuestions.ascx.cs

https://github.com/rajalekshminovasoft/talentscout12-4-2014
C# | 1386 lines | 1135 code | 138 blank | 113 comment | 401 complexity | c85757d17de2e2c15d39ef83d0461885 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Xml.Linq;
  13. public partial class VideoQuestions : System.Web.UI.UserControl
  14. {
  15. string usercode = "";
  16. int userid = 0;
  17. DBManagementClass clsclass = new DBManagementClass();
  18. AssesmentDataClassesDataContext dataclass = new AssesmentDataClassesDataContext();
  19. DataSet ds;
  20. int qusid1 = 0;
  21. int qusid2 = 0;
  22. int qusid3 = 0;
  23. int qusid4 = 0;
  24. int qusid5 = 0;
  25. int qusid6 = 0;
  26. int qusid7 = 0;
  27. int qusid8 = 0;
  28. int qusid9 = 0;
  29. int qusid10 = 0;
  30. int pagecount = 0;
  31. int quesperPage = 1;//bip 121009
  32. int testId = 0; int testsectionid = 0;
  33. double interval = 60; private int test;
  34. protected void Page_Load(object sender, EventArgs e)
  35. {
  36. // PlayVideo("", 1); return;
  37. if (Session["UserTestId"] != null)
  38. {
  39. /// bip 10052010
  40. if (Session["timeExpired"] != null)
  41. if (Session["timeExpired"].ToString() == "True")
  42. {
  43. CheckTime();
  44. return;
  45. }
  46. ///
  47. //if (CheckTime() == true) return;//bip 15052010
  48. FillTitle();
  49. testId = int.Parse(Session["UserTestId"].ToString());
  50. if (Session["UserID"] != null)
  51. {
  52. userid = int.Parse(Session["UserID"].ToString());
  53. FillQuestion();
  54. }
  55. }
  56. }
  57. private void FillVideoQuestionInstructions()
  58. {
  59. int testSecondVariableId = 0, testFirstVariableId = 0, testSectionID = 0;
  60. if (Session["CurrentTestSectionId"] != null)
  61. testSectionID = int.Parse(Session["CurrentTestSectionId"].ToString()); ;
  62. if (Session["CurrentTestSecondVariableId"] != null)
  63. testSecondVariableId = int.Parse(Session["CurrentTestSecondVariableId"].ToString());
  64. if (Session["CurrentTestFirstVariableId"] != null)
  65. testFirstVariableId = int.Parse(Session["CurrentTestFirstVariableId"].ToString());
  66. bool valueexists = false;
  67. DataSet dsInstructiondet = new DataSet();
  68. string quesrystring = "";
  69. if (testSecondVariableId > 0)
  70. quesrystring = "select InstructionDetails,InstructionImage1,InstructionDetails2,InstructionImage2,InstructionDetails3 from TestSectionVariablewiseInstructions where CategoryId =5 and TestId=" + testId + " and TestSectionId =" + testSectionID + " and FirstVariableId=" + testFirstVariableId + " and SecondVariableId =" + testSecondVariableId;
  71. else if (testFirstVariableId > 0)
  72. quesrystring = "select InstructionDetails,InstructionImage1,InstructionDetails2,InstructionImage2,InstructionDetails3 from TestSectionVariablewiseInstructions where CategoryId =5 and TestId=" + testId + " and TestSectionId =" + testSectionID + " and FirstVariableId=" + testFirstVariableId;
  73. dsInstructiondet = clsclass.GetValuesFromDB(quesrystring);
  74. if (dsInstructiondet != null) if (dsInstructiondet.Tables.Count > 0) if (dsInstructiondet.Tables[0].Rows.Count > 0)
  75. {
  76. string styleproperties = "padding-left: 40px";
  77. HtmlTable tblInstructions = new HtmlTable();
  78. HtmlTableRow trInstructions = new HtmlTableRow();
  79. HtmlTableCell tcellInstructions = new HtmlTableCell();
  80. if (dsInstructiondet.Tables[0].Rows[0]["InstructionDetails"].ToString() != null && dsInstructiondet.Tables[0].Rows[0]["InstructionDetails"].ToString() != "")
  81. {
  82. tcellInstructions.InnerHtml = dsInstructiondet.Tables[0].Rows[0]["InstructionDetails"].ToString();
  83. trInstructions.Cells.Add(tcellInstructions);
  84. tblInstructions.Rows.Add(trInstructions);
  85. valueexists = true;
  86. }
  87. if (dsInstructiondet.Tables[0].Rows[0]["InstructionImage1"].ToString() != null && dsInstructiondet.Tables[0].Rows[0]["InstructionImage1"].ToString() != "")
  88. {
  89. trInstructions = new HtmlTableRow();
  90. tcellInstructions = new HtmlTableCell();
  91. tcellInstructions.InnerHtml = "<div style='" + styleproperties + "'><img alt='' src='QuestionAnswerFiles/InstructionImages/" + dsInstructiondet.Tables[0].Rows[0]["InstructionImage1"].ToString() + "' /></div>";
  92. trInstructions.Cells.Add(tcellInstructions);
  93. tblInstructions.Rows.Add(trInstructions);
  94. valueexists = true;
  95. }
  96. if (dsInstructiondet.Tables[0].Rows[0]["InstructionDetails2"].ToString() != null && dsInstructiondet.Tables[0].Rows[0]["InstructionDetails2"].ToString() != "")
  97. {
  98. trInstructions = new HtmlTableRow();
  99. tcellInstructions = new HtmlTableCell();
  100. tcellInstructions.InnerHtml = dsInstructiondet.Tables[0].Rows[0]["InstructionDetails2"].ToString();
  101. trInstructions.Cells.Add(tcellInstructions);
  102. tblInstructions.Rows.Add(trInstructions);
  103. valueexists = true;
  104. }
  105. if (dsInstructiondet.Tables[0].Rows[0]["InstructionImage2"].ToString() != null && dsInstructiondet.Tables[0].Rows[0]["InstructionImage2"].ToString() != "")
  106. {
  107. trInstructions = new HtmlTableRow();
  108. tcellInstructions = new HtmlTableCell();
  109. tcellInstructions.InnerHtml = "<div style='" + styleproperties + "'><img alt='' src='QuestionAnswerFiles/InstructionImages/" + dsInstructiondet.Tables[0].Rows[0]["InstructionImage2"].ToString() + "' /></div>";
  110. trInstructions.Cells.Add(tcellInstructions);
  111. tblInstructions.Rows.Add(trInstructions);
  112. valueexists = true;
  113. }
  114. if (dsInstructiondet.Tables[0].Rows[0]["InstructionDetails3"].ToString() != null && dsInstructiondet.Tables[0].Rows[0]["InstructionDetails3"].ToString() != "")
  115. {
  116. trInstructions = new HtmlTableRow();
  117. tcellInstructions = new HtmlTableCell();
  118. tcellInstructions.InnerHtml = dsInstructiondet.Tables[0].Rows[0]["InstructionDetails3"].ToString();
  119. trInstructions.Cells.Add(tcellInstructions);
  120. tblInstructions.Rows.Add(trInstructions);
  121. valueexists = true;
  122. }
  123. divInstructions.Controls.Clear();
  124. divInstructions.Controls.Add(tblInstructions);
  125. }
  126. if (valueexists == false)
  127. FillCommonInstructions();
  128. // else FillTitle();
  129. }
  130. private void FillTitle()
  131. {
  132. var InstructionDetails = from instructiondet in dataclass.TestInstructions
  133. where instructiondet.CategoryId == 5
  134. select instructiondet;
  135. if (InstructionDetails.Count() > 0)
  136. {
  137. if (InstructionDetails.First().Title != null)
  138. divtitle.InnerHtml = InstructionDetails.First().Title.ToString();
  139. }
  140. }
  141. private void FillCommonInstructions()
  142. {
  143. var InstructionDetails = from instructiondet in dataclass.TestInstructions
  144. where instructiondet.CategoryId == 5
  145. select instructiondet;
  146. if (InstructionDetails.Count() > 0)
  147. {
  148. if (InstructionDetails.First().InstructionDetails != null)
  149. divInstructions.InnerHtml = InstructionDetails.First().InstructionDetails.ToString();
  150. }
  151. }
  152. protected void ptnPrevious_Click(object sender, EventArgs e)
  153. {
  154. Session["displaystatus_video"] = null;
  155. Session["test_video"] = null;
  156. int curcount = 0;
  157. int totalcount = 0, totalquesavail = 0;
  158. if (Session["totalQuesCount_video"] != null)
  159. totalcount = int.Parse(Session["totalQuesCount_video"].ToString());
  160. if (Session["totalQuesAvailable_video"] != null)
  161. totalquesavail = int.Parse(Session["totalQuesAvailable_video"].ToString());
  162. if (totalcount == totalquesavail)
  163. curcount = totalcount;
  164. if (totalcount > totalquesavail)
  165. curcount = totalquesavail;
  166. if (Session["pagecount_video"] != null)
  167. pagecount = int.Parse(Session["pagecount_video"].ToString());
  168. Session["VideoPrevious"] = "True";
  169. int curindex = 0;
  170. curindex = (pagecount - 1) * quesperPage;
  171. if (curindex >= 0)
  172. {
  173. pagecount--;
  174. Session["pagecount_video"] = pagecount; SetCurrentPageCount();// 230110 bip
  175. }
  176. else
  177. {
  178. GoToPreviousPage();
  179. }
  180. FillQuestion();
  181. }
  182. private void GoToPreviousPage()
  183. {
  184. Session["AudioPrevious"] = "True";
  185. //Session["AudioCurrentpage"] = "0";
  186. ClearSessionValues();
  187. Session["evaldirection"] = "Previous";
  188. Session["SubCtrl"] = "AudioQuestions.ascx";
  189. Response.Redirect("FJAHome.aspx");
  190. }
  191. private Boolean CheckTime()//bip 10052010
  192. {
  193. Boolean timeExpired = false;//bip 10052010
  194. if (CheckTestTimeValidity() == true)
  195. {
  196. lblpopup_timer.Text = "The time alloted for your test is completed, <br> If you are interested to take this test again please contact our site admin";
  197. pnlpopup_timer.Visible = true; btnYes_timer_Test.Visible = true; Timer1.Enabled = false;
  198. timeExpired = true; pnlMain.Visible = false; Session["timeExpired"] = "True";//bip 10052010
  199. //return;
  200. }
  201. else if (CheckTimeValidity() == true)
  202. {
  203. lblpopup_timer.Text = "The time alloted for this Test Section is completed, <br> Do you want to continue with the remaining sections under your Test?";
  204. pnlpopup_timer.Visible = true; btnYes_timer.Visible = true; btnNo_timer.Visible = true; Timer1.Enabled = false;
  205. timeExpired = true; pnlMain.Visible = false; Session["timeExpired"] = "True";//bip 10052010
  206. //return;
  207. }
  208. else if (CheckTestSecVarTimeValidity() == true)
  209. {
  210. lblpopup_timer.Text = "The time alloted for this Variable under selected Section is completed, <br> Do you want to continue with the remaining Variables under your Test Section?";
  211. pnlpopup_timer.Visible = true; btnYes_timer_TestVariable.Visible = true; btnNo_timer.Visible = true; Timer1.Enabled = false;
  212. timeExpired = true; pnlMain.Visible = false; Session["timeExpired"] = "True";//bip 10052010
  213. //return;
  214. }
  215. if (timeExpired == true)
  216. {
  217. if (Session["saved"] != null)
  218. if (Session["saved"].ToString() == "true")
  219. return timeExpired;
  220. SaveAnswer(); Session["saved"] = "true";
  221. }
  222. return timeExpired;
  223. }
  224. protected void btnSubmit_Click(object sender, EventArgs e)
  225. {
  226. Boolean timeExpired = CheckTime();
  227. if (timeExpired == false)//bip 10052010
  228. {
  229. if (CheckAnswer() == false)
  230. {
  231. Timer1.Enabled = false;// 04-03-2010 bip
  232. pnlpopup.Visible = true;
  233. return;
  234. }
  235. SaveValues();
  236. }
  237. //else SaveAnswer();//bip 10052010
  238. }
  239. private void SaveValues()
  240. {
  241. SaveAnswer();
  242. Session["displaystatus_video"] = null;
  243. Session["test_video"] = null;
  244. //usercode = Session["UserCode"].ToString();
  245. if (Session["UserID"] != null)
  246. userid = int.Parse(Session["UserID"].ToString());
  247. int curcount = 0;
  248. int totalcount = 0, totalquesavail = 0;
  249. if (Session["totalQuesCount_video"] != null)
  250. totalcount = int.Parse(Session["totalQuesCount_video"].ToString());
  251. if (Session["totalQuesAvailable_video"] != null)
  252. totalquesavail = int.Parse(Session["totalQuesAvailable_video"].ToString());
  253. if (totalcount == totalquesavail)
  254. curcount = totalcount;
  255. if (totalcount > totalquesavail)
  256. curcount = totalquesavail;
  257. if (Session["pagecount_video"] != null)
  258. pagecount = int.Parse(Session["pagecount_video"].ToString());
  259. int curindex = 0;
  260. curindex = (pagecount + 1) * quesperPage;
  261. if (curindex < curcount)
  262. {
  263. pagecount++;
  264. Session["pagecount_video"] = pagecount;SetCurrentPageCount();// 230110 bip
  265. FillQuestion();
  266. }
  267. else
  268. {
  269. ClearSessionValues();
  270. GoToNextPage();
  271. }
  272. }
  273. private void SetCurrentPageCount()
  274. {
  275. testsectionid = int.Parse(Session["CurrentTestSectionId"].ToString());
  276. // //// 220110 ... bip
  277. int testSecondVariableId = 0, testFirstVariableId = 0;
  278. if (Session["CurrentTestSecondVariableId"] != null)
  279. testSecondVariableId = int.Parse(Session["CurrentTestSecondVariableId"].ToString());
  280. if (Session["CurrentTestFirstVariableId"] != null)
  281. testFirstVariableId = int.Parse(Session["CurrentTestFirstVariableId"].ToString());
  282. int questionid = 0; string questiontype = "VideoType";
  283. dataclass.Procedure_UserTestPageIndex_Temp(userid, testId, testsectionid, testFirstVariableId, testSecondVariableId, pagecount, questiontype);
  284. }
  285. private Boolean CheckAnswer()
  286. {
  287. Boolean answercompleted = true;
  288. string answer = "";
  289. if (rbQues1Answer1.Checked == true)
  290. answer = rbQues1Answer1.Text;
  291. else if (rbQues1Answer2.Checked == true)
  292. answer = rbQues1Answer2.Text;
  293. else if (rbQues1Answer3.Checked == true)
  294. answer = rbQues1Answer3.Text;
  295. else if (rbQues1Answer4.Checked == true)
  296. answer = rbQues1Answer4.Text;
  297. else if (rbQues1Answer5.Checked == true)
  298. answer = rbQues1Answer5.Text;
  299. if (answer == "")
  300. {
  301. lblpopup.Text += "You have missed question No:" + lblNo1.Text.Trim() + " Please, complete all questions before moving to the next page. <br> Do you want to go to next page? ";
  302. answercompleted = false;
  303. }
  304. return answercompleted;
  305. }
  306. protected void btnExit_Click(object sender, EventArgs e)
  307. {
  308. Session.Clear();
  309. Session["SubCtrl"] = null;
  310. Response.Redirect("FJAHome.aspx");
  311. }
  312. private DataSet GetQuestionList(int testsectionid)
  313. {
  314. //// bip 07122009
  315. string firstVariableName = ""; string secondVariableName = "";
  316. if (Session["TestFirstVariableName"] != null)
  317. firstVariableName = Session["TestFirstVariableName"].ToString();
  318. if (Session["TestSecondVariableName"] != null)
  319. secondVariableName = Session["TestSecondVariableName"].ToString();
  320. //
  321. DataSet dsQuesCount;
  322. string querystring = "";
  323. DataTable dtQuestionList = new DataTable();
  324. //QuestionID,Question,Answer,Option1,Option2,Option3,Option4,Option5
  325. dtQuestionList.Columns.Add("QuestionID");
  326. dtQuestionList.Columns.Add("Question");
  327. dtQuestionList.Columns.Add("Answer");
  328. dtQuestionList.Columns.Add("QuestionFileName");
  329. dtQuestionList.Columns.Add("Option1");
  330. dtQuestionList.Columns.Add("Option2");
  331. dtQuestionList.Columns.Add("Option3");
  332. dtQuestionList.Columns.Add("Option4");
  333. dtQuestionList.Columns.Add("Option5");
  334. DataRow drQurstionList;
  335. // bip 08122009;
  336. if (secondVariableName != "")
  337. querystring = "select distinct VideoQuestionCount,SectionId from QuestionCount where VideoQuestionCount>0 and TestId=" + testId + " and TestSectionId=" + testsectionid + " and SectionName='" + firstVariableName + "' and SectionNameSub1='" + secondVariableName + "' order by sectionid";
  338. else if (firstVariableName != "")
  339. querystring = "select distinct VideoQuestionCount,SectionId from QuestionCount where VideoQuestionCount>0 and TestId=" + testId + " and TestSectionId=" + testsectionid + " and SectionName='" + firstVariableName + "' order by sectionid";
  340. if (secondVariableName == "" && firstVariableName == "") return null;
  341. DataSet dsQuestioncount = new DataSet();
  342. dsQuestioncount = clsclass.GetValuesFromDB(querystring);
  343. if (dsQuestioncount != null)
  344. if (dsQuestioncount.Tables.Count > 0)
  345. if (dsQuestioncount.Tables[0].Rows.Count > 0)
  346. for (int c = 0; c < dsQuestioncount.Tables[0].Rows.Count; c++)//
  347. {
  348. int videoQuescount = int.Parse(dsQuestioncount.Tables[0].Rows[c]["VideoQuestionCount"].ToString());
  349. int sectionid = int.Parse(dsQuestioncount.Tables[0].Rows[c]["SectionId"].ToString());
  350. if (videoQuescount > 0)
  351. {
  352. querystring = "SELECT TOP (" + videoQuescount + ") QuestionID,Question,Answer,QuestionFileName,Option1,Option2,Option3,Option4,Option5 FROM View_TestBaseQuestionList where Category = 'VideoType' AND TestBaseQuestionStatus=1 AND TestSectionId=" + testsectionid + " AND SectionId=" + sectionid + " AND TestId=" + testId + " ORDER BY RAND((100*QuestionID)*DATEPART(millisecond, GETDATE())) ";
  353. dsQuesCount = new DataSet();
  354. dsQuesCount = clsclass.GetValuesFromDB(querystring);
  355. if (dsQuesCount != null)
  356. if (dsQuesCount.Tables[0].Rows.Count > 0)
  357. {
  358. for (int i = 0; i < dsQuesCount.Tables[0].Rows.Count; i++)
  359. {
  360. drQurstionList = dtQuestionList.NewRow();
  361. drQurstionList["QuestionID"] = dsQuesCount.Tables[0].Rows[i]["QuestionID"];
  362. drQurstionList["Question"] = dsQuesCount.Tables[0].Rows[i]["Question"];
  363. drQurstionList["QuestionFileName"] = dsQuesCount.Tables[0].Rows[i]["QuestionFileName"];
  364. drQurstionList["Answer"] = dsQuesCount.Tables[0].Rows[i]["Answer"];
  365. drQurstionList["Option1"] = dsQuesCount.Tables[0].Rows[i]["Option1"];
  366. drQurstionList["Option2"] = dsQuesCount.Tables[0].Rows[i]["Option2"];
  367. drQurstionList["Option3"] = dsQuesCount.Tables[0].Rows[i]["Option3"];
  368. drQurstionList["Option4"] = dsQuesCount.Tables[0].Rows[i]["Option4"];
  369. drQurstionList["Option5"] = dsQuesCount.Tables[0].Rows[i]["Option5"];
  370. dtQuestionList.Rows.Add(drQurstionList);
  371. }
  372. }
  373. }
  374. }
  375. DataSet dsQuestionList = new DataSet();
  376. if (dtQuestionList.Rows.Count > 0)
  377. {
  378. dsQuestionList.Tables.Add(dtQuestionList); Session["questionColl_video"] = dsQuestionList;
  379. Session["totalQuesCount_video"] = dsQuestionList.Tables[0].Rows.Count.ToString();
  380. }
  381. else { Session["questionColl_video"] = null; dsQuestionList = null; }
  382. return dsQuestionList;
  383. }
  384. private void PlayVideo(string path, int index)
  385. {
  386. string FilePath = "QuestionAnswerFiles/" + path;
  387. if (index == 1)
  388. mpPlayer1.MovieURL = FilePath;
  389. }
  390. private string GetAnswerOptionOrder(int index)
  391. {
  392. string option = "";
  393. if (index == 1)
  394. option = "A";
  395. else if (index == 2)
  396. option = "B";
  397. else if (index == 3)
  398. option = "C";
  399. else if (index == 4)
  400. option = "D";
  401. else if (index == 5)
  402. option = "E";
  403. return option;
  404. }
  405. private DataSet GetTempData()
  406. {
  407. DataSet dsTempData = new DataSet();
  408. //// 220110 ... bip
  409. int testSecondVariableId = 0, testFirstVariableId = 0;
  410. if (Session["CurrentTestSecondVariableId"] != null)
  411. testSecondVariableId = int.Parse(Session["CurrentTestSecondVariableId"].ToString());
  412. if (Session["CurrentTestFirstVariableId"] != null)
  413. testFirstVariableId = int.Parse(Session["CurrentTestFirstVariableId"].ToString());
  414. int questionid = 0; string questiontype = "VideoType";
  415. string querystringquesTemp = "select distinct QuestionId from UserTestQuestions_Temp where UserID=" + userid + " and TestId=" + testId + " and TestSectionId=" + testsectionid + " and FirstVariableId=" + testFirstVariableId + " and QuestionType='" + questiontype + "'";
  416. if (testSecondVariableId > 0)
  417. querystringquesTemp += " and SecondVariableId = " + testSecondVariableId;
  418. DataSet dsquestionIdColl = clsclass.GetValuesFromDB(querystringquesTemp);
  419. if (dsquestionIdColl != null)
  420. if (dsquestionIdColl.Tables.Count > 0)
  421. if (dsquestionIdColl.Tables[0].Rows.Count > 0)
  422. {
  423. string questionids = "";
  424. for (int index = 0; index < dsquestionIdColl.Tables[0].Rows.Count; index++)
  425. {
  426. if (questionids != "")
  427. questionids += " or ";
  428. questionids += " QuestionId=" + dsquestionIdColl.Tables[0].Rows[index]["QuestionId"].ToString();
  429. }
  430. querystringquesTemp = "SELECT QuestionID,Question,Answer,QuestionFileName,Option1,Option2,Option3,Option4,Option5 FROM View_TestBaseQuestionList where " + questionids;
  431. dsTempData = clsclass.GetValuesFromDB(querystringquesTemp);
  432. Session["questionColl_Audio"] = dsTempData;
  433. var GetPageIndex = from pageindex in dataclass.UserTestPageIndex_Temps
  434. where pageindex.UserId == userid && pageindex.TestId == testId && pageindex.TestSectionId == testsectionid &&
  435. pageindex.FirstVariableId == testFirstVariableId && pageindex.SecondVariableId == testSecondVariableId &&
  436. pageindex.QuestionType == questiontype
  437. select pageindex;
  438. if (GetPageIndex.Count() > 0)
  439. {
  440. if (GetPageIndex.First().PageIndex != null)
  441. {
  442. pagecount = int.Parse(GetPageIndex.First().PageIndex.ToString());
  443. Session["pagecount_video"] = pagecount;
  444. Session["displaystatus_video"] = "True";
  445. Session["VideoPrevious"]="True";
  446. Session["VideoCurrentpage"] = pagecount;
  447. }
  448. }
  449. }
  450. else dsTempData = null;
  451. return dsTempData;
  452. }
  453. private void FillQuestion()
  454. {
  455. //try
  456. //{
  457. ClearControls();
  458. string querystring = "";
  459. //int totalQues = 0;
  460. int QuestionID = 0;
  461. if (Session["pagecount_video"] != null)
  462. pagecount = int.Parse(Session["pagecount_video"].ToString());
  463. ds = new DataSet();//int testsectionid = 0;
  464. if (Session["CurrentTestSectionId"] != null)
  465. testsectionid = int.Parse(Session["CurrentTestSectionId"].ToString());
  466. //da.Fill(ds);
  467. if (Session["questionColl_video"] != null)
  468. ds = (DataSet)Session["questionColl_video"];
  469. else
  470. {//bip 081009
  471. //int testsectionid = 0;
  472. if (Session["CurrentTestSectionId"] != null)
  473. {
  474. testsectionid = int.Parse(Session["CurrentTestSectionId"].ToString());
  475. //
  476. // //// 220110 ... bip
  477. int testSecondVariableId = 0, testFirstVariableId = 0;
  478. if (Session["CurrentTestSecondVariableId"] != null)
  479. testSecondVariableId = int.Parse(Session["CurrentTestSecondVariableId"].ToString());
  480. if (Session["CurrentTestFirstVariableId"] != null)
  481. testFirstVariableId = int.Parse(Session["CurrentTestFirstVariableId"].ToString());
  482. int questionid = 0; string questiontype = "VideoType";
  483. ds = GetTempData();
  484. bool newentry = false;
  485. if (ds == null)
  486. {
  487. newentry = true;
  488. ds = GetQuestionList(testsectionid);
  489. }
  490. else if (ds.Tables.Count <= 0)
  491. { newentry = true; ds = GetQuestionList(testsectionid); }
  492. ////.......
  493. //
  494. if (ds == null)
  495. {
  496. string evaldirection = "Next";
  497. if (Session["evaldirection"] != null)
  498. evaldirection = Session["evaldirection"].ToString();
  499. if (evaldirection == "Next")
  500. GoToNextPage();
  501. else GoToPreviousPage();
  502. return;
  503. }
  504. else // store the questiondetails in a temp table.
  505. {
  506. if (newentry == true)
  507. if (ds.Tables.Count > 0)
  508. if (ds.Tables[0].Rows.Count > 0)
  509. {
  510. for (int q = 0; q < ds.Tables[0].Rows.Count; q++)
  511. {
  512. questionid = int.Parse(ds.Tables[0].Rows[q]["QuestionID"].ToString());
  513. dataclass.Procedure_UserTestQuestions_Temp(userid, testId, testsectionid, testFirstVariableId, testSecondVariableId, questionid, questiontype);
  514. }
  515. }
  516. }
  517. }
  518. }
  519. int slno = 0;
  520. slno = pagecount * quesperPage + 1;
  521. if (slno < 0)
  522. slno = 1;
  523. int pagecnt = 0;
  524. int curntquescnt = 0;
  525. int slnos = 0;
  526. if (ds.Tables[0].Rows.Count > 0)
  527. {
  528. bool previousdisplay = false;
  529. int returnpage = 0;
  530. if (Session["VideoPrevious"] != null)
  531. {
  532. if (Session["VideoCurrentpage"] != null)
  533. {
  534. returnpage = int.Parse(Session["VideoCurrentpage"].ToString());
  535. if (pagecount <= returnpage)
  536. { previousdisplay = true; mpPlayer1.Visible = false; imgbtnPlay.Visible = false; }
  537. }
  538. }
  539. if (previousdisplay == false)
  540. {
  541. if (Session["displaystatus_video"] != null)
  542. {
  543. if (Session["displaystatus_video"].ToString() != "True")
  544. {
  545. Session["displaystatus_video"] = "False"; //interval = (interval * 1000); UpdateTimer.Interval = int.Parse(interval.ToString()); UpdateTimer.Enabled = true;
  546. }
  547. }
  548. else { Session["displaystatus_video"] = "False"; imgbtnPlay.Visible = true; mpPlayer1.Visible = false; btnSubmit.Enabled = false; FillVideoQuestionInstructions(); } //interval = 1000; UpdateTimer.Interval = int.Parse(interval.ToString()); UpdateTimer.Enabled = true; }
  549. }
  550. else Session["displaystatus_video"] = "True";
  551. }
  552. if (Session["displaystatus_video"] != null)
  553. if (Session["displaystatus_video"].ToString() == "True")
  554. {
  555. if (ds.Tables[0].Rows.Count > 0)
  556. {
  557. // Session["ValueExists"] = "True";
  558. Session["totalQuesAvailable_video"] = ds.Tables[0].Rows.Count.ToString();
  559. int j = 0;
  560. for (int i = slno - 1; i < ds.Tables[0].Rows.Count; i++)
  561. {
  562. if (j >= quesperPage) break;
  563. string Answer = "";
  564. Session["CurrentControlCtrl"] = "VideoQuestions.ascx";// bip 08012010
  565. Session["ValueExists"] = "True";
  566. Timer1.Enabled = true;// 04-03-2010 bip
  567. UpdateTimer.Enabled = false;// 15052010 bip
  568. switch (j)
  569. {
  570. case 0:
  571. int optindex = 1;
  572. // slnos = CheckSlNo();
  573. lblNo1.Text = slno.ToString() + ". ";
  574. // lblQues1.Text = ds.Tables[0].Rows[i]["Question"].ToString();
  575. tcellQues1.InnerHtml = ds.Tables[0].Rows[i]["Question"].ToString();
  576. lblQuesID1.Text = ds.Tables[0].Rows[i]["QuestionID"].ToString();
  577. var Ques1 = from Ques in dataclass.EvaluationResults
  578. where Ques.UserId == userid && Ques.Question == ds.Tables[0].Rows[i]["Question"].ToString() && Ques.QuestionID == int.Parse(ds.Tables[0].Rows[i]["QuestionID"].ToString()) &&
  579. Ques.TestId == testId && Ques.TestSectionId == testsectionid
  580. select Ques;//Ques.UserCode == usercode &&
  581. if (Ques1.Count() > 0)
  582. if (Ques1.First().Answer != null)
  583. Answer = Ques1.First().Answer.ToString();
  584. if (ds.Tables[0].Rows[i]["Option1"].ToString() != "")
  585. {
  586. rbQues1Answer1.Visible = true; lblA1.Visible = true;
  587. rbQues1Answer1.Text = ds.Tables[0].Rows[i]["Option1"].ToString();
  588. if (ds.Tables[0].Rows[i]["Option1"].ToString() == Answer)
  589. rbQues1Answer1.Checked = true;
  590. optindex++;
  591. }
  592. if (ds.Tables[0].Rows[i]["Option2"].ToString() != "")
  593. {
  594. if (optindex != 2)
  595. lblB1.Text = GetAnswerOptionOrder(optindex);
  596. rbQues1Answer2.Visible = true; lblB1.Visible = true;
  597. rbQues1Answer2.Text = ds.Tables[0].Rows[i]["Option2"].ToString();
  598. if (ds.Tables[0].Rows[i]["Option2"].ToString() == Answer)
  599. rbQues1Answer2.Checked = true;
  600. optindex++;
  601. }
  602. if (ds.Tables[0].Rows[i]["Option3"].ToString() != "")
  603. {
  604. if (optindex != 3)
  605. lblC1.Text = GetAnswerOptionOrder(optindex);
  606. rbQues1Answer3.Visible = true; lblC1.Visible = true;
  607. rbQues1Answer3.Text = ds.Tables[0].Rows[i]["Option3"].ToString();
  608. if (ds.Tables[0].Rows[i]["Option3"].ToString() == Answer)
  609. rbQues1Answer3.Checked = true;
  610. optindex++;
  611. }
  612. if (ds.Tables[0].Rows[i]["Option4"].ToString() != "")
  613. {
  614. if (optindex != 4)
  615. lblD1.Text = GetAnswerOptionOrder(optindex);
  616. rbQues1Answer4.Visible = true; lblD1.Visible = true;
  617. rbQues1Answer4.Text = ds.Tables[0].Rows[i]["Option4"].ToString();
  618. if (ds.Tables[0].Rows[i]["Option4"].ToString() == Answer)
  619. rbQues1Answer4.Checked = true;
  620. optindex++;
  621. }
  622. if (ds.Tables[0].Rows[i]["Option5"].ToString() != "")
  623. {
  624. if (optindex != 5)
  625. lblE1.Text = GetAnswerOptionOrder(optindex);
  626. rbQues1Answer5.Visible = true; lblE1.Visible = true;
  627. rbQues1Answer5.Text = ds.Tables[0].Rows[i]["Option5"].ToString();
  628. if (ds.Tables[0].Rows[i]["Option5"].ToString() == Answer)
  629. rbQues1Answer5.Checked = true;
  630. }
  631. btnSubmit.Enabled = true; divInstructions.InnerHtml = "";
  632. pnlQuestion.Visible = true;// 29122009 bip
  633. imgbtnPlay.Visible = false;
  634. curntquescnt++;
  635. j++;
  636. break;
  637. }
  638. }
  639. }
  640. else { GoToNextPage(); }
  641. Session["curntques"] = curntquescnt;
  642. }
  643. //}
  644. //catch (Exception ex)
  645. //{
  646. // FillQuestion();//bipson 14082010 to avoid arithmetic error... //conn.Close();
  647. //}
  648. }
  649. private void GoToNextPage()
  650. {
  651. // ClearSessionValues();
  652. ClearAllPageCountValues(1);
  653. Session["evaldirection"] = "Next";
  654. Session["SubCtrl"] = "RatingQuestions.ascx";
  655. Response.Redirect("FJAHome.aspx");
  656. }
  657. private void SaveAnswer()
  658. {
  659. string quescategory = "VideoType";
  660. int testsectionid = 0;
  661. if (Session["CurrentTestSectionId"] != null)
  662. testsectionid = int.Parse(Session["CurrentTestSectionId"].ToString());
  663. string answer = "";
  664. if (rbQues1Answer1.Checked == true)
  665. //answer = rbQues1Answer1.Text;
  666. answer = "1";
  667. else if (rbQues1Answer2.Checked == true)
  668. //answer = rbQues1Answer2.Text;
  669. answer = "2";
  670. else if (rbQues1Answer3.Checked == true)
  671. //answer = rbQues1Answer3.Text;
  672. answer = "3";
  673. else if (rbQues1Answer4.Checked == true)
  674. //answer = rbQues1Answer4.Text;
  675. answer = "4";
  676. else if (rbQues1Answer5.Checked == true)
  677. //answer = rbQues1Answer5.Text;
  678. answer = "5";
  679. if (lblQuesID1.Text.Trim() != "")
  680. {
  681. qusid1 = int.Parse(lblQuesID1.Text.Trim());
  682. dataclass.Procedure_QuesAnswers(qusid1, usercode, tcellQues1.InnerHtml, answer, userid, testId, testsectionid,quescategory);
  683. }
  684. answer = "";
  685. }
  686. private void ClearControls()
  687. {
  688. rbQues1Answer1.Checked = false; rbQues1Answer1.Visible = false;
  689. rbQues1Answer2.Checked = false; rbQues1Answer2.Visible = false;
  690. rbQues1Answer3.Checked = false; rbQues1Answer3.Visible = false;
  691. rbQues1Answer4.Checked = false; rbQues1Answer4.Visible = false;
  692. rbQues1Answer5.Checked = false; rbQues1Answer5.Visible = false;
  693. lblA1.Visible = false; lblB1.Visible = false; lblC1.Visible = false; lblD1.Visible = false; lblE1.Visible = false;
  694. lblNo1.Text = "";
  695. lblQues1.Text = "";
  696. tcellVideoQuestion1.InnerHtml = "";
  697. tcellQues1.InnerHtml = "";
  698. }
  699. private void ClearSessionValues()
  700. {
  701. //Session["pagecount_video"] = null;
  702. }
  703. private void ClearAllPageCountValues(int index)
  704. {
  705. if (index == 0)
  706. Session["pagecount_video"] = null;
  707. Session["pagecountRating"] = null;
  708. }
  709. private string GetVideoFileName()
  710. {
  711. string displayvideo = "";
  712. if (Session["test_video"] != null)
  713. test = int.Parse(Session["test_video"].ToString());
  714. if (ds.Tables.Count > 0)
  715. {
  716. if (ds.Tables[0].Rows.Count > 0)
  717. {
  718. if (Session["pagecount_video"] != null)
  719. pagecount = int.Parse(Session["pagecount_video"].ToString());
  720. int slno = 0;
  721. slno = pagecount * quesperPage + 1;
  722. if (slno < 0)
  723. slno = 0;
  724. if (slno > ds.Tables[0].Rows.Count)//
  725. { Session["displaystatus_video"] = "True"; Session["test_video"] = null; return ""; }
  726. if (test > 1) { Session["displaystatus_video"] = "True"; return ""; }
  727. displayvideo = ds.Tables[0].Rows[slno - 1]["QuestionFileName"].ToString();
  728. }
  729. }
  730. return displayvideo;
  731. }
  732. protected void UpdateTimer_Tick(object sender, EventArgs e)
  733. {
  734. /*
  735. /// bip 10052010
  736. if (Session["timeExpired"] != null)
  737. if (Session["timeExpired"].ToString() == "True")
  738. return;
  739. if (CheckTime() == true) { return; }//SaveAnswer();
  740. ///
  741. bool countcompleted = false;
  742. if (Session["test_video"] != null)
  743. test = int.Parse(Session["test_video"].ToString());
  744. test = test + 1;
  745. Session["test_video"] = test.ToString();
  746. string displayvalue = GetVideoFileName();
  747. if (displayvalue == "")
  748. if (Session["displaystatus_video"].ToString() == "True")
  749. { UpdateTimer.Enabled = false; Session["test_video"] = null; FillQuestion(); }
  750. PlayVideo(displayvalue, 1);
  751. // txtmemtypewords.Text = displayword;
  752. if (Session["pagecount_video"] != null)
  753. pagecount = int.Parse(Session["pagecount_video"].ToString());
  754. int slno = 0;
  755. slno = pagecount * quesperPage + 1;
  756. if (slno < 0)
  757. slno = 0;
  758. if (test > 1)
  759. countcompleted = true;
  760. if (countcompleted == true)
  761. { UpdateTimer.Enabled = false; Session["displaystatus_video"] = "True"; Session["test_video"] = null; tcellQues1.InnerHtml = ""; FillQuestion(); }
  762. */
  763. }
  764. protected void lbtnPlay_Click(object sender, EventArgs e)
  765. {
  766. imgbtnClickHere.Visible = true; lblInstruction_ques.Visible = true;lblInstruction_ques1.Visible = true;
  767. string displayvalue = GetVideoFileName(); divInstructions.InnerHtml = "";//FillVideoQuestionInstructions();
  768. PlayVideo(displayvalue, 1);
  769. }
  770. protected void lbtnViewQuestion_Click(object sender, EventArgs e)
  771. {
  772. }
  773. protected void imgbtnPlay_Click(object sender, ImageClickEventArgs e)
  774. {
  775. // PlayVideo("", 1); return;
  776. mpPlayer1.Visible = true; imgbtnPlay.Visible = false;
  777. imgbtnClickHere.Visible = true; lblInstruction_ques.Visible = true; lblInstruction_ques1.Visible = true;
  778. string displayvalue = GetVideoFileName(); divInstructions.InnerHtml = "";//FillVideoQuestionInstructions();
  779. PlayVideo(displayvalue, 1);
  780. }
  781. protected void imgbtnClickHere_Click(object sender, ImageClickEventArgs e)
  782. {
  783. if (Session["pagecount_video"] != null)
  784. pagecount = int.Parse(Session["pagecount_video"].ToString());
  785. Session["VideoCurrentpage"] = pagecount.ToString();
  786. Session["displaystatus_video"] = "True"; mpPlayer1.Visible = false;
  787. imgbtnClickHere.Visible = false; lblInstruction_ques.Visible = false; lblInstruction_ques1.Visible = false;
  788. UpdateTimer.Enabled = false; Session["test_video"] = null; FillQuestion(); divInstructions.InnerHtml = "";
  789. }
  790. protected void btnYes_Click(object sender, EventArgs e)
  791. {
  792. SaveValues(); pnlpopup.Visible = false;
  793. Timer1.Enabled = true;// 04-03-2010 bip
  794. }
  795. // for first level variablewise time setting 24-02-2010 bip
  796. private Boolean CheckTestSecVarTimeValidity()
  797. {
  798. if (Session["TestSectionVariableStartTime"] != null)
  799. {
  800. if (Session["TestSectionVariableTimeDuration"] != null)
  801. {
  802. DateTime dtStart = (DateTime)Session["TestSectionVariableStartTime"];
  803. DateTime dtNow = DateTime.Now;
  804. TimeSpan tsNow = dtNow.Subtract(dtStart);
  805. int hrs = tsNow.Hours;
  806. int min = tsNow.Minutes;
  807. int sec = tsNow.Seconds;
  808. string strDuration = Session["TestSectionVariableTimeDuration"].ToString();
  809. string[] timeValues = strDuration.Split(new char[] { ':' });
  810. int setHrs = int.Parse(timeValues[0].ToString());
  811. int setMin = int.Parse(timeValues[1].ToString());
  812. int setSec = int.Parse(timeValues[2].ToString());
  813. TimeSpan tsDuration = new TimeSpan(setHrs, setMin, setSec);//25-02-2010 bip
  814. bool timeExpired = false;
  815. if (tsNow > tsDuration)
  816. timeExpired = true;
  817. // return true;
  818. TimeSpan tsTimeRemains = tsDuration.Subtract(tsNow);
  819. // 03-02-2010 bip
  820. int firstvariableid = 0;
  821. if (Session["CurrentTestFirstVariableId"] != null)
  822. firstvariableid = int.Parse(Session["CurrentTestFirstVariableId"].ToString());
  823. DataTable dtTimeDetails = new DataTable();
  824. if (Session["FirstvarTimeDet"] == null)
  825. {
  826. dtTimeDetails.Columns.Add("FirstVarID");
  827. dtTimeDetails.Columns.Add("TimeUsed");
  828. dtTimeDetails.Columns.Add("CompletionStatus");
  829. dtTimeDetails.Columns.Add("AssignTime");
  830. dtTimeDetails.Columns.Add("AssignStatus");
  831. }
  832. else
  833. {
  834. dtTimeDetails = (DataTable)Session["FirstvarTimeDet"];
  835. }
  836. bool valueexists = false;
  837. for (int i = 0; i < dtTimeDetails.Rows.Count; i++)
  838. {
  839. int firstvarid = 0;
  840. string competionstatus = "", assigntime = "", timeused = "", assignStatus = "";
  841. if (dtTimeDetails.Rows[i]["FirstVarID"] != null)
  842. firstvarid = int.Parse(dtTimeDetails.Rows[i]["FirstVarID"].ToString());
  843. if (dtTimeDetails.Rows[i]["TimeUsed"] != null)
  844. timeused = dtTimeDetails.Rows[i]["TimeUsed"].ToString();
  845. if (dtTimeDetails.Rows[i]["CompletionStatus"] != null)
  846. competionstatus = dtTimeDetails.Rows[i]["CompletionStatus"].ToString();
  847. if (dtTimeDetails.Rows[i]["AssignTime"] != null)
  848. assigntime = dtTimeDetails.Rows[i]["AssignTime"].ToString();
  849. if (dtTimeDetails.Rows[i]["AssignStatus"] != null)
  850. assignStatus = dtTimeDetails.Rows[i]["AssignStatus"].ToString();
  851. if (firstvariableid == firstvarid)
  852. {
  853. valueexists = true;
  854. if (dtTimeDetails.Rows[i]["CompletionStatus"].ToString() == "1")
  855. return true;
  856. dtTimeDetails.Rows[i]["TimeUsed"] = hrs + ":" + min + ":" + sec;
  857. if (timeExpired == true)
  858. {
  859. dtTimeDetails.Rows[i]["CompletionStatus"] = 1;
  860. Session["FirstvarTimeDet"] = dtTimeDetails;
  861. return true;
  862. }
  863. Session["FirstvarTimeDet"] = dtTimeDetails;
  864. break;
  865. }
  866. }
  867. if (valueexists == false)
  868. {
  869. // code to assign values from here
  870. DataRow drTimedet = dtTimeDetails.NewRow();
  871. drTimedet["FirstVarID"] = firstvariableid;
  872. //drTimedet["CompletionStatus"] = 0;
  873. drTimedet["TimeUsed"] = hrs + ":" + min + ":" + sec;
  874. drTimedet["AssignTime"] = setHrs + ":" + setMin + ":" + 0;
  875. drTimedet["AssignStatus"] = 1;
  876. //dtTimeDetails.Rows.Add(drTimedet);
  877. if (timeExpired == true)
  878. {
  879. drTimedet["CompletionStatus"] = 1;
  880. dtTimeDetails.Rows.Add(drTimedet);
  881. Session["FirstvarTimeDet"] = dtTimeDetails;
  882. return true;
  883. }
  884. drTimedet["CompletionStatus"] = 0;
  885. dtTimeDetails.Rows.Add(drTimedet);
  886. Session["FirstvarTimeDet"] = dtTimeDetails;
  887. }
  888. ////
  889. }
  890. else return CheckTestSecVarGenValidity();
  891. }
  892. //else Session["AudioStatrtTime"] = DateTime.Now;
  893. return false;
  894. }
  895. private Boolean CheckTestSecVarGenValidity()
  896. {
  897. // if (Session["TestSectionVariableTimeDuration"] == null)
  898. if (Session["TotalTimeForUnAssgnSecVariables"] != null)
  899. {
  900. string[] totaltimeforUnAssgn = Session["TotalTimeForUnAssgnSecVariables"].ToString().Split(new char[] { ':' });
  901. int totalHrsforUnAssgn = int.Parse(totaltimeforUnAssgn[0]);
  902. int totalMinforUnAssgn = int.Parse(totaltimeforUnAssgn[1]);
  903. int totalSecforUnAssgn = int.Parse(totaltimeforUnAssgn[2]);
  904. TimeSpan tsUnAssgn = new TimeSpan(totalHrsforUnAssgn, totalMinforUnAssgn, totalSecforUnAssgn);
  905. int genHrs = 0, genMin = 0, genSec = 0;
  906. if (Session["GeneralVariableTimeUsed"] != null)
  907. {
  908. string[] genTimeUsed = Session["GeneralVariableTimeUsed"].ToString().Split(new char[] { ':' });
  909. genHrs = int.Parse(genTimeUsed[0]);
  910. genMin = int.Parse(genTimeUsed[1]);
  911. genSec = int.Parse(genTimeUsed[2]);
  912. TimeSpan tsGeneral = new TimeSpan(genHrs, genMin, genSec);
  913. if (tsGeneral > tsUnAssgn)
  914. return true;
  915. }
  916. //
  917. if (Session["TestSectionVariableStartTime"] != null)
  918. {
  919. DateTime dtStartTime = (DateTime)Session["TestSectionVariableStartTime"];
  920. DateTime dtendTime = DateTime.Now;
  921. TimeSpan tsUsed = dtendTime.Subtract(dtStartTime);
  922. genHrs += tsUsed.Hours;
  923. genMin += tsUsed.Minutes;
  924. genSec += tsUsed.Seconds;
  925. if (genSec >= 60)
  926. {
  927. double getMin = float.Parse(genSec.ToString()) / 60;
  928. string[] newMin = getMin.ToString().Split(new char[] { '.' });
  929. if (newMin.Length > 1)
  930. {
  931. int newminutes = int.Parse(newMin[0]);
  932. genMin += newminutes;
  933. float newSec = float.Parse(getMin.ToString().Substring(1)) * 60;
  934. string[] newSeconds = newSec.ToString().Split(new char[] { '.' });
  935. int seconds = int.Parse(newSeconds[0]);
  936. genSec = seconds;
  937. }
  938. }
  939. if (genMin >= 60)
  940. {
  941. double getHrs = float.Parse(genMin.ToString()) / 60;
  942. string[] newHrs = getHrs.ToString().Split(new char[] { '.' });
  943. if (newHrs.Length > 1)
  944. {
  945. int newhours = int.Parse(newHrs[0]);
  946. genHrs += newhours;
  947. float newMin = float.Parse(getHrs.ToString().Substring(1)) * 60;
  948. string[] newMinutes = newMin.ToString().Split(new char[] { '.' });
  949. int minutes = int.Parse(newMinutes[0]);

Large files files are truncated, but you can click here to view the full file