public CurrentTopicTestResultsModel(int curriculumChapterTopicId, TopicTypeEnum topicType, int groupId, ILmsService lmsService)
 {
     this.group = lmsService.FindService<IUserService>().GetGroup(groupId);
     var currenUser = lmsService.FindService<IUserService>().GetCurrentUser();
     var curriculumChapterTopic = lmsService.FindService<ICurriculumService>().GetCurriculumChapterTopicById(curriculumChapterTopicId);
     if (currenUser != null & curriculumChapterTopic != null)
     {
         var attemptResults = lmsService.FindService<ITestingService>().GetResults(currenUser, curriculumChapterTopic, topicType).ToList();
         if (attemptResults.Any())
         {
             // hotfix: added checking of Course id
             this.attempt =
                 attemptResults.FirstOrDefault(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef);
             if (this.attempt != null)
             {
                 this.courseInfo =
                     lmsService.FindService<ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef);
                 this.userAnswers = lmsService.FindService<ITestingService>().GetAnswers(this.attempt);
                 
                 this.hasNoData = this.userAnswers == null;
             }
         }
         else
             this.hasNoData = true;
     }
     else
         this.hasNoData = true;
 }
Exemple #2
0
        public ActionResult CurrentTopicTestResults(int curriculumChapterTopicId, TopicTypeEnum topicType)
        {
            var groupId = (int)HttpContext.Session["SelectedGroupId"];
            var model   = new CurrentTopicTestResultsModel(curriculumChapterTopicId, topicType, groupId, LmsService);

            return(View(model));
        }
        public CurrentTopicTestResultsModel(int curriculumChapterTopicId, TopicTypeEnum topicType, int groupId, ILmsService lmsService)
        {
            this.group = lmsService.FindService <IUserService>().GetGroup(groupId);
            var currenUser             = lmsService.FindService <IUserService>().GetCurrentUser();
            var curriculumChapterTopic = lmsService.FindService <ICurriculumService>().GetCurriculumChapterTopicById(curriculumChapterTopicId);

            if (currenUser != null & curriculumChapterTopic != null)
            {
                var attemptResults = lmsService.FindService <ITestingService>().GetResults(currenUser, curriculumChapterTopic, topicType).ToList();
                if (attemptResults.Any())
                {
                    // hotfix: added checking of Course id
                    this.attempt =
                        attemptResults.FirstOrDefault(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef);
                    if (this.attempt != null)
                    {
                        this.courseInfo =
                            lmsService.FindService <ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef);
                        this.userAnswers = lmsService.FindService <ITestingService>().GetAnswers(this.attempt);

                        this.hasNoData = this.userAnswers == null;
                    }
                }
                else
                {
                    this.hasNoData = true;
                }
            }
            else
            {
                this.hasNoData = true;
            }
        }
Exemple #4
0
        /// <summary>
        /// Checks if related to topic package has been already uploaded.
        /// In case it was not uploaded - upload package.
        /// Check attempt has been created and get attempt id.
        /// </summary>
        /// <param name="curriculumChapterTopicId">Iudico CurriculumChapterTopic.Id</param>
        /// <param name="courseId">Iudico Course.Id</param>
        /// <param name="topicType"><see cref="TopicTypeEnum"/> enumeration value.</param>
        /// <returns>Long integer value representing attempt id.</returns>
        public long GetAttemptId(int curriculumChapterTopicId, int courseId, TopicTypeEnum topicType)
        {
            this.GetCurrentUserIdentifier();
            AttemptItemIdentifier attemptId;
            ActivityPackageItemIdentifier organizationId;
            var packageId = this.GetPackageIdentifier(courseId);

            // in case package has not been uploaded yet.
            if (packageId == null)
            {
                string zipPath = this.CourseService.Export(courseId, true);
                Package package = new ZipPackage(zipPath);
                package.CourseID = courseId;
                packageId = this.AddPackage(package);
                organizationId = this.GetOrganizationIdentifier(packageId);
                attemptId = this.CreateAttempt(organizationId.GetKey(), curriculumChapterTopicId, topicType);
            }
            else
            {
                // otherwise check if attempt was created
                organizationId = this.GetOrganizationIdentifier(packageId);

                AttemptItemIdentifier attId = this.GetAttemptIdentifier(
                    organizationId, curriculumChapterTopicId, topicType);
                attemptId = attId ?? this.CreateAttempt(organizationId.GetKey(), curriculumChapterTopicId, topicType);
            }

            return attemptId.GetKey();
        }
