protected void Page_Load(object sender, EventArgs e)
        {
            if (IsQueryStringMissingParameter(X_ID))
            {
                RedirectToPortalSelectionScreen();
            }
            else
            {
                _assessmentID = GetDecryptedEntityId(X_ID);
            }

            ScriptManager.RegisterStartupScript(this, typeof(string), "encryptedUserID", "var FieldTestFormId=" + AssessmentForm.FieldTestFormId + ";" +
                                                                                            " var UpdatedDataAttached=" + (int)ActionResult.GenericStatus.UpdatedDataAttached + ";"
                                                                                            , true);

            ImageWebFolder = (Request.ApplicationPath.Equals("/") ? "" : Request.ApplicationPath) + "/Images/";
            _selectedAssessment = Assessment.GetAssessmentAndQuestionsByID(_assessmentID);
            _selectedAssessment.LoadForms(true);
            if (_selectedAssessment == null)
            {
                return;
                //_selectedAssessment = Base.Classes.Assessment.GetAssessmentAndQuestionsByID(_assessmentID);
                //Cache.Insert(key, _selectedAssessment, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromHours(2));
            }

            if (!IsPostBack)
            {
                bool hasPermission = SessionObject.LoggedInUser.HasPermission(Permission.Access_SecureTesting);

                if (_assessmentID != 0)
                {
                    selectedAssessment = Thinkgate.Base.Classes.Assessment.GetAssessmentByID(_assessmentID);
                    dictionaryItem = Base.Classes.TestTypes.TypeWithSecureFlag(selectedAssessment.TestCategory);
                    isSecuredFlag = dictionaryItem.Where(x => Boolean.Parse(x.Value.ToString())).Select(y => y.Key).ToList().Distinct().Any();
                    SecureTitle = hasPermission && isSecuredFlag && SecureType;
                        
                }
             
                BindAssessmentItems(_selectedAssessment.Items);
                BindFormData();
                BindRadtab_Forms();
            }

        }
		protected new void Page_Init(object sender, EventArgs e)
		{
			base.Page_Init(sender, e);
			Master.Search += new SearchMaster.SearchHandler(SearchHandler);
			if (!IsPostBack)
			{
				LoadSearchScripts();

                if (Request.QueryString["AssessmentID"] != null)
                {
                   
                        AssessmentID = Convert.ToInt32(Request.QueryString["AssessmentID"]);
                 
                }

                bool hasPermission = SessionObject.LoggedInUser.HasPermission(Permission.Access_SecureTesting);
                Dictionary<string, bool> dictionaryItem;
                string testCategory = string.Empty;
                if (AssessmentID != 0)
                {
                    selectedAssessment = Thinkgate.Base.Classes.Assessment.GetAssessmentByID(AssessmentID);
                    dictionaryItem = Base.Classes.TestTypes.TypeWithSecureFlag(selectedAssessment.TestCategory);
                    bool isSecuredFlag = dictionaryItem != null && dictionaryItem.Where(x => Boolean.Parse(x.Value.ToString()) == true).Select(y => y.Key).ToList().Distinct().Count() > 0 ? true : false;
                    testCategory = selectedAssessment.TestCategory;
                    if (hasPermission && isSecuredFlag)
                    {
                        if (SecureType)
                        {
                            testCategory = selectedAssessment.TestType;
                        }
                    }
                }

                DistrictParms parms = DistrictParms.LoadDistrictParms();
                ShowExpiredItems = (Request.QueryString["ShowExpiredItems"] != "No" && parms.AllowSearchForCopyRightExpiredContent);
                if (!ShowExpiredItems)
			    {
			        ExpirationStatusDateRange.DDLExpirationStatus.Visible = false;
			     }

			    ImageWebFolder = (Request.ApplicationPath.Equals("/") ? string.Empty : Request.ApplicationPath) + "/Images/";

				if (!UserHasPermission(Permission.Icon_Expand_Item))
				{
					ExpandPerm_IconWidth = "0px";
					ExpandPerm_onclick = "";
				}
				else
				{
					ExpandPerm_IconWidth = "17px";
					ExpandPerm_onclick = "onclick=\"expandItem('{{:IDEncrypted}}');\"";
				}

				var serializer = new JavaScriptSerializer();

				var itemBankEditTbl = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser, ThinkgatePermission.PermissionLevelValues.ItemBankEdit, "Search");
				var itemBankCopyTbl = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser, ThinkgatePermission.PermissionLevelValues.ItemBankCopy, "Search");
				serializer.RegisterConverters(new JavaScriptConverter[] { new ToStringSerializer() });
				string renderIBEditArray = "var IBEditArray = [" + serializer.Serialize(itemBankEditTbl) + "]; ";
				renderIBEditArray += "var IBCopyArray = [" + serializer.Serialize(itemBankCopyTbl) + "]; ";
				ScriptManager.RegisterStartupScript(this, typeof(string), "IBEditArray", renderIBEditArray, true);
				//If user does not have the following permission, then we are to hide the "Lexile:" information.
				_perm_Field_Lexile = UserHasPermission(Permission.Field_Lexile);

