public static void RenderEditContent(this IHtmlHelper html, SectionContent content)
 {
     if (content != null && content.SectionContentType > 0)
     {
         html.RenderPartialAsync("SectionPartial." + ((SectionContentBase.Types)content.SectionContentType + ".Edit"), content).GetAwaiter().GetResult();
     }
 }
Пример #2
0
 public static void RenderContent(this HtmlHelper html, SectionContent content)
 {
     if (content != null && content.SectionContentType > 0)
     {
         html.RenderPartial("SectionPartial." + ((SectionContentBase.Types)content.SectionContentType), content);
     }
 }
 private void AddLinesContent(SectionContent lines)
 {
     lines.AddLine("bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla")
     .AddLine("bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla")
     .AddLine("bla bla bla bla bla bla bla bla bla bla bla bla bla");
     lines.Print();
 }
Пример #4
0
 public SectionContent FillContent(SectionContent content)
 {
     return
         (content.InitContent(
              _sectionContentServices.First(m => (int)m.ContentType == content.SectionContentType)
              .GetContent(content.ID)));
 }
Пример #5
0
 public static void RenderEditContent(this HtmlHelper html, SectionContent content)
 {
     if (content != null && content.SectionContentType.HasValue)
     {
         html.RenderPartial("SectionPartial." + ((SectionContent.Types)content.SectionContentType + ".Edit"), content);
     }
 }
Пример #6
0
        public void Update(SectionContent item)
        {
            var content = Get(item.ID);

            item.CopyTo(content);
            base.Update(content);
            _sectionContentServices.First(m => (int)m.ContentType == item.SectionContentType).UpdateContent(item);
        }
Пример #7
0
        public void SaveSort(SectionContent content)
        {
            var contentPart = content.ToContent();

            CurrentDbSet.Attach(contentPart);
            DbContext.Entry(contentPart).Property(n => n.Order).IsModified = true;
            DbContext.SaveChanges();
        }
Пример #8
0
        public void SetValue(string section, string key, string value, bool create)
        {
            SectionContent kl = Section(section, true);

            if (kl != null)
            {
                kl.SetValue(key, value, create);
            }
        }
Пример #9
0
        public void ClearSection(string section)
        {
            SectionContent kl = Section(section, false);

            if (kl != null)
            {
                kl.Clear();
            }
        }
        private static string FormatPercentComplete(SectionContent sectionContent)
        {
            var    totalStatus = sectionContent.Tutorials.Sum(tutorial => tutorial.TutorialStatus);
            double percentage  =
                sectionContent.Tutorials.Count == 0 || !sectionContent.HasLearning
                    ? 0
                    : (totalStatus * 100) / (sectionContent.Tutorials.Count * 2);

            return($"{Convert.ToInt32(Math.Floor(percentage))}% learning complete");
        }
Пример #11
0
        public string GetValue(string section, string key, string def)
        {
            SectionContent kl = Section(section, false);

            if (kl != null)
            {
                return(kl.GetValue(key, def));
            }
            return(def);
        }
Пример #12
0
        /// <summary>
        /// Default section constructor
        /// </summary>
        /// <param name="sectionTitle">Title of the section</param>
        /// <param name="open">If is open or closed upon creation</param>
        /// <param name="content">Delegate function for drawing the section content</param>
        /// <param name="changesCheck">Delegate fucntion for checks that need to be done knowing if the box is open or enabled at all</param>
        public Section(GUIContent sectionTitle, bool open, SectionContent content, ChangesCheck changesCheck)
        {
            this.sectionTitle = sectionTitle;
            this.isOpen       = open;
            this.content      = content;
            this.changesCheck = changesCheck;

            TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath));

            sectionStyle        = (SectionStyle)settings.sectionStyle;
            this.sectionBgColor = settings.sectionColor;
        }
        public void Add(SectionContent item)
        {
            item.ID = Guid.NewGuid().ToString("N");
            if (!item.Order.HasValue || item.Order.Value == 0)
            {
                item.Order = Count(m => m.SectionWidgetId == item.SectionWidgetId && m.SectionGroupId == item.SectionGroupId) + 1;
            }
            var contentBase = item.ToContent();

            base.Add(contentBase);
            _sectionContentServices.First(m => (int)m.ContentType == item.SectionContentType).AddContent(item);
        }
Пример #14
0
        public void Lines()
        {
            SectionContent lines = new SectionContent();

            AddLinesContent(lines);
            lines.Print();

            Console.WriteLine("----------------------------");

            lines = new SectionContent(4);
            AddLinesContent(lines);
            lines.Print();
        }
