Exemple #1
0
        /// <summary>
        /// Converts a value returned from a LearningStore query to a
        /// <c>ActivityPackageItemIdentifier</c>.  Throws an exception if the value is
        /// <c>DBNull</c>.
        /// </summary>
        ///
        /// <param name="value">A value from a <c>DataRow</c> within a <c>DataTable</c>
        /// returned from a LearningStore query.</param>
        ///
        /// <param name="result">Where to store the result.</param>
        ///
        public static void CastNonNull(object value, out ActivityPackageItemIdentifier result)
        {
            LearningStoreItemIdentifier id;

            CastNonNull(value, out id);
            result = new ActivityPackageItemIdentifier(id);
        }
Exemple #2
0
        /// <summary>
        /// Retrieves attempt identifier for specified organization id and Iudico topic id.
        /// </summary>
        /// <param name="orgId"><c>ActivityPackageItemIdentifier</c> value representing Organization ID.</param>
        /// <param name="curriculumChapterTopicId">Integer value - IUDICO curriculum chapter topic id.</param>
        /// <param name="topicType"><see cref="TopicTypeEnum"/> value.</param>
        /// <returns><c>AttemptItemIdentifier</c> value representing Attempt Identifier.</returns>
        protected AttemptItemIdentifier GetAttemptIdentifier(
            ActivityPackageItemIdentifier orgId, int curriculumChapterTopicId, TopicTypeEnum topicType)
        {
            AttemptItemIdentifier result = null;
            LearningStoreJob      job    = this.LStore.CreateJob();

            LearningStoreQuery query = this.LStore.CreateQuery(Schema.MyAttemptIds.ViewName);

            query.AddColumn(Schema.MyAttemptIds.AttemptId);
            query.SetParameter(Schema.MyAttemptIds.CurriculumChapterTopicId, curriculumChapterTopicId);
            query.SetParameter(Schema.MyAttemptIds.OrganizationId, orgId);
            query.SetParameter(Schema.MyAttemptIds.TopicType, topicType);

            job.PerformQuery(query);

            ReadOnlyCollection <object> resultList = job.Execute();

            var dataTable = (DataTable)resultList[0];

            if (dataTable.Rows.Count > 0)
            {
                // get last result
                LStoreHelper.Cast(dataTable.Rows[dataTable.Rows.Count - 1][Schema.MyAttemptIds.AttemptId], out result);
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Converts a value returned from a LearningStore query to a
        /// <c>ActivityPackageItemIdentifier</c>, or <c>null</c> if the value is <c>DBNull</c>.
        /// </summary>
        ///
        /// <param name="value">A value from a <c>DataRow</c> within a <c>DataTable</c>
        /// returned from a LearningStore query.</param>
        ///
        /// <param name="result">Where to store the result.</param>
        ///
        public static void Cast(object value, out ActivityPackageItemIdentifier result)
        {
            LearningStoreItemIdentifier id;

            Cast(value, out id);
            result = (id == null) ? null : new ActivityPackageItemIdentifier(id);
        }
Exemple #4
0
        /// <summary>
        /// Creates attempt on given organization and returns attempt identifier.
        /// </summary>
        /// <param name="orgID">Long integer value represents organization identifier to create attempt on.</param>
        /// <returns>Long integer value, representing attempt identifier of created attempt.</returns>
        public long CreateAttempt(long orgID)
        {
            ActivityPackageItemIdentifier organizationID = new ActivityPackageItemIdentifier(orgID);

            StoredLearningSession session = StoredLearningSession.CreateAttempt(this.PStore, this.CurrentUserIdentifier, organizationID, LoggingOptions.LogAll);

            long attemptID = session.AttemptId.GetKey();

            return(attemptID);
        }
    protected void CreateAttemptButton_Click(object sender, EventArgs e)
    {
        // the hidden "Create Attempt" button was auto-clicked by script on page load...

        // prevent script from clicking "Create Attempt" again
        AutoPostScript.Visible = false;

        // hide the "please wait" panel
        PleaseWait.Visible = false;

        // the OrganizationId hidden form element contains the ID of the organization to attempt --
        // try to create a new attempt based on that ID; an organization is a root-level activity,
        // so OrganizationId is actually an ActivityPackageItemIdentifier
        try
        {
            // set <currentUser> to information about the current user; we
            // need the current user's UserItemIdentifier
            LStoreUserInfo currentUser = GetCurrentUserInfo();

            // set <organizationId> from the OrganizationId hidden form element as described above
            ActivityPackageItemIdentifier organizationId = new ActivityPackageItemIdentifier(
                Convert.ToInt64(OrganizationId.Value, CultureInfo.InvariantCulture));

            // create an attempt on <organizationId>
            StoredLearningSession session = StoredLearningSession.CreateAttempt(PStore,
                                                                                currentUser.Id, organizationId, LoggingOptions.LogAll);

            // the operation was successful, and there are no messages to display to the user, so
            // update the AttemptId hidden form element with the ID of the newly-created attempt,
            // update the parent page, and close the dialog
            AttemptId.Value = Convert.ToString(session.AttemptId.GetKey(), CultureInfo.InvariantCulture);
            UpdateParentPageScript.Visible = true;
            CloseDialogScript.Visible      = true;
        }
        catch (Exception ex)
        {
            // an unexpected error occurred -- display a generic message that
            // doesn't include the exception message (since that message may
            // include sensitive information), and write the exception message
            // to the event log
            ErrorIntro.Visible   = true;
            ErrorMessage.Visible = true;
            ErrorMessage.Controls.Add(new System.Web.UI.LiteralControl(
                                          Server.HtmlEncode("A serious error occurred.  Please contact your system administrator.  More information has been written to the server event log.")));
            LogEvent(System.Diagnostics.EventLogEntryType.Error,
                     "An exception occurred while creating an attempt:\n\n{0}\n\n", ex.ToString());
            Buttons.Visible = true;
        }
    }
Exemple #6
0
        /// <summary>
        /// Creates attempt on given organization and returns attempt identifier.
        /// </summary>
        /// <param name="orgID">Long integer value represents organization identifier to create attempt on.</param>
        /// <returns>Long integer value, representing attempt identifier of created attempt.</returns>
        protected AttemptItemIdentifier CreateAttempt(long orgID, int topicId)
        {
            ActivityPackageItemIdentifier organizationID = new ActivityPackageItemIdentifier(orgID);

            StoredLearningSession session = StoredLearningSession.CreateAttempt(this.PStore, this.GetCurrentUserIdentifier(), organizationID, LoggingOptions.LogAll);
            // TODO: add IudicoTopicRef
            LearningStoreJob            job = LStore.CreateJob();
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add(Schema.AttemptItem.IudicoThemeRef, topicId);
            job.UpdateItem(session.AttemptId, dic);
            job.Execute();

            return(session.AttemptId);
        }
Exemple #7
0
        /// <summary>
        /// Creates attempt on given organization and returns attempt identifier.
        /// </summary>
        /// <param name="orgId">Long integer value represents organization identifier to create attempt on.</param>
        /// <param name="curriculumChapterTopicId">Int32 value representing id of curriculum chapter topic.</param>
        /// <param name="topicType"><see cref="TopicTypeEnum"/> value defines part of topic.</param>
        /// <returns>Long integer value, representing attempt identifier of created attempt.</returns>
        protected AttemptItemIdentifier CreateAttempt(long orgId, int curriculumChapterTopicId, TopicTypeEnum topicType)
        {
            var organizationId = new ActivityPackageItemIdentifier(orgId);

            StoredLearningSession session = StoredLearningSession.CreateAttempt(
                this.PStore, this.GetCurrentUserIdentifier(), organizationId, LoggingOptions.LogAll);
            LearningStoreJob job = this.LStore.CreateJob();
            var dic = new Dictionary <string, object>
            {
                { Schema.AttemptItem.IudicoCurriculumChapterTopicRef, curriculumChapterTopicId },
                { Schema.AttemptItem.IudicoTopicType, topicType }
            };

            job.UpdateItem(session.AttemptId, dic);
            job.Execute();

            return(session.AttemptId);
        }
Exemple #8
0
        /// <summary>
        /// Retrieves Organization Id by specified package oidentifier.
        /// </summary>
        /// <param name="packageId"><c>PackageItemIdentifier</c> value representing package id, organization is being searched by.</param>
        /// <returns><c>ActivityPackageItemIdentifier</c> value, which represents organization identifier of specified package.</returns>
        protected ActivityPackageItemIdentifier GetOrganizationIdentifier(PackageItemIdentifier packageId)
        {
            ActivityPackageItemIdentifier result = null;
            LearningStoreJob job = LStore.CreateJob();

            LearningStoreQuery query = LStore.CreateQuery(Schema.RootActivityByPackage.ViewName);

            query.AddColumn(Schema.RootActivityByPackage.RootActivity);
            query.SetParameter(Schema.RootActivityByPackage.PackageId, packageId);

            job.PerformQuery(query);

            var resultList = job.Execute();

            DataTable dataTable = (DataTable)resultList[0];

            if (dataTable.Rows.Count > 0)
            {
                LStoreHelper.Cast(dataTable.Rows[0][Schema.RootActivityByPackage.RootActivity], out result);
            }

            return(result);
        }
Exemple #9
0
        /// <summary>
        /// Retrieves attempt identifier for specified organization id and Iudico topic id.
        /// </summary>
        /// <param name="orgId"><c>ActivityPackageItemIdentifier</c> value representing Organization ID.</param>
        /// <param name="topicId">Integer value - IUDICO topic id.</param>
        /// <returns><c>AttemptItemIdentifier</c> value representing Attempt Identifier.</returns>
        protected AttemptItemIdentifier GetAttemptIdentifier(ActivityPackageItemIdentifier orgId, int topicId)
        {
            AttemptItemIdentifier result = null;
            LearningStoreJob      job    = LStore.CreateJob();

            LearningStoreQuery query = LStore.CreateQuery(Schema.MyAttempts.ViewName);

            query.AddColumn(Schema.MyAttempts.AttemptId);
            query.AddCondition(Schema.MyAttempts.OrganizationId, LearningStoreConditionOperator.Equal, orgId);
            query.AddCondition(Schema.MyAttempts.ThemeId, LearningStoreConditionOperator.Equal, topicId);

            job.PerformQuery(query);

            ReadOnlyCollection <object> resultList = job.Execute();

            DataTable dataTable = (DataTable)resultList[0];

            if (dataTable.Rows.Count > 0)
            {
                // get last result
                LStoreHelper.Cast(dataTable.Rows[dataTable.Rows.Count - 1][Schema.MyAttempts.AttemptId], out result);
            }
            return(result);
        }
Exemple #10
0
        /// <summary>
        /// Creates attempt on given organization and returns attempt identifier.
        /// </summary>
        /// <param name="orgID">Long integer value represents organization identifier to create attempt on.</param>
        /// <returns>Long integer value, representing attempt identifier of created attempt.</returns>
        public long CreateAttempt(long orgID)
        {
            ActivityPackageItemIdentifier organizationID = new ActivityPackageItemIdentifier(orgID);

            StoredLearningSession session = StoredLearningSession.CreateAttempt(this.PStore, this.CurrentUserIdentifier, organizationID, LoggingOptions.LogAll);

            long attemptID = session.AttemptId.GetKey();
            return attemptID;
        }
Exemple #11
0
        /// <summary>
        /// Retrieves attempt identifier for specified organization id and Iudico topic id.
        /// </summary>
        /// <param name="orgId"><c>ActivityPackageItemIdentifier</c> value representing Organization ID.</param>
        /// <param name="topicId">Integer value - IUDICO topic id.</param>
        /// <returns><c>AttemptItemIdentifier</c> value representing Attempt Identifier.</returns>
        protected AttemptItemIdentifier GetAttemptIdentifier(ActivityPackageItemIdentifier orgId, int topicId)
        {
            AttemptItemIdentifier result = null;
            LearningStoreJob job = LStore.CreateJob();

            LearningStoreQuery query = LStore.CreateQuery(Schema.MyAttempts.ViewName);
            query.AddColumn(Schema.MyAttempts.AttemptId);
            query.AddCondition(Schema.MyAttempts.OrganizationId, LearningStoreConditionOperator.Equal, orgId);
            query.AddCondition(Schema.MyAttempts.ThemeId, LearningStoreConditionOperator.Equal, topicId);

            job.PerformQuery(query);

            ReadOnlyCollection<object> resultList = job.Execute();

            DataTable dataTable = (DataTable)resultList[0];

            if (dataTable.Rows.Count > 0)
            {
                // get last result
                LStoreHelper.Cast(dataTable.Rows[dataTable.Rows.Count-1][Schema.MyAttempts.AttemptId], out result);
            }
            return result;
        }
Exemple #12
0
        /// <summary>
        /// Creates attempt on given organization and returns attempt identifier.
        /// </summary>
        /// <param name="orgID">Long integer value represents organization identifier to create attempt on.</param>
        /// <returns>Long integer value, representing attempt identifier of created attempt.</returns>
        protected AttemptItemIdentifier CreateAttempt(long orgID, int topicId)
        {
            ActivityPackageItemIdentifier organizationID = new ActivityPackageItemIdentifier(orgID);
            
            StoredLearningSession session = StoredLearningSession.CreateAttempt(this.PStore, this.GetCurrentUserIdentifier(), organizationID, LoggingOptions.LogAll);
            // TODO: add IudicoTopicRef
            LearningStoreJob job = LStore.CreateJob();
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add(Schema.AttemptItem.IudicoThemeRef, topicId);
            job.UpdateItem(session.AttemptId, dic);
            job.Execute();

            return session.AttemptId;
        }
Exemple #13
0
        /// <summary>
        /// Retrieves attempt identifier for specified organization id and Iudico topic id.
        /// </summary>
        /// <param name="orgId"><c>ActivityPackageItemIdentifier</c> value representing Organization ID.</param>
        /// <param name="curriculumChapterTopicId">Integer value - IUDICO curriculum chapter topic id.</param>
        /// <param name="topicType"><see cref="TopicTypeEnum"/> value.</param>
        /// <returns><c>AttemptItemIdentifier</c> value representing Attempt Identifier.</returns>
        protected AttemptItemIdentifier GetAttemptIdentifier(
            ActivityPackageItemIdentifier orgId, int curriculumChapterTopicId, TopicTypeEnum topicType)
        {
            AttemptItemIdentifier result = null;
            LearningStoreJob job = this.LStore.CreateJob();

            LearningStoreQuery query = this.LStore.CreateQuery(Schema.MyAttemptIds.ViewName);
            query.AddColumn(Schema.MyAttemptIds.AttemptId);
            query.SetParameter(Schema.MyAttemptIds.CurriculumChapterTopicId, curriculumChapterTopicId);
            query.SetParameter(Schema.MyAttemptIds.OrganizationId, orgId);
            query.SetParameter(Schema.MyAttemptIds.TopicType, topicType);

            job.PerformQuery(query);

            ReadOnlyCollection<object> resultList = job.Execute();

            var dataTable = (DataTable)resultList[0];

            if (dataTable.Rows.Count > 0)
            {
                // get last result
                LStoreHelper.Cast(dataTable.Rows[dataTable.Rows.Count - 1][Schema.MyAttemptIds.AttemptId], out result);
            }
            return result;
        }
Exemple #14
0
        /// <summary>
        /// Creates attempt on given organization and returns attempt identifier.
        /// </summary>
        /// <param name="orgId">Long integer value represents organization identifier to create attempt on.</param>
        /// <param name="curriculumChapterTopicId">Int32 value representing id of curriculum chapter topic.</param>
        /// <param name="topicType"><see cref="TopicTypeEnum"/> value defines part of topic.</param>
        /// <returns>Long integer value, representing attempt identifier of created attempt.</returns>
        protected AttemptItemIdentifier CreateAttempt(long orgId, int curriculumChapterTopicId, TopicTypeEnum topicType)
        {
            var organizationId = new ActivityPackageItemIdentifier(orgId);

            StoredLearningSession session = StoredLearningSession.CreateAttempt(
                this.PStore, this.GetCurrentUserIdentifier(), organizationId, LoggingOptions.LogAll);
            LearningStoreJob job = this.LStore.CreateJob();
            var dic = new Dictionary<string, object>
                {
                    { Schema.AttemptItem.IudicoCurriculumChapterTopicRef, curriculumChapterTopicId },
                    { Schema.AttemptItem.IudicoTopicType, topicType }
                };
            job.UpdateItem(session.AttemptId, dic);
            job.Execute();

            return session.AttemptId;
        }