Esempio n. 1
0
        public static ExaminationContract ConvertSpeak(CiWong.Tools.Workshop.DataContracts.ListeningAndSpeakingContract listeningAndSpeaking)
        {
            if (null == listeningAndSpeaking)
            {
                return(null);
            }

            var examinationContract = new ExaminationContract()
            {
                Id           = listeningAndSpeaking.Id.HasValue ? listeningAndSpeaking.Id.Value : 0,
                Title        = listeningAndSpeaking.Name,
                RefScore     = Convert.ToSingle(listeningAndSpeaking.TotalScore),
                CurriculumID = 3
            };

            var parts = new List <QuestionModuleContract>();

            listeningAndSpeaking.Items.ToList().ForEach(t => parts.Add(new QuestionModuleContract()
            {
                ModuleTypeName = t.TemplateSettings.Content ?? string.Empty,
                Children       = ConvertQuestion(t)
            }));

            examinationContract.Parts = parts;

            return(examinationContract);
        }
        /// <summary>
        /// 试卷转换
        /// </summary>
        public static ExaminationContract ConvertExamination(CiWong.Examination.Mapping.Entities.Examination examination)
        {
            if (null == examination)
            {
                return(null);
            }

            var examinationContract = new ExaminationContract()
            {
                Id           = examination.ExaminationID,
                Title        = examination.ExaminationTitle,
                RefScore     = examination.RefScore,
                CurriculumID = examination.CurriculumID,
            };

            var parts = new List <QuestionModuleContract>();
            var index = 0;

            foreach (var group in examination.ExaminationVersions.GroupBy(t => t.ModulePosition))
            {
                parts.Add(new QuestionModuleContract()
                {
                    Sid            = index++,
                    ModuleTypeURL  = group.First().ModuleTypeURL,
                    ModuleTypeName = group.First().ModuleTypeName,
                    Children       = ConvertQuestionList(group)
                });
            }

            examinationContract.Parts = parts;

            return(examinationContract);
        }