Пример #15
0
 public DynamicSectionContent(SectionContent SC, SectionLayout SL)
 {
     this.Title             = SC.Title;
     this.SectionLayoutID   = SC.SectionLayoutID;
     this.SubTitle          = SC.SubTitle;
     this.BodyHTML          = SC.BodyHTML;
     this.NextContentID     = SC.NextContentID;
     this.PreviousContentID = SC.PreviousContentID;
     this.ContentID         = SC.ContentID;
     this.LayoutName        = SL.LayoutName;
     this.HeaderLink        = SL.HeaderLink;
     this.Header            = SL.Header;
     this.Footer            = SL.Footer;
     this.CssClass          = SL.CssClass;
 }
Пример #16
0
        public IniRegistry(StreamReader sr)
        {
            reg = new Sectionlist();
            string keyBase  = "";
            string keyName  = "";
            string keyValue = "";

            while (!sr.EndOfStream)
            {
                string line = sr.ReadLine().Trim();
                if (line.Length == 0 || line.StartsWith(";"))
                {
                    continue;
                }

                //remove comment
                int pos = line.IndexOf(';');
                if (pos > 0)
                {
                    line = line.Substring(0, pos).Trim();
                }
                ;

                if (line.StartsWith("["))
                {
                    if (line.EndsWith("]"))
                    {
                        keyBase      = line.Substring(1, line.Length - 2).Trim();
                        reg[keyBase] = new SectionContent();
                        continue;
                    }
                    // fall through!
                }
                else if (line.Contains("="))
                {
                    string[] a = line.Split(new char[] { '=' }, 2);
                    keyName  = a[0].Trim().ToLower();
                    keyValue = a[1].Trim().ToLower();
                    reg[keyBase].SetValue(keyName, keyValue, true);
                    continue;
                }
                throw new Exception("Invalid inifile line: " + line);
            }
        }
        public SectionContentViewModel(IConfiguration config, SectionContent sectionContent, int customisationId, int sectionId)
        {
            CourseTitle                = sectionContent.CourseTitle;
            CourseDescription          = sectionContent.CourseDescription;
            SectionName                = sectionContent.SectionName;
            PercentComplete            = FormatPercentComplete(sectionContent);
            ShowPercentComplete        = sectionContent.HasLearning && sectionContent.CourseSettings.ShowPercentage;
            CustomisationId            = customisationId;
            SectionId                  = sectionId;
            ShowPostLearning           = sectionContent.PostLearningAssessmentPath != null && sectionContent.IsAssessed;
            PostLearningStatus         = GetPostLearningStatus(sectionContent);
            PostLearningStatusStyling  = GetPostLearningStatusStyling(sectionContent);
            ShowDiagnostic             = sectionContent.DiagnosticAssessmentPath != null && sectionContent.DiagnosticStatus;
            DiagnosticCompletionStatus = GetDiagnosticCompletionStatus(sectionContent);
            ConsolidationExercisePath  = sectionContent.ConsolidationPath == null
                ? null
                : OldSystemEndpointHelper.GetConsolidationPathUrl(config, sectionContent.ConsolidationPath);
            ShowConsolidation          = ConsolidationExercisePath != null;
            ConsolidationExerciseLabel = sectionContent.CourseSettings.ConsolidationExercise ?? "Consolidation Exercise";

            Tutorials = sectionContent.Tutorials.Select(tutorial => new TutorialCardViewModel(
                                                            tutorial,
                                                            sectionContent.CourseSettings.ShowTime,
                                                            sectionContent.CourseSettings.ShowLearnStatus,
                                                            sectionId,
                                                            customisationId
                                                            ));

            DisplayDiagnosticSeparator   = ShowDiagnostic && (sectionContent.Tutorials.Any() || ShowPostLearning || ShowConsolidation);
            DisplayTutorialSeparator     = sectionContent.Tutorials.Any() && (ShowPostLearning || ShowConsolidation);
            DisplayPostLearningSeparator = ShowConsolidation && ShowPostLearning;
            NextSectionId                  = sectionContent.NextSectionId;
            ShowCompletionSummary          = sectionContent.IncludeCertification && !sectionContent.OtherSectionsExist;
            OtherSectionsExist             = sectionContent.OtherSectionsExist;
            CompletionSummaryCardViewModel = new CompletionSummaryCardViewModel(
                customisationId,
                sectionContent.Completed,
                sectionContent.MaxPostLearningAssessmentAttempts,
                sectionContent.IsAssessed,
                sectionContent.PostLearningAssessmentPassThreshold,
                sectionContent.DiagnosticAssessmentCompletionThreshold,
                sectionContent.TutorialsCompletionThreshold
                );
        }
        private static string GetPostLearningStatus(SectionContent sectionContent)
        {
            if (sectionContent.PostLearningAttempts == 0)
            {
                return("Not Attempted");
            }

            if (sectionContent.PostLearningAttempts > 0 && sectionContent.PostLearningPassed)
            {
                return("Passed");
            }

            if (sectionContent.PostLearningAttempts > 0 && !sectionContent.PostLearningPassed)
            {
                return("Failed");
            }

            return("");
        }
        private static string GetDiagnosticCompletionStatus(SectionContent sectionContent)
        {
            if (sectionContent.DiagnosticAttempts == 0)
            {
                return("Not Attempted");
            }

            if (sectionContent.DiagnosticAttempts == 1)
            {
                return($"{sectionContent.SectionScore}/{sectionContent.MaxSectionScore} - {sectionContent.DiagnosticAttempts} attempt");
            }

            if (sectionContent.DiagnosticAttempts > 0)
            {
                return($"{sectionContent.SectionScore}/{sectionContent.MaxSectionScore} - {sectionContent.DiagnosticAttempts} attempts");
            }

            return("");
        }
Пример #20
0
        public SectionContent Section(string section, bool create)
        {
            foreach (string k in reg.Keys)
            {
                if (KeyCompare(section, k))
                {
                    return(reg[k]);
                }
            }

            if (!create)
            {
                return(null);
            }

            SectionContent kl = new SectionContent();

            reg.Add(section, kl);

            return(kl);
        }
Пример #21
0
 public void UpdateContent(SectionContent content)
 {
     Update(content as SectionContentImage);
 }
Пример #22
0
 public void AddContent(SectionContent content)
 {
     Add(content as SectionContentImage);
 }
Пример #23
0
        /// <summary>
        /// Load INI file
        /// </summary>
        /// <param name="INIStream">A Stream, which contains INI file</param>
        public void Load(Stream INIStream)
        {
            StreamReader sr = new StreamReader(INIStream);

            while (!sr.EndOfStream)
            {
                INIcontent += sr.ReadLine() + Environment.NewLine;
            }

            string SectionName = "INI#";
            Dictionary <string, string> SectionContent = new Dictionary <string, string>();

            foreach (string str in INIcontent.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            {
                //Console.WriteLine(str);

                if (str.StartsWith(";"))
                {
                    continue;
                }

                if (str.StartsWith("["))
                {
                    if (SectionName != "INI#" && SectionContent.Count > 0)
                    {
                        Sections.Add(SectionName, SectionContent);
                    }
                    SectionName = str.Substring(1, str.Length - 2);
                    if (Sections.ContainsKey(SectionName))
                    {
                        SectionName = SectionName + "dupl" + new Random().Next();
                    }
                    SectionContent = new Dictionary <string, string>();
                    continue;
                }

                string OptionName  = "";
                string OptionValue = "";
                bool   OnValue     = false;
                for (int pos = 0; pos < str.Length; pos++)
                {
                    if (str[pos] == '=')
                    {
                        OnValue = true; continue;
                    }
                    else
                    {
                        if (OnValue)
                        {
                            OptionValue += str[pos];
                            //add parsing for quotes and comments (напр.: name="value\"part in quotes\"";comment )
                        }
                        else
                        {
                            OptionName += str[pos];
                        }
                    }
                }
                if (OptionName == "")
                {
                    OptionName = "noname" + new Random().Next();
                }

                if (!SectionContent.ContainsKey(OptionName))
                {
                    SectionContent.Add(OptionName, OptionValue);
                }
                else
                {
                    SectionContent.Add(OptionName + "=" + new Random().Next(), OptionValue);
                }
            }
            Sections.Add(SectionName, SectionContent);
        }
Пример #24
0
 public void UpdateContent(SectionContent content)
 {
     Update(content as SectionContentParagraph);
 }
Пример #25
0
 public void AddContent(SectionContent content)
 {
     Add(content as SectionContentParagraph);
 }
 public void UpdateContent(SectionContent content)
 {
     Update(content as SectionContentTitle);
 }
 public void AddContent(SectionContent content)
 {
     Add(content as SectionContentTitle);
 }
Пример #28
0
 public void AddContent(SectionContent content)
 {
     this.Add(content as SectionContentCallToAction);
 }
Пример #29
0
 public void UpdateContent(SectionContent content)
 {
     this.Update(content as SectionContentCallToAction);
 }
Пример #30
0
 public void UpdateContent(SectionContent content)
 {
     Update(content as SectionContentVideo);
 }