Exemple #5
0
        /// <summary>
        /// Checks if related to topic package has been already uploaded.
        /// In case it was not uploaded - upload package.
        /// Check attempt has been created and get attempt id.
        /// </summary>
        /// <param name="curriculumChapterTopicId">Iudico CurriculumChapterTopic.Id</param>
        /// <param name="courseId">Iudico Course.Id</param>
        /// <param name="topicType"><see cref="TopicTypeEnum"/> enumeration value.</param>
        /// <returns>Long integer value representing attempt id.</returns>
        public long GetAttemptId(int curriculumChapterTopicId, int courseId, TopicTypeEnum topicType)
        {
            this.GetCurrentUserIdentifier();
            AttemptItemIdentifier         attemptId;
            ActivityPackageItemIdentifier organizationId;
            var packageId = this.GetPackageIdentifier(courseId);

            // in case package has not been uploaded yet.
            if (packageId == null)
            {
                string  zipPath = this.CourseService.Export(courseId, true);
                Package package = new ZipPackage(zipPath);
                package.CourseID = courseId;
                packageId        = this.AddPackage(package);
                organizationId   = this.GetOrganizationIdentifier(packageId);
                attemptId        = this.CreateAttempt(organizationId.GetKey(), curriculumChapterTopicId, topicType);
            }
            else
            {
                // otherwise check if attempt was created
                organizationId = this.GetOrganizationIdentifier(packageId);

                AttemptItemIdentifier attId = this.GetAttemptIdentifier(
                    organizationId, curriculumChapterTopicId, topicType);
                attemptId = attId ?? this.CreateAttempt(organizationId.GetKey(), curriculumChapterTopicId, topicType);
            }

            return(attemptId.GetKey());
        }
Exemple #6
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 #7
0
        public ActionResult Play(int curriculumChapterTopicId, int courseId, TopicTypeEnum topicType)
        {
            CurriculumChapterTopic curriculumChapterTopic;

            try
            {
                curriculumChapterTopic = this.CurriculumService.GetCurriculumChapterTopicById(curriculumChapterTopicId);
            }
            catch (InvalidOperationException)
            {
                curriculumChapterTopic = null;
            }

            if (curriculumChapterTopic == null)
            {
                return(this.View("Error", "~/Views/Shared/Site.Master", Localization.GetMessage("Topic_Not_Found")));
            }

            Course course;

            try
            {
                course = this.CourseService.GetCourse(courseId);
            }
            catch (InvalidOperationException)
            {
                course = null;
            }

            if (course == null)
            {
                return(this.View("Error", "~/Views/Shared/Site.Master", Localization.GetMessage("Course_Not_Found")));
            }

            var canPass = this.CurriculumService.CanPassCurriculumChapterTopic(
                this.CurrentUser, curriculumChapterTopic, topicType);

            if (!canPass)
            {
                return(this.View(
                           "Error", "~/Views/Shared/Site.Master", Localization.GetMessage("Not_Allowed_Pass_Topic")));
            }

            var attemptId = this.MlcProxy.GetAttemptId(curriculumChapterTopicId, courseId, topicType);

            ServicesProxy.Instance.Initialize(LmsService);

            return(this.View(
                       "Play",
                       new PlayModel
            {
                AttemptId = attemptId,
                CurriculumChapterTopicId = curriculumChapterTopicId,
                TopicType = topicType,
                TopicName = string.Format("{0}: {1}", Localization.GetMessage(topicType.ToString()), curriculumChapterTopic.Topic.Name)
            }));
        }