#if DEBUG
				clientFolder = "";
#else
				clientFolder = AppSettings.AppVirtualPath == "/" ? "" : AppSettings.AppVirtualPath;
#endif

				if (UserHasPermission(Permission.Icon_Expand_Addendum))
				{
					ExpandPerm_IconWidth = "17px";
					ExpandPerm_onclick = "onclick=\"window.open('" + clientFolder + "/Record/AddendumPage.aspx?xID={{:ID_Encrypted}}');\"";
				}
				else
				{
					ExpandPerm_IconWidth = "0px";
					ExpandPerm_onclick = "";
				}

				var courses = CourseMasterList.GetStandardCoursesForUser(SessionObject.LoggedInUser);

                ctrlGradeSubjectCourseStandardSet.JsonDataSource = serializer.Serialize(courses.BuildJsonArray());
				ctrlGradeSubjectCourseStandardSet.ChkGrade.DefaultTexts = PossibleDefaultTexts(Request.QueryString["grade"]);
				ctrlGradeSubjectCourseStandardSet.ChkSubject.DefaultTexts = PossibleDefaultTexts(Request.QueryString["subject"]);
				ctrlGradeSubjectCourseStandardSet.CmbCourse.DefaultTexts = PossibleDefaultTexts(Request.QueryString["coursename"]);
				ctrlAddendumType.ParentDataSource = Addendum.AddendumTypes;
				ctrlAddendumType.ChildDataSource = Addendum.AddendumGenres;

				//cblItemBank.DataSource = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser).DistinctByLabel();
                dtItemBank dtItemBank = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser, ThinkgatePermission.PermissionLevelValues.Read, testCategory).DistinctByLabel();
                //dtItemBank dtItemBank = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser).DistinctByLabel();
                
                TestCategory = Request.QueryString["TestCategory"];

                if (TestCategory != null && TestCategory == AssessmentCategories.District.ToString())
                {
                    for (var rowIndex = dtItemBank.Rows.Count - 1; rowIndex >= 0; rowIndex--)
                    {
                        if (dtItemBank.Rows[rowIndex]["Label"].ToString() == "Personal")
                        { dtItemBank.Rows[rowIndex].Delete(); }
                    }
                }
                cblItemBank.DataSource = dtItemBank;

				txtSearch.DataSource = TextSearchDropdownValues();
				SortBar.DataSource = SortFields();
			}
		}
        protected new void Page_Init(object sender, EventArgs e)
        {
            base.Page_Init(sender, e); 
            Master.Search += new SearchMaster.SearchHandler(SearchHandler);
            if (!IsPostBack)
            {
                LoadSearchScripts();

                DistrictParms parms = DistrictParms.LoadDistrictParms();
                ShowExpiredItems = (Request.QueryString["ShowExpiredItems"] != "No" && parms.AllowSearchForCopyRightExpiredContent);
                if (!ShowExpiredItems)
                    ExpirationStatusDateRange.DDLExpirationStatus.Visible = false;

                ImageWebFolder = (Request.ApplicationPath.Equals("/") ? string.Empty : Request.ApplicationPath) + "/Images/";

                if (!UserHasPermission(Permission.Icon_Expand_Image))
                {
                    ExpandPerm_IconWidth = "0px";
                    ExpandPerm_onclick = "";
                }
                else
                {
                    ExpandPerm_IconWidth = "17px";
                    ExpandPerm_onclick = " onclick=\"window.open('../../Record/ImagePage.aspx?xID={{:ID_Encrypted}}');\"";
                }
                
                var serializer = new JavaScriptSerializer();

                var itemBankEditTbl = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser, ThinkgatePermission.PermissionLevelValues.ItemBankEdit, "Search");
                serializer.RegisterConverters(new JavaScriptConverter[] { new ToStringSerializer() });
                string renderIBEditArray = "var IBEditArray = [" + serializer.Serialize(itemBankEditTbl) + "]; ";
                ScriptManager.RegisterStartupScript(this, typeof(string), "IBEditArray", renderIBEditArray, true);
                //If user does not have the following permission, then we are to hide the "Lexile:" information.
                
//#if DEBUG
//                clientFolder = "";
//#else
//                clientFolder = AppSettings.AppVirtualPath;
//#endif
                if (Request.QueryString["xID"]!= null)
                {
                    if(Cryptography.GetDecryptedID(SessionObject.LoggedInUser.CipherKey)<= 0)
                    {
                        
                    }
                else
                    {
                        AssessmentID =
                            Cryptography.GetDecryptedID(SessionObject.LoggedInUser.CipherKey);
                    }
                }

                bool hasPermission = SessionObject.LoggedInUser.HasPermission(Permission.Access_SecureTesting);
                Dictionary<string, bool> dictionaryItem;
                string testCategory = string.Empty;
                if (AssessmentID != 0)
                {
                    selectedAssessment =
                        Thinkgate.Base.Classes.Assessment.GetAssessmentByID(AssessmentID);
                    dictionaryItem = Base.Classes.TestTypes.TypeWithSecureFlag(selectedAssessment.TestCategory);
                    bool isSecuredFlag = dictionaryItem != null && dictionaryItem.Where(x => Boolean.Parse(x.Value.ToString())).Select(y => y.Key).ToList().Distinct().Any();
                    testCategory = selectedAssessment.TestCategory;
                    if (hasPermission && isSecuredFlag && SecureType)
                        testCategory = selectedAssessment.TestType;
                  
                }

                var courses = CourseMasterList.GetStandardCoursesForUser(SessionObject.LoggedInUser);
                ctrlGradeSubjectCourseStandardSet.JsonDataSource = serializer.Serialize(courses.BuildJsonArray());
                ctrlGradeSubjectCourseStandardSet.ChkGrade.DefaultTexts = PossibleDefaultTexts(Request.QueryString["grade"]);
                ctrlGradeSubjectCourseStandardSet.ChkSubject.DefaultTexts = PossibleDefaultTexts(Request.QueryString["subject"]);
                ctrlGradeSubjectCourseStandardSet.CmbCourse.DefaultTexts = PossibleDefaultTexts(Request.QueryString["coursename"]);
                //cblItemBank.DataSource = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser).DistinctByLabel();
                dtItemBank dtItemBank = ItemBankMasterList.GetItemBanksForUser(SessionObject.LoggedInUser, ThinkgatePermission.PermissionLevelValues.Read, testCategory).DistinctByLabel();
                

                cblItemBank.DataSource = dtItemBank;
                

                txtSearch.DataSource = TextSearchDropdownValues();
                SortBar.DataSource = SortFields();
            } 
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            SessionObject = (Thinkgate.Classes.SessionObject)Page.Session["SessionObject"];

           if (String.IsNullOrEmpty(Request.QueryString["xID"]) && String.IsNullOrEmpty(Request.QueryString["yID"]))
            {
                subject = SessionObject.AssessmentBuildParms.ContainsKey("Subject") ? SessionObject.AssessmentBuildParms["Subject"] : "";
                courseID = SessionObject.AssessmentBuildParms.ContainsKey("Course") ? DataIntegrity.ConvertToInt(SessionObject.AssessmentBuildParms["Course"]) : 0;
                Base.Classes.Course assessmentCourse = CourseMasterList.GetCurrCourseById(courseID);
                courseName = assessmentCourse != null ? assessmentCourse.CourseName : "";
                grade = SessionObject.AssessmentBuildParms.ContainsKey("Grade") ? SessionObject.AssessmentBuildParms["Grade"] : "";
                type = SessionObject.AssessmentBuildParms.ContainsKey("Type") ? SessionObject.AssessmentBuildParms["Type"] : "";
                term = SessionObject.AssessmentBuildParms.ContainsKey("Term") ? DataIntegrity.ConvertToInt(SessionObject.AssessmentBuildParms["Term"]) : 0;
                content = SessionObject.AssessmentBuildParms.ContainsKey("Content") ? SessionObject.AssessmentBuildParms["Content"] : "";
                includeFieldTest = SessionObject.AssessmentBuildParms.ContainsKey("IncludeFieldTest") ? SessionObject.AssessmentBuildParms["IncludeFieldTest"] : "";
                description = SessionObject.AssessmentBuildParms.ContainsKey("Description") ? SessionObject.AssessmentBuildParms["Description"] : "";
                currUserID = SessionObject.LoggedInUser != null ? (SessionObject.LoggedInUser.Page > 0 ? SessionObject.LoggedInUser.Page : AppSettings.Demo_TeacherID) : AppSettings.Demo_TeacherID;
                testCategory = SessionObject.AssessmentBuildParms.ContainsKey("TestCategory") ? SessionObject.AssessmentBuildParms["TestCategory"] : "Classroom";
                AssessmentType = type;
                bool hasPermission = SessionObject.LoggedInUser.HasPermission(Permission.Access_SecureTesting);
                Dictionary<string, bool> dictionaryItem = Base.Classes.TestTypes.TypeWithSecureFlag(testCategory);
                bool isSecuredFlag = dictionaryItem != null && dictionaryItem.Where(x => Boolean.Parse(x.Value.ToString())).Select(y => y.Key).ToList().Distinct().Any();
                
                hiddenAccessSecureTesting.Value = hasPermission.ToString();
                hiddenIsSecuredFlag.Value = isSecuredFlag.ToString();
                hiddenSecureType.Value = AssessmentSecureType.ToString();

            }
            else
            {
                if (_assessment == null)
                    LoadAssessment();
               
                    bool hasPermission = SessionObject.LoggedInUser.HasPermission(Permission.Access_SecureTesting);
                    if (!IsPostBack)
                    {
                        if (_assessment.AssessmentID != 0)
                        {
                            selectedAssessment = Base.Classes.Assessment.GetAssessmentByID(_assessment.AssessmentID);
                            dictionaryItem = TestTypes.TypeWithSecureFlag(selectedAssessment.TestCategory);
                            isSecuredFlag = dictionaryItem != null && dictionaryItem.Where(x => Boolean.Parse(x.Value.ToString())).Select(y => y.Key).ToList().Distinct().Any();
                            SecureTitle = hasPermission && isSecuredFlag && SecureType;

                        }
                    

                    hiddenAccessSecureTesting.Value = hasPermission.ToString();
                    hiddenIsSecuredFlag.Value = isSecuredFlag.ToString();
                    hiddenSecureType.Value = SecureType.ToString();

                    subject = _assessment.Subject;
                    courseName = _assessment.Course;
                    grade = _assessment.Grade;
                    type = _assessment.TestType;
                    term = DataIntegrity.ConvertToInt(_assessment.Term);
                    content = _assessment.ContentType;

                    if (SessionObject.AssessmentBuildParms.ContainsKey("IncludeFieldTest"))
                    {
                        SessionObject.AssessmentBuildParms.Remove("IncludeFieldTest");
                    }

                    SessionObject.AssessmentBuildParms.Add(
                        "IncludeFieldTest",
                        _assessment.IncludeFieldTest ? "Yes" : "No");
                    includeFieldTest = _assessment.IncludeFieldTest ? "Yes" : "No";

                    description = _assessment.Description;
                    currUserID = SessionObject.LoggedInUser != null
                        ? (SessionObject.LoggedInUser.Page > 0
                            ? SessionObject.LoggedInUser.Page
                            : AppSettings.Demo_TeacherID)
                        : AppSettings.Demo_TeacherID;

                    _ds = ThinkgateDataAccess.FetchDataSet(
                        "E3_Assessment_GetByID",
                        new object[]
                        {
                            _assessmentID,
                            currUserID
                        });
                    _ds.Tables[0].TableName = "Summary";
                    _ds.Tables[1].TableName = "StandardQuestionCounts";
                    _ds.Tables[2].TableName = "RigorCounts";
                    isPDFView = Request.QueryString["printPDFView"] == "yes";
                }
            }
        }