public void Tutorial_parses_html_document_of_objectives() { // Given const string objectives = "<html> <head> <title>Tutorial Objective</title> </head>" + "<body> In this tutorial you will learn to: " + "<ul>" + "<li>open another window on to a workbook</li>" + "<li>arrange workbook windows</li>" + "<li>hide and show windows</li>" + "</ul>" + "</body> </html>"; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( objectives: objectives ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.Objectives.Should().Be(" In this tutorial you will learn to: " + "<ul>" + "<li>open another window on to a workbook</li>" + "<li>arrange workbook windows</li>" + "<li>hide and show windows</li>" + "</ul>"); }
public async Task <IActionResult> Index(string slug = null) { var tutorials = (await wordPressService.GetPostsByCategory((int)PostCategory.Tutorials))?.OrderByDescending(o => o.Id); var firstSlug = tutorials?.Select(s => s.Slug).FirstOrDefault(); if (string.IsNullOrEmpty(firstSlug)) { return(RedirectToAction("Index", "Home")); } if (string.IsNullOrEmpty(slug)) { return(RedirectToAction("Index", "Tutorial", new { slug = firstSlug })); } var id = tutorials.Where(t => t.Slug == slug).Select(s => s.Id).Single(); var model = new TutorialViewModel() { Tutorials = tutorials, Post = await wordPressService.GetPost(id) }; ViewBag.Title = model.Post.Title.Rendered; return(View(model)); }
public async Task <IActionResult> Edit(TutorialViewModel model) { if (ModelState.IsValid) { try { string path = model.PicturePath; if (model.LogoFile != null) { path = await _imageHelper.UploadImageAsync(model.LogoFile, "Tutorials"); } var tutorial = _converterHelper.ToTutorial(model, path, false); _context.Update(tutorial); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { ModelState.AddModelError(string.Empty, "An error has ocurred saving the data"); return(View(model)); } return(RedirectToAction(nameof(Index))); } return(View(model)); }
public void Tutorial_should_have_nextLinkViewModel() { // Given const string postLearningAssessmentPath = "/assessment"; const int nextTutorialId = 101; const int nextSectionId = 100; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( nextTutorialId: nextTutorialId, nextSectionId: nextSectionId, postLearningAssessmentPath: postLearningAssessmentPath ); var expectedNextLinkViewModel = new TutorialNextLinkViewModel( CustomisationId, SectionId, postLearningAssessmentPath, nextTutorialId, nextSectionId ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.NextLinkViewModel.Should().BeEquivalentTo(expectedNextLinkViewModel); }
private FrameworkElement getComponentFromParent(DependencyObject parent, TutorialViewModel context) { if (string.IsNullOrEmpty(context.CurrentStep.ComponentToHighlight)) { return(null); } //Try to get the Type Type ComponentType = Type.GetType(context.CurrentStep.ComponentToHighlight); FrameworkElement ToSearch; if (ComponentType != null) { ToSearch = (FrameworkElement)UiHelper.FindChildWithType(parent, ComponentType); } //Otherwise, return with string ToSearch = (FrameworkElement)UiHelper.FindChildWithName(parent, context.CurrentStep.ComponentToHighlight); if (ToSearch == null) { throw new InvalidOperationException("An element defined to be highlighted " + "in a tutorial must exist."); } return(ToSearch); }
public void Tutorial_should_have_showNextButton( string status, bool otherSectionsExist, bool otherItemsInSectionExist, bool expectedShowNextButton ) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: status, otherSectionsExist: otherSectionsExist, otherItemsInSectionExist: otherItemsInSectionExist ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowNextButton.Should().Be(expectedShowNextButton); }
public JsonTutorial tutorialList() { JsonTutorial jsonTutorial = new JsonTutorial(); List <TutorialViewModel> tutorialLISTOBJ = new List <TutorialViewModel>(); try { var tutorialListes = _link.TutorialCategory(); foreach (var item in tutorialListes) { TutorialViewModel tutorialOBJ = new TutorialViewModel(); tutorialOBJ.Title = item.Title; tutorialOBJ.Link = item.Url; tutorialOBJ.Description = item.Description; tutorialLISTOBJ.Add(tutorialOBJ); } jsonTutorial.Result = tutorialLISTOBJ; return(jsonTutorial); } catch (Exception ex) { _ = ex.Message; return(jsonTutorial); } }
private void RunOnElement(TutorialViewModel context, FrameworkElement parent, FrameworkElement component) { //Check if we need to right click if (context.CurrentStep.RightClickOnComponent) { //Right click in the middle of the managed component Point Position = component.TranslatePoint(new Point(0, 0), parent); RightMouseClick(Convert.ToInt32(Position.X + component.ActualWidth / 2), Convert.ToInt32(Position.Y + component.ActualHeight / 2)); } //Check if a command exist to run if (!string.IsNullOrEmpty(context.CurrentStep.RunThisCommand)) { Type VmType = context.GetType(); MethodInfo method = VmType.GetMethod(context.CurrentStep.RunThisCommand); method.Invoke(element, null); } //Check if we need to send a message if (!string.IsNullOrEmpty(context.CurrentStep.SendThisMessage)) { Messenger.Default.Send(new NotificationMessage(context, context.CurrentStep.SendThisMessage)); } }
/// <summary> /// Get Tutorial by id /// </summary> /// <param name="id">Tutorial id</param> /// <returns>Tutorial json view model</returns> public IHttpActionResult Get(int id) { try { // get log.Debug("_tutorialService.GetTutorial - tutorialId: " + id + " "); var tutorial = new TutorialViewModel(_tutorialService.GetTutorial(id)); log.Debug("_tutorialService.GetTutorial - " + TutorialViewModel.FormatTutorialViewModel(tutorial)); log.Debug("result: 'success'"); //return Json(tutorial, JsonRequestBehavior.AllowGet); //return Content(JsonConvert.SerializeObject(tutorial), "application/json"); //return tutorial; //return JsonConvert.SerializeObject(tutorial); return(Ok(tutorial)); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
private TutorialDTO Create(TutorialViewModel viewModel) { try { log.Debug(TutorialViewModel.FormatTutorialViewModel(viewModel)); TutorialDTO tutorial = new TutorialDTO(); // copy values viewModel.UpdateDTO(tutorial, null); //RequestContext.Principal.Identity.GetUserId()); // audit tutorial.CreateBy = null; //RequestContext.Principal.Identity.GetUserId(); tutorial.CreateOn = DateTime.UtcNow; // add log.Debug("_tutorialService.AddTutorial - " + TutorialDTO.FormatTutorialDTO(tutorial)); int id = _tutorialService.AddTutorial(tutorial); tutorial.TutorialId = id; log.Debug("result: 'success', id: " + id); return(tutorial); } catch (Exception e) { // error log.Error(e.ToString()); throw; } }
public void Tutorial_should_have_timeSummary( int timeSpent, int averageTutorialDuration, bool showTime, bool showLearnStatus ) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( timeSpent: timeSpent, averageTutorialDuration: averageTutorialDuration, courseSettings: "{\"lm.st\":" + showTime.ToString().ToLower() + ", \"lm.sl\":" + showLearnStatus.ToString().ToLower() + "}" ); var expectedTimeSummary = new TutorialTimeSummaryViewModel( timeSpent, averageTutorialDuration, showTime, showLearnStatus ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TimeSummary.Should().BeEquivalentTo(expectedTimeSummary); }
public void Tutorial_should_have_showCompletionSummary( bool otherSectionsExist, bool otherItemsInSectionExist, bool includeCertification, bool expectedShowCompletionSummary ) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( otherSectionsExist: otherSectionsExist, otherItemsInSectionExist: otherItemsInSectionExist, includeCertification: includeCertification ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowCompletionSummary.Should().Be(expectedShowCompletionSummary); }
public Tutorial() { DataContext = new TutorialViewModel(); InitializeComponent(); Step = 1; MaxStep = 7; ShowStep(); }
// Constructor for the page. Attaches the binding public TutorialPage() { viewModel = new TutorialViewModel(); InitializeComponent(); BindingContext = viewModel; }
public TutorialView() { InitializeComponent(); _viewModel = new TutorialViewModel(); DataContext = _viewModel; this.Resources.MergedDictionaries.Add(App.resdict); this.Unloaded += _viewModel.TutorialView_Unloaded; }
public IActionResult Create() { TutorialViewModel model = new TutorialViewModel { Categories = _combosHelper.GetComboCategories() }; return(View(model)); }
public Tutorial ToTutorial(TutorialViewModel model, string path, bool isNew) { return(new Tutorial { Id = isNew ? 0 : model.Id, PicturePath = path, Title = model.Title, Description = model.Description, Category = _context.Categories.Find(model.CategoryId), Date = model.Date }); }
private void BuildText(FrameworkElement parent, TutorialViewModel context , Rect ComponentSpace) { //Write text somewhere not in the way Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); TextBlock block = new TextBlock { Text = LocalizationHelper.getValueForKey(context.CurrentStep.TextKey, LocalesSource.Tutorial), Foreground = Brushes.White, FontSize = 18, TextWrapping = TextWrapping.Wrap }; FormattedText formattedText = new FormattedText( LocalizationHelper.getValueForKey(context.CurrentStep.TextKey, LocalesSource.Tutorial), CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface(block.FontFamily, block.FontStyle, block.FontWeight, block.FontStretch), block.FontSize, Brushes.White) { MaxTextWidth = Math.Min(parent.Width / 2, MinTestWidth), MaxTextHeight = bestTextHeight }; BorderPositionning = getNotInTheWayRectangle(ComponentSpace, parent, formattedText); border = new Border { Height = formattedText.Height + ButtonHeightAndMargin, Padding = new Thickness(5), Width = formattedText.Width + bestMargin, Background = (Brush)appStyle.Item1.Resources["WindowBackgroundBrush"], BorderThickness = new Thickness(1), BorderBrush = new SolidColorBrush((Color)appStyle.Item2.Resources["AccentColor"]), HorizontalAlignment = HorizontalAlignment.Left, Child = new StackPanel { Orientation = Orientation.Vertical } }; ((StackPanel)border.Child).Children.Add(block); if (string.IsNullOrEmpty(context.CurrentStep.WaitForMessage)) { ((StackPanel)border.Child).Children.Add(new Button { Content = LocalizationHelper.getValueForKey("Tutorial_Continue", LocalesSource.Tutorial), Style = (Style)parent.FindResource("SquareButtonStyle"), Command = context.ContinueCommand, Margin = new Thickness(5), Width = 150, HorizontalAlignment = HorizontalAlignment.Center }); } Children.Add(border); }
public async Task <IActionResult> Tutorial(int customisationId, int sectionId, int tutorialId) { var candidateId = User.GetCandidateIdKnownNotNull(); var centreId = User.GetCentreId(); var tutorialInformation = tutorialContentDataService.GetTutorialInformation(candidateId, customisationId, sectionId, tutorialId); if (tutorialInformation == null) { logger.LogError( "Redirecting to 404 as customisation/section/tutorial id was not found. " + $"Candidate id: {candidateId}, customisation id: {customisationId}, " + $"centre id: {centreId.ToString() ?? "null"}, section id: {sectionId} tutorial id: {tutorialId}" ); return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 })); } if (!String.IsNullOrEmpty(tutorialInformation.Password) && !tutorialInformation.PasswordSubmitted) { return(RedirectToAction("CoursePassword", "LearningMenu", new { customisationId })); } var progressId = courseContentService.GetOrCreateProgressId(candidateId, customisationId, centreId); if (progressId == null) { logger.LogError( "Redirecting to 404 as no progress id was returned. " + $"Candidate id: {candidateId}, customisation id: {customisationId}, centre id: {centreId}" ); return(RedirectToAction("StatusCode", "LearningSolutions", new { code = 404 })); } sessionService.StartOrUpdateDelegateSession(candidateId, customisationId, HttpContext.Session); courseContentService.UpdateProgress(progressId.Value); /* Course progress doesn't get updated if the auth token expires by the end of the tutorials. * Some tutorials are longer than the default auth token lifetime of 1 hour, so we set the auth expiry to 8 hours. * See HEEDLS-637 and HEEDLS-674 for more details */ if (tutorialInformation.AverageTutorialDuration >= MinimumTutorialAverageTimeToIncreaseAuthExpiry) { await IncreaseAuthenticatedUserExpiry(); } var viewModel = new TutorialViewModel(config, tutorialInformation, customisationId, sectionId); return(View("Tutorial/Tutorial", viewModel)); }
public ActionResult Tutorials_Create([DataSourceRequest]DataSourceRequest request, TutorialViewModel model) { if (ModelState.IsValid) { this.tutorials.Add( model.Title, model.Game, model.Content, User.Identity.GetUserId(), model.ImageId ); } return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public ActionResult Tutorials_Update([DataSourceRequest]DataSourceRequest request, TutorialViewModel model) { if (ModelState.IsValid) { this.tutorials.Edit( model.Id, model.Title, model.Game, model.Content, model.ImageId); } return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public void Tutorial_should_have_tutorialId() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TutorialId.Should().Be(TutorialId); }
// GET: Lessons/Details/5 public async Task <ActionResult> Details(Guid?id, string languageFilter) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lesson lesson = await db.Lessons.FindAsync(id); if (lesson == null) { return(HttpNotFound()); } MethodHelpers methodHelpers = new MethodHelpers(); TutorialViewModel viewModel = new TutorialViewModel(); viewModel.LessionID = lesson.LessionID; viewModel.LessonName = lesson.LessonName; viewModel.IssueDate = lesson.IssueDate; viewModel.Subject = lesson.Subject; List <File> files = await db.Files.Where(d => d.LessionID == lesson.LessionID).ToListAsync(); ViewBag.VideoContent = false; ViewBag.IsTranscript = false; foreach (var item in files) { if (item.FileType == "Video") { if (languageFilter != null && item.ContentDetails != null) { item.ContentDetails = await methodHelpers.TranslateContent(item.ContentDetails, languageFilter); } ViewBag.VideoContent = true; if (!string.IsNullOrEmpty(item.ContentDetails)) { ViewBag.IsTranscript = true; } } } viewModel.Files = files; Dictionary <string, string> languageList = methodHelpers.GetSupportedLangs(); SelectList langs = new SelectList(languageList.Select(x => new { Value = x.Key, Text = x.Value }), "Value", "Text"); ViewBag.languageFilter = langs; ViewBag.LessionID = id; return(View(viewModel)); }
public async Task Tutorial_should_render_view() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation(TutorialId); A.CallTo(() => tutorialContentDataService.GetTutorialInformation(CandidateId, CustomisationId, SectionId, TutorialId)) .Returns(expectedTutorialInformation); A.CallTo(() => courseContentService.GetOrCreateProgressId(CandidateId, CustomisationId, CentreId)).Returns(3); // When var result = await controller.Tutorial(CustomisationId, SectionId, TutorialId); // Then var expectedModel = new TutorialViewModel(config, expectedTutorialInformation, CustomisationId, SectionId); result.Should().BeViewResult() .Model.Should().BeEquivalentTo(expectedModel); }
public void Tutorial_handles_null_objectives() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( objectives: null ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.Objectives.Should().BeNull(); }
public void Tutorial_should_have_default_supportingMaterialsLabel_when_courseSetting_is_empty() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( courseSettings: null ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.SupportingMaterialsLabel.Should().Be("Download supporting materials"); }
public void Tutorial_should_have_default_showLearnStatus_when_courseSetting_is_empty() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( courseSettings: null ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowLearnStatus.Should().BeTrue(); }
public void Tutorial_should_have_showLearnStatus_from_courseSetting() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( courseSettings: "{\"lm.sl\":false}" ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.ShowLearnStatus.Should().BeFalse(); }
public void Tutorial_start_button_should_be_grey_if_tutorial_status_is_complete() { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: "Complete" ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TutorialStartButtonAdditionalStyling.Should().Be("nhsuk-button--secondary"); }
public void Tutorial_start_button_should_say_start_tutorial_if_tutorial_status_is_not_complete(string status) { // Given var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: status ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.TutorialStartButtonText.Should().Be("Start tutorial"); }
public void Tutorial_should_have_completion_summary_card_view_model( int customisationId, string?completed, int maxPostLearningAssessmentAttempts, bool isAssessed, int postLearningAssessmentPassThreshold, int diagnosticAssessmentCompletionThreshold, int tutorialsCompletionThreshold ) { // Given var completedDateTime = completed != null?DateTime.Parse(completed) : (DateTime?)null; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( completed: completedDateTime, maxPostLearningAssessmentAttempts: maxPostLearningAssessmentAttempts, isAssessed: isAssessed, postLearningAssessmentPassThreshold: postLearningAssessmentPassThreshold, diagnosticAssessmentCompletionThreshold: diagnosticAssessmentCompletionThreshold, tutorialsCompletionThreshold: tutorialsCompletionThreshold ); var expectedCompletionSummaryViewModel = new CompletionSummaryCardViewModel( customisationId, completedDateTime, maxPostLearningAssessmentAttempts, isAssessed, postLearningAssessmentPassThreshold, diagnosticAssessmentCompletionThreshold, tutorialsCompletionThreshold ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, customisationId, SectionId ); // Then tutorialViewModel.CompletionSummaryCardViewModel .Should().BeEquivalentTo(expectedCompletionSummaryViewModel); }
public void Tutorial_should_have_status() { // Given const string status = "Not started"; var expectedTutorialInformation = TutorialContentHelper.CreateDefaultTutorialInformation( status: status ); // When var tutorialViewModel = new TutorialViewModel( config, expectedTutorialInformation, CustomisationId, SectionId ); // Then tutorialViewModel.Status.Should().Be(status); }
public ActionResult Tutorials_Destroy([DataSourceRequest]DataSourceRequest request, TutorialViewModel model) { this.tutorials.Delete(model.Id); return Json(new[] { model }.ToDataSourceResult(request, ModelState)); }
public ActionResult Create(TutorialViewModel model) { if (!ModelState.IsValid) { return View(model); } var id = this.tutorials.Add(model.Title, model.Game, Server.HtmlDecode(model.Content), User.Identity.GetUserId(), model.ImageId); return RedirectToAction("Details", "Tutorials", new { id = id }); }