Exemple #8
0
 public static string ToString(TopicTypeEnum topicType)
 {
     switch (topicType)
     {
         case TopicTypeEnum.Test: return Localization.GetMessage("TopicType.Test");
         case TopicTypeEnum.Theory: return Localization.GetMessage("TopicType.Theory");
         case TopicTypeEnum.TestWithoutCourse: return Localization.GetMessage("TopicType.TestWithoutCourse");
         default: throw new ArgumentOutOfRangeException();
     }
 }
        public ActionResult Play(int curriculumChapterTopicId, int courseId, TopicTypeEnum topicType)
        {
            CurriculumChapterTopic curriculumChapterTopic;
            try
            {
                curriculumChapterTopic = this.CurriculumService.GetCurriculumChapterTopicById(curriculumChapterTopicId);
            }
            catch (InvalidOperationException)
            {
                curriculumChapterTopic = null;
            }

            if (curriculumChapterTopic == null)
            {
                return this.View("Error", "~/Views/Shared/Site.Master", Localization.GetMessage("Topic_Not_Found"));
            }

            Course course;
            try
            {
                course = this.CourseService.GetCourse(courseId);
            }
            catch (InvalidOperationException)
            {
                course = null;    
            }
            
            if (course == null)
            {
                return this.View("Error", "~/Views/Shared/Site.Master", Localization.GetMessage("Course_Not_Found"));
            }

            var canPass = this.CurriculumService.CanPassCurriculumChapterTopic(
                this.CurrentUser, curriculumChapterTopic, topicType);

            if (!canPass)
            {
                return this.View(
                    "Error", "~/Views/Shared/Site.Master", Localization.GetMessage("Not_Allowed_Pass_Topic"));
            }

            var attemptId = this.MlcProxy.GetAttemptId(curriculumChapterTopicId, courseId, topicType);

            ServicesProxy.Instance.Initialize(LmsService);

            return this.View(
                "Play",
                new PlayModel
                    {
                        AttemptId = attemptId,
                        CurriculumChapterTopicId = curriculumChapterTopicId,
                        TopicType = topicType,
                        TopicName = string.Format("{0}: {1}", Localization.GetMessage(topicType.ToString()), curriculumChapterTopic.Topic.Name)
                    });
        }
Exemple #10
0
        public static string ToString(TopicTypeEnum topicType)
        {
            switch (topicType)
            {
            case TopicTypeEnum.Test: return(Localization.GetMessage("TopicType.Test"));

            case TopicTypeEnum.Theory: return(Localization.GetMessage("TopicType.Theory"));

            case TopicTypeEnum.TestWithoutCourse: return(Localization.GetMessage("TopicType.TestWithoutCourse"));

            default: throw new ArgumentOutOfRangeException();
            }
        }
Exemple #11
0
 public void PlayModelPropertiesTest(int attemptId, int curriculumChapterTopicId, TopicTypeEnum topicType, string topicName)
 {
     var playModel = new PlayModel
         {
             AttemptId = attemptId,
             CurriculumChapterTopicId = curriculumChapterTopicId,
             TopicType = topicType,
             TopicName = topicName
         };
     
     Assert.AreEqual(attemptId, playModel.AttemptId);
     Assert.AreEqual(curriculumChapterTopicId, playModel.CurriculumChapterTopicId);
     Assert.AreEqual(topicType, playModel.TopicType);
     Assert.AreEqual(topicName, playModel.TopicName);
 }
Exemple #12
0
        public static string ToString(IUDICO.Common.Models.Shared.TopicType topicType)
        {
            TopicTypeEnum enumTopicType = ToTopicType(topicType);

            switch (enumTopicType)
            {
            case TopicTypeEnum.Test: return(Localization.getMessage("TopicType.Test"));

            case TopicTypeEnum.Theory: return(Localization.getMessage("TopicType.Theory"));

            case TopicTypeEnum.TestWithoutCourse: return(Localization.getMessage("TopicType.TestWithoutCourse"));

            default: throw new ArgumentOutOfRangeException();
            }
        }
Exemple #13
0
        public AttemptResult(long attemptId, User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType, CompletionStatus completionStatus, AttemptStatus attemptStatus, SuccessStatus successStatus, DateTime? startTime, DateTime? finishTime, int iudicoCourseRef, float? minScore, float? maxScore, float? rawScore, float? scaledScore)
        {
            this.AttemptId = attemptId;
            this.User = user;
            this.CurriculumChapterTopic = curriculumChapterTopic;
            this.TopicType = topicType;

            this.CompletionStatus = completionStatus;
            this.AttemptStatus = attemptStatus;
            this.SuccessStatus = successStatus;
            this.StartTime = startTime;
            this.FinishTime = finishTime;
            this.IudicoCourseRef = iudicoCourseRef;
            this.Score = new Score(minScore, maxScore, rawScore, scaledScore);
        }
Exemple #14
0
        public IEnumerable <AttemptResult> GetResults(
            User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
        {
            var job        = this.LStore.CreateJob();
            var conditions = new List <QueryCondition>
            {
                new QueryCondition(Schema.AllAttemptsResults.UserItemKey, user.Id.ToString()),
                new QueryCondition(Schema.AllAttemptsResults.CurriculumChapterTopicId, curriculumChapterTopic.Id),
                new QueryCondition(Schema.AllAttemptsResults.TopicType, (int)topicType)
            };

            this.RequestAttemptResults(job, conditions);

            var dataTable = job.Execute <DataTable>();

            return(this.ParseAttemptResults(dataTable.AsEnumerable(), conditions));
        }
        public void CreateAttemptResultWithParameters()
        {
            const long             AttemptId              = 12312;
            const int              IudicoCourseRef        = 23;
            var                    user                   = new User();
            var                    curriculumChapterTopic = new CurriculumChapterTopic();
            const TopicTypeEnum    TopicTypeEnum          = TopicTypeEnum.TestWithoutCourse;
            const CompletionStatus CompletionStatus       = CompletionStatus.Incomplete;
            const AttemptStatus    AttemptStatus          = AttemptStatus.Completed;
            const SuccessStatus    SuccessStatus          = SuccessStatus.Passed;
            DateTime?              startTime              = new DateTime(32478932);
            DateTime?              finishTime             = new DateTime(189041324);
            float?                 score                  = 0.22f;
            float?                 minScore               = 0;
            float?                 maxScore               = 50;
            float?                 rawScore               = 11;

            var attemptResult = new AttemptResult(
                AttemptId,
                user,
                curriculumChapterTopic,
                TopicTypeEnum,
                CompletionStatus,
                AttemptStatus,
                SuccessStatus,
                startTime,
                finishTime,
                IudicoCourseRef,
                minScore,
                maxScore,
                rawScore,
                score);

            Assert.AreEqual(AttemptId, attemptResult.AttemptId);
            Assert.AreEqual(user, attemptResult.User);
            Assert.AreEqual(curriculumChapterTopic, attemptResult.CurriculumChapterTopic);
            Assert.AreEqual(TopicTypeEnum, attemptResult.TopicType);
            Assert.AreEqual(CompletionStatus, attemptResult.CompletionStatus);
            Assert.AreEqual(AttemptStatus, attemptResult.AttemptStatus);
            Assert.AreEqual(SuccessStatus, attemptResult.SuccessStatus);
            Assert.AreEqual(startTime, attemptResult.StartTime);
            Assert.AreEqual(finishTime, attemptResult.FinishTime);
            Assert.AreEqual(score, attemptResult.Score.ScaledScore);
        }
Exemple #16
0
 public bool CanPassCurriculumChapterTopic(User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
 {
     return this.curriculumStorage.CanPassCurriculumChapterTopic(user, curriculumChapterTopic, topicType);
 }
        public bool CanPassCurriculumChapterTopic(User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
        {
            // TODO: implement in more sophisticated and performance-proof maner

            var descriptions = this.GetTopicDescriptions(user);

            var selectedDescriptions =
                descriptions.Where(desc => desc.CurriculumChapterTopicId == curriculumChapterTopic.Id
                                           && desc.TopicType == topicType);

            return selectedDescriptions.Count() == 1;
        }
Exemple #18
0
 public IEnumerable <AttemptResult> GetResults(
     User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
 {
     return(this.MlcProxy.GetResults(user, curriculumChapterTopic, topicType));
 }
Exemple #19
0
        public IEnumerable<AttemptResult> GetResults(
            User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
        {
            var job = this.LStore.CreateJob();
            var conditions = new List<QueryCondition>
                {
                    new QueryCondition(Schema.AllAttemptsResults.UserItemKey, user.Id.ToString()),
                    new QueryCondition(Schema.AllAttemptsResults.CurriculumChapterTopicId, curriculumChapterTopic.Id),
                    new QueryCondition(Schema.AllAttemptsResults.TopicType, (int)topicType)
                };

            this.RequestAttemptResults(job, conditions);

            var dataTable = job.Execute<DataTable>();

            return this.ParseAttemptResults(dataTable.AsEnumerable(), conditions);
        }
Exemple #20
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 #21
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 #22
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 #23
0
 public IEnumerable<AttemptResult> GetResults(
     User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
 {
     return this.MlcProxy.GetResults(user, curriculumChapterTopic, topicType);
 }
Exemple #24
0
 public bool CanPassCurriculumChapterTopic(User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
 {
     return(this.curriculumStorage.CanPassCurriculumChapterTopic(user, curriculumChapterTopic, topicType));
 }
Exemple #25
0
        public void PlayModelPropertiesTest(int attemptId, int curriculumChapterTopicId, TopicTypeEnum topicType, string topicName)
        {
            var playModel = new PlayModel
            {
                AttemptId = attemptId,
                CurriculumChapterTopicId = curriculumChapterTopicId,
                TopicType = topicType,
                TopicName = topicName
            };

            Assert.AreEqual(attemptId, playModel.AttemptId);
            Assert.AreEqual(curriculumChapterTopicId, playModel.CurriculumChapterTopicId);
            Assert.AreEqual(topicType, playModel.TopicType);
            Assert.AreEqual(topicName, playModel.TopicName);
        }
Exemple #26
0
        public ActionResult CurrentTopicTestResults(int curriculumChapterTopicId, TopicTypeEnum topicType)
        {
            var model = new CurrentTopicTestResultsModel(curriculumChapterTopicId, topicType, LmsService);

            return(View(model));
        }
Exemple #27
0
 public ActionResult CurrentTopicTestResults(int curriculumChapterTopicId, TopicTypeEnum topicType)
 {
     var groupId = (int)HttpContext.Session["SelectedGroupId"];
     var model = new CurrentTopicTestResultsModel(curriculumChapterTopicId, topicType, groupId, LmsService);
     return View(model);
 }
        /// <summary>
        /// Imports the measure topic file.
        /// </summary>
        /// <param name="wingName">Name of the wing.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="topicType">Type of the topic.</param>
        public void ImportMeasureTopicFile(string wingName, string fileName, TopicTypeEnum topicType)
        {
            using (var session = Provider.SessionFactory.OpenSession())
            {
                string selectStatement = string.Format("SELECT * FROM [{0}]", Path.GetFileName(fileName));

                var builder = new OleDbConnectionStringBuilder()
                {
                    Provider   = "Microsoft.ACE.OLEDB.12.0",
                    DataSource = Path.GetDirectoryName(fileName),
                };

                builder["Extended Properties"] = "text;HDR=YES;FMT=Delimited";

                using (var conn = new OleDbConnection(builder.ConnectionString))
                {
                    conn.Open();
                    using (var tx = session.BeginTransaction())
                    {
                        try
                        {
                            using (var cmd = new OleDbCommand(selectStatement, conn))
                            {
                                using (var rdr = cmd.ExecuteReader())
                                {
                                    while (rdr != null && rdr.Read())
                                    {
                                        var measureCode         = rdr["MeasureCode"].ToString().Trim();
                                        var topicCategoryName   = rdr["TopicCategory"].ToString().Trim();
                                        var topicName           = rdr["TopicName"].ToString().Trim();
                                        var usedForInfographics = rdr["UsedForInfographic"].ToString().Trim().ToLower() == "true";
                                        var audiencesText       = rdr.ColumnExists("Audiences") ? rdr.Guard <string>("Audiences") : null;

                                        if (string.IsNullOrEmpty(measureCode) ||
                                            string.IsNullOrEmpty(topicCategoryName) ||
                                            string.IsNullOrEmpty(topicName))
                                        {
                                            continue;
                                        }

                                        var measure =
                                            session.Query <Measure>().FirstOrDefault(tst => tst.Name == measureCode);

                                        if (measure == null)
                                        {
                                            continue;
                                        }

                                        //	Get/Update topicCategory.
                                        var topicCategory = session.Query <TopicCategory>().FirstOrDefault(tc => tc.Name.ToLower() == topicCategoryName.ToLower()) ?? new TopicCategory(topicCategoryName);
                                        topicCategory.TopicType = topicType;

                                        //	Get topic; create if needed.
                                        var newTopic = topicCategory.Topics.SingleOrDefault(t => t.Name.EqualsIgnoreCase(topicName) && t.Owner.Name.EqualsIgnoreCase(topicCategoryName));
                                        if (newTopic == null)
                                        {
                                            newTopic = new Topic(topicCategory, topicName);
                                        }

                                        //	Create/Update measureTopic.
                                        var measureTopic = measure.MeasureTopics.FirstOrDefault(mt => mt.Topic.Name.EqualsIgnoreCase(topicName) && mt.Topic.Owner.Name.EqualsIgnoreCase(topicCategoryName));
                                        if (measureTopic == null)
                                        {
                                            measure.AddTopic(newTopic, usedForInfographics);
                                        }
                                        else
                                        {
                                            measureTopic.UsedForInfographic = usedForInfographics;
                                        }

                                        session.SaveOrUpdate(measure);
                                        session.SaveOrUpdate(newTopic);
                                        session.SaveOrUpdate(topicCategory);
                                    }
                                    tx.Commit();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            //tx.Rollback();
                            Logger.Write(ex, "Error importing measure topics for Wing \"{0}\" from file {1}", wingName, fileName);
                        }
                    }
                }
            }
        }
Exemple #29
0
        public AttemptResult(long attemptId, User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType, CompletionStatus completionStatus, AttemptStatus attemptStatus, SuccessStatus successStatus, DateTime?startTime, DateTime?finishTime, int iudicoCourseRef, float?minScore, float?maxScore, float?rawScore, float?scaledScore)
        {
            this.AttemptId = attemptId;
            this.User      = user;
            this.CurriculumChapterTopic = curriculumChapterTopic;
            this.TopicType = topicType;

            this.CompletionStatus = completionStatus;
            this.AttemptStatus    = attemptStatus;
            this.SuccessStatus    = successStatus;
            this.StartTime        = startTime;
            this.FinishTime       = finishTime;
            this.IudicoCourseRef  = iudicoCourseRef;
            this.Score            = new Score(minScore, maxScore, rawScore, scaledScore);
        }
Exemple #30
0
 public ActionResult CurrentTopicTestResults(int curriculumChapterTopicId, TopicTypeEnum topicType)
 {
     var model = new CurrentTopicTestResultsModel(curriculumChapterTopicId, topicType, LmsService);
     return View(model);
 }
Exemple #31
0
        public bool CanPassCurriculumChapterTopic(User user, CurriculumChapterTopic curriculumChapterTopic, TopicTypeEnum topicType)
        {
            // TODO: implement in more sophisticated and performance-proof maner

            var descriptions = this.GetTopicDescriptions(user);

            var selectedDescriptions =
                descriptions.Where(desc => desc.CurriculumChapterTopicId == curriculumChapterTopic.Id &&
                                   desc.TopicType == topicType);

            return(selectedDescriptions.Count() == 1);
        }