/// <summary>Configures the course page.</summary> /// <param name="coursePage">The course page.</param> /// <param name="controls">The controls.</param> public virtual void ConfigureCoursePage(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { coursePage.Configuration = (( RockTextBox )controls[0]).Text; } }
public void OpenBrowserWindowAndNavigateToURL() { Initialize(); _homePage = new HomePage(Driver); _coursePage = new CoursePage(Driver); _homePage.Open(); }
public override void ConfigureCoursePage(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { coursePage.Configuration = (( HtmlEditor )controls[0]).Text; } }
public override List <Control> DisplayCoursePage(CoursePage coursePage, Control parentControl) { var controls = new List <Control>(); HiddenField hfScore = new HiddenField { ID = "hfScore", Value = coursePage.PassingScore.ToString() }; parentControl.Controls.Add(hfScore); controls.Add(hfScore); //Update the html to make it pleasent for mobile coursePage.Configuration = coursePage.Configuration.Replace("iframe", "iframe class='embed-item'"); Literal literal = new Literal { Text = "<div id='vimeoVideoContainer' class='embed-responsive embed-responsive-16by9'>" + coursePage.Configuration + "</div>" }; controls.Add(literal); parentControl.Controls.Add(literal); var page = parentControl.Page; ScriptManager.RegisterClientScriptInclude(page, page.GetType(), "VimeoAPI", "https://player.vimeo.com/api/player.js"); ScriptManager.RegisterClientScriptInclude(page, page.GetType(), "VimeoHelper", "/Plugins/org_secc/Equip/VimeoHelper.js"); ScriptManager.RegisterStartupScript(page, page.GetType(), "VimeoSetup", "VimeoSetup();", true); return(controls); }
/// <summary>Configures the controls.</summary> /// <param name="coursePage">The course page.</param> /// <param name="controls">The controls.</param> public virtual void ConfigureControls(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { var textbox = ( RockTextBox )controls[0]; textbox.Text = coursePage.Configuration; } }
public override void ConfigureControls(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { var codeEditor = ( HtmlEditor )controls[0]; codeEditor.Text = coursePage.Configuration; } }
public override void ConfigureCoursePage(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { var widgityControl = ( WidgityControl )controls[0]; widgityControl.EntityTypeId = EntityTypeCache.GetId(typeof(CoursePage)).Value; widgityControl.EntityGuid = coursePage.Guid; widgityControl.Publish(); } }
public override void ConfigureControls(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { var widgityControl = ( WidgityControl )controls[0]; widgityControl.EntityTypeId = EntityTypeCache.GetId(typeof(CoursePage)).Value; widgityControl.EntityGuid = coursePage.Guid; widgityControl.ShowPublishButtons = false; widgityControl.DataBind(); widgityControl.ShowSettings(); } }
/// <summary>Displays the course page.</summary> /// <param name="coursePage">The course page.</param> /// <param name="parentControl">The parent control.</param> /// <returns></returns> public virtual List <Control> DisplayCoursePage(CoursePage coursePage, Control parentControl) { var controls = new List <Control>(); var literal = new RockLiteral { Text = coursePage.Configuration }; parentControl.Controls.Add(literal); controls.Add(literal); return(controls); }
public override void ConfigureControls(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { RockTextBox embedCode = ( RockTextBox )controls[0]; embedCode.Text = coursePage.Configuration; } if (controls.Count > 1) { RockTextBox percentRequired = ( RockTextBox )controls[1]; percentRequired.Text = coursePage.PassingScore.ToString(); } }
public override void ConfigureCoursePage(CoursePage coursePage, List <Control> controls) { if (controls.Count > 0) { RockTextBox embedCode = ( RockTextBox )controls[0]; coursePage.Configuration = embedCode.Text; } if (controls.Count > 1) { RockTextBox percentRequired = ( RockTextBox )controls[1]; coursePage.PassingScore = percentRequired.Text.AsInteger(); } }
public void OpenDevedPage() { mp_POM = new MainPage(chrome); head_ru_POM = new HeaderCityRu(chrome); cr_POM = new CoursePage(chrome); gr_POM = new GraduatePage(chrome); news_POM = new NewsPage(chrome); blog_POM = new BlogPage(chrome); about_POM = new AboutPage(chrome); contact_POM = new ContactPage(chrome); chrome.Navigate().GoToUrl("https://deveducation.com"); chrome.Manage().Window.Maximize(); chrome.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3); }
private void DownloadCourse(int userCourseIndex) { Console.WriteLine("\n-------------------------------"); // We need to subtract 1 from user input number to get the correct index as it null-based var courseTitle = PluralsaverSettings.CoursesToDownload[userCourseIndex - 1]; Console.WriteLine("Downloading course #{0}: {1}", userCourseIndex, courseTitle); OpenCourseInBrowser(courseTitle); CoursePage.Download(); Console.WriteLine("Course download has been completed."); Driver.Close(); }
public override void ConfigureCoursePage(CoursePage coursePage, List <Control> controls) { var configuration = new QuizPageConfiguration(); if (controls.Count > 0) { var hiddenField = ( HiddenField )controls[0]; configuration.QuizConfiguration = hiddenField.Value; } if (controls.Count > 1) { RockTextBox score = ( RockTextBox )controls[1]; coursePage.PassingScore = score.Text.AsInteger(); } coursePage.Configuration = JsonConvert.SerializeObject(configuration); }
protected void btnSavePage_Click(object sender, EventArgs e) { RockContext rockContext = new RockContext(); CoursePageService coursePageService = new CoursePageService(rockContext); var coursePage = GetCoursePage(coursePageService); var pageCourseComponent = GetCoursePageComponent(coursePage); if (coursePage.Id == 0) { var chapterId = PageParameter(PageParameterKey.ChapterId).AsInteger(); var coursePages = coursePageService .Queryable() .Where(p => p.ChapterId == chapterId) .OrderBy(cc => cc.Order).ToList(); int order = 0; if (coursePages.Any()) { order = coursePages.Last().Order + 1; } if (!EntityGuid.HasValue) { EntityGuid = Guid.NewGuid(); } coursePage = new CoursePage { ChapterId = chapterId, EntityTypeId = pageCourseComponent.TypeId, Guid = EntityGuid.Value, Order = order }; coursePageService.Add(coursePage); } coursePage.Name = tbName.Text; pageCourseComponent.ConfigureCoursePage(coursePage, controls); rockContext.SaveChanges(); var queryString = new Dictionary <string, string> { { PageParameterKey.ChapterId, coursePage.ChapterId.ToString() } }; ClientNavigate(queryString); }
public override List <Control> DisplayCoursePage(CoursePage coursePage, Control parentControl) { { var controls = new List <Control>(); WidgityControl widgityControl = new WidgityControl { ID = this.Id + "_widgityControl" }; parentControl.Controls.Add(widgityControl); controls.Add(widgityControl); widgityControl.EntityTypeId = EntityTypeCache.GetId(typeof(CoursePage)).Value; widgityControl.EntityGuid = coursePage.Guid; widgityControl.DataBind(); return(controls); } }
public void CreateNewCourse1() { //reference the webdriver to be used IWebDriver driver = new FirefoxDriver(); //we create a new Coursepage object called 'CreateNewCourse1' to exercise the happy path //For convenience of test case naming, I've also called his happy path test case create new CoursePage CreateNewCourse1 = new CoursePage(); //Test case body CreateNewCourse1.GoToUrl(); CreateNewCourse1.CourseCreateNewLink(); CreateNewCourse1.CourseNumberField("1"); CreateNewCourse1.CourseTitleField("Biology"); CreateNewCourse1.CourseCreditsField("3"); CreateNewCourse1.DepartmentIDField("Biology"); CreateNewCourse1.CourseCreateButton(); }
public override List <Control> DisplayCoursePage(CoursePage coursePage, Control parentControl) { var controls = new List <Control>(); HiddenField hfScore = new HiddenField { ID = "hfScore", Value = coursePage.PassingScore.ToString() }; parentControl.Controls.Add(hfScore); controls.Add(hfScore); var regex = @"((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)"; var rx = new Regex(regex); MatchCollection matches = rx.Matches(coursePage.Configuration); if (matches.Count > 0) { var match = matches[0]; // need this to make the javascript work coursePage.Configuration = coursePage.Configuration.Replace(match.Value, match.Value + "?enablejsapi=1"); } //Update the html to make it pleasent for mobile coursePage.Configuration = coursePage.Configuration.Replace("iframe", "iframe class='embed-item'"); Literal literal = new Literal { Text = "<div id='youtubeVideoContainer' class='embed-responsive embed-responsive-16by9'>" + coursePage.Configuration + "</div>" }; controls.Add(literal); parentControl.Controls.Add(literal); var page = parentControl.Page; ScriptManager.RegisterClientScriptInclude(page, page.GetType(), "YouTubeHelper", "/Plugins/org_secc/Equip/YouTubeHelper.js"); ScriptManager.RegisterStartupScript(page, page.GetType(), "YouTubeSetup", "YouTubeSetup();", true); return(controls); }
public static Task Login(string token, string courseUrl) { return(_initializationTask.ContinueWith((t) => { _session.Driver.Manage().Cookies.AddCookie(new Cookie("token", token, "www.lynda.com", "/", new DateTime(2222, 1, 1))); _coursePage = _session.NavigateTo <CoursePage>(courseUrl); if (_session.Driver.PageSource.Contains("submenu-account")) { _session.Driver.Manage().Cookies.DeleteAllCookies(); _session.Driver.Manage().Cookies.AddCookie(new Cookie("token", token, "www.lynda.com", "/", new DateTime(2222, 1, 1))); _session.NavigateTo <CoursePage>(courseUrl); } else { throw new InvalidTokenException(); } })); }
private CoursePage GetCoursePage(CoursePageService coursePageService) { var coursePageId = PageParameter(PageParameterKey.CoursePageId).AsIntegerOrNull(); if (!coursePageId.HasValue) //if there is no page parameter for the page the user doesn't want it { return(null); } var coursePage = coursePageService.Get(coursePageId.Value); if (coursePage == null) { var chapterId = PageParameter(PageParameterKey.ChapterId).AsInteger(); var coursePages = coursePageService .Queryable() .Where(p => p.ChapterId == chapterId) .OrderBy(cc => cc.Order).ToList(); int order = 0; if (coursePages.Any()) { order = coursePages.Last().Order + 1; } if (!EntityGuid.HasValue) { EntityGuid = Guid.NewGuid(); } var pageCourseComponent = GetCoursePageComponent(coursePage); coursePage = new CoursePage { ChapterId = chapterId, EntityTypeId = PageComponentId ?? 0, Guid = EntityGuid.Value, Order = order, Configuration = string.Empty }; } return(coursePage); }
private CoursePageComponent GetCoursePageComponent(CoursePage coursePage) { if (coursePage == null) { return(null); } var component = ( CoursePageComponent )CoursePageContainer.Instance.Dictionary .Where(c => c.Value.Value.EntityType.Id == coursePage.EntityTypeId) .Select(c => c.Value.Value) .FirstOrDefault(); if (component != null) { PageComponentId = component.TypeId; return(component); } return(null); }
public override void ConfigureControls(CoursePage coursePage, List <Control> controls) { var configuration = JsonConvert.DeserializeObject <QuizPageConfiguration>(coursePage.Configuration); if (configuration == null) { configuration = new QuizPageConfiguration(); } if (controls.Count > 0) { var hiddenField = ( HiddenField )controls[0]; hiddenField.Value = configuration.QuizConfiguration; ScriptManager.RegisterStartupScript(hiddenField.Page, hiddenField.Page.GetType(), "RenderQuizEditor", "RenderQuizEditor();", true); } if (controls.Count > 1) { RockTextBox score = ( RockTextBox )controls[1]; score.Text = coursePage.PassingScore.ToString(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,HtmlContent,UnitId")] CoursePage coursePage) { if (id != coursePage.Id) { return(NotFound()); } if (ModelState.IsValid) { try { // url address if (String.IsNullOrEmpty(coursePage.UrlName)) { // leave all coursePage.UrlName = coursePage.Title.ConvertToUrlName(); if (coursePage.UrlName.Length < 4) // error if too small { ModelState.AddModelError("UrlName", "Choose a url name which contains only numbers, digits, hyphen and underbar, or choose a course name with more english chars."); return(View(coursePage)); } } _context.Update(coursePage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoursePageExists(coursePage.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UnitId"] = new SelectList(_context.Units, "Id", "Id", coursePage.UnitId); return(View(coursePage)); }
public Task Login(string token, string courseUrl, Task initializationTask) { return(initializationTask.ContinueWith((t) => { Sessions[0].Driver.Manage().Cookies.AddCookie(new Cookie("token", token, "www.lynda.com", "/", new DateTime(2222, 1, 1))); coursePage = Sessions[0].NavigateTo <CoursePage>(courseUrl); if (Sessions[0].Driver.PageSource.Contains("submenu-account")) { Parallel.For(1, NumberOfSessions, (i) => { Sessions[i].Driver.Manage().Cookies.DeleteAllCookies(); Sessions[i].Driver.Manage().Cookies.AddCookie(new Cookie("token", token, "www.lynda.com", "/", new DateTime(2222, 1, 1))); }); Sessions[0].NavigateTo <CoursePage>(courseUrl); } else { throw new InvalidTokenException(); } })); }
public static void KillDrivers() { if (!(_session is null)) { _session.Driver.Quit(); _session = null; _coursePage = null; _allVideos = null; _course = null; _initializationTask = null; _statusLock = new object(); } Process[] geckodriverProcesses = Process.GetProcessesByName("geckodriver"); foreach (var geckodriverProcess in geckodriverProcesses) { geckodriverProcess.KillTree(); } Process[] chromedriverProcesses = Process.GetProcessesByName("chromedriver"); foreach (var chromedriverProcess in chromedriverProcesses) { chromedriverProcess.KillTree(); } }
public async Task <IActionResult> Create([Bind("Id,Title,HtmlContent,UnitId")] CoursePage coursePage) { if (ModelState.IsValid) { // url address if (String.IsNullOrEmpty(coursePage.UrlName)) { // leave all coursePage.UrlName = coursePage.Title.ConvertToUrlName(); if (coursePage.UrlName.Length < 4) // error if too small { ModelState.AddModelError("UrlName", "Choose a url name which contains only numbers, digits, hyphen and underbar, or choose a course name with more english chars."); return(View(coursePage)); } } _context.Add(coursePage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UnitId"] = new SelectList(_context.Courses, "Id", "DisplayName", coursePage.Unit.CourseId); return(View(coursePage)); }
public override List <Control> DisplayCoursePage(CoursePage coursePage, Control parentControl) { var configuration = JsonConvert.DeserializeObject <QuizPageConfiguration>(coursePage.Configuration); var controls = new List <Control>(); HiddenField hfScore = new HiddenField { ID = "hfScore", Value = configuration.QuizConfiguration }; parentControl.Controls.Add(hfScore); controls.Add(hfScore); HiddenField hfConfiguration = new HiddenField { ID = "hfConfiguration", Value = configuration.QuizConfiguration }; parentControl.Controls.Add(hfConfiguration); controls.Add(hfConfiguration); Literal literal = new Literal { Text = "<div class='QuizContent'></div>" }; controls.Add(literal); parentControl.Controls.Add(literal); var page = parentControl.Page; ScriptManager.RegisterClientScriptInclude(page, page.GetType(), "QuizDisplay", "/Plugins/org_secc/Equip/QuizDisplay.js"); ScriptManager.RegisterStartupScript(page, page.GetType(), "RenderQuizDisplay", "RenderQuizDisplay();", true); return(controls); }
private void UpdateTableOfContents(CoursePage coursePage) { phTOC.Controls.Clear(); phMobileTOC.Controls.Clear(); var course = coursePage.Chapter.Course; var passed = false; var first = true; var mostAdvancedCoursePageId = coursePage.Id; if (ViewState["coursePageRecordId"] is int) { RockContext rockContext = new RockContext(); CoursePageRecordService coursePageRecordService = new CoursePageRecordService(rockContext); mostAdvancedCoursePageId = coursePageRecordService.Get(( int )ViewState["coursePageRecordId"]).CoursePageId; } foreach (var chapter in course.Chapters.OrderBy(c => c.Order).ToList()) { var ltChapter = new Literal { ID = "ltChapter" + chapter.Id.ToString(), }; if (coursePage.ChapterId == chapter.Id) { ltChapter.Text = string.Format("<b>{0}</b></br>", chapter.Name); } else { ltChapter.Text = string.Format("{0}</br>", chapter.Name); } phTOC.Controls.Add(ltChapter); //Mobile if (!first) { HtmlGenericControl liDivider = new HtmlGenericControl("li"); liDivider.AddCssClass("divider"); phMobileTOC.Controls.Add(liDivider); } first = false; HtmlGenericControl liChapter = new HtmlGenericControl("li"); liChapter.AddCssClass("dropdown-header"); liChapter.InnerText = chapter.Name; phMobileTOC.Controls.Add(liChapter); //Add the course pages foreach (var page in chapter.CoursePages.OrderBy(c => c.Order).ToList()) { phTOC.Controls.Add(new Literal { Text = " " }); if (page.Id == coursePage.Id) { Literal ltPage = new Literal { ID = "ltPage" + page.Id.ToString(), Text = string.Format("<a href='#'><i class='fa fa-caret-right'></i> {0}</a><br>", page.Name) }; phTOC.Controls.Add(ltPage); //Mobile phMobileTitle.Controls.Clear(); Literal mobileTitle = new Literal { Text = page.Name }; phMobileTitle.Controls.Add(mobileTitle); HtmlGenericControl li = new HtmlGenericControl("li") { InnerHtml = string.Format("<a href='#'><i class='fa fa-caret-right'></i> {0}</a>", page.Name) }; phMobileTOC.Controls.Add(li); } else { LinkButton lbPage = new LinkButton { ID = "lbPage" + page.Id.ToString(), Text = string.Format("{0}<br>", page.Name) }; HtmlGenericControl li = new HtmlGenericControl("li"); phMobileTOC.Controls.Add(li); LinkButton lbMobile = new LinkButton { ID = "lbMobile" + page.Id.ToString(), Text = page.Name }; if (passed) { lbPage.Enabled = false; lbMobile.Enabled = false; } else { lbPage.Click += (s, e) => { MoveToPage(page.Id); }; lbMobile.Click += (s, e) => { MoveToPage(page.Id); }; } phTOC.Controls.Add(lbPage); li.Controls.Add(lbMobile); } if (page.Id == mostAdvancedCoursePageId) { passed = true; } } } }