public async System.Threading.Tasks.Task <ActionResult> MarkAttendance(FormCollection formCollection)
        {
            SectionVM      section  = new SectionVM();
            List <Section> sections = new List <Section>();
            string         EmpName  = formCollection[1];

            Int32.TryParse(formCollection[2], out int courseID);
            section.EmpName  = EmpName;
            section.CourseID = courseID;
            var json = JsonConvert.SerializeObject(new DataVM {
                courseID = courseID, empName = EmpName
            });
            var data = new StringContent(json, Encoding.UTF8, "application/json");

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44380/api/");
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage result = await client.PostAsync("AttendanceTeacher/GetTeacherSections/", data);

                var response = result.Content.ReadAsStringAsync().Result;

                sections = JsonConvert.DeserializeObject <List <Section> >(response);
            }
            section.sections = sections;
            return(View("ChooseSection", section));
        }
Ejemplo n.º 2
0
        public IActionResult Index()
        {
            var survey  = new SurveyVM();
            var section = new SectionVM()
            {
                Label = "Section1"
            };

            section.Controls.Add(new QuestionVM()
            {
                Label = "Question1"
            });
            section.Controls.Add(new QuestionVM()
            {
                Label = "Question2"
            });
            section.Controls.Add(new QuestionVM()
            {
                Label = "Question3"
            });
            section.Controls.Add(new ButtonVM()
            {
                Label = "Button1"
            });
            section.Controls.Add(new QuestionVM()
            {
                Label = "Question4"
            });
            section.Controls.Add(new QuestionVM()
            {
                Label = "Question5"
            });
            section.Controls.Add(new LabelVM()
            {
                Label = "I am a label!"
            });
            survey.Controls.Add(section);

            var section2 = new SectionVM()
            {
                Label = "Section2"
            };

            section2.Controls.Add(new QuestionVM()
            {
                Label = "Question6"
            });
            section2.Controls.Add(new QuestionVM()
            {
                Label = "Question7"
            });
            section2.Controls.Add(new QuestionVM()
            {
                Label = "Question8"
            });
            section.Controls.Add(section2);

            return(View(survey));
        }
Ejemplo n.º 3
0
        public List <string> GetBreadCrumbs(SectionVM model)
        {
            var breadcrumb = new List <string>();

            if (model.Parent != null)
            {
                AddLink(breadcrumb, model.Parent);
            }
            return(breadcrumb);
        }
Ejemplo n.º 4
0
        public async Task <IViewComponentResult> InvokeAsync(SectionModel model)
        {
            var viewModel = new SectionVM
            {
                Id       = model.Id,
                CourseId = model.CourseId,
                Items    = _context.MediaItems.Where(x => x.SectionId == model.Id).ToList()
            };

            return(View(viewModel));
        }
        public string GetSection(int Id)
        {
            Section   results       = new Section();
            SectionVM returnResults = new SectionVM();
            string    json;

            using (ApplicationDbContext data = new ApplicationDbContext())
            {
                results = data.Sections.FirstOrDefault(X => X.Id == Id);
            }

            returnResults.Name        = results.Name;
            returnResults.Description = results.Description;

            json = JsonConvert.SerializeObject(returnResults);

            return(json);
        }
Ejemplo n.º 6
0
        private bool UpdateQuestion(int idTest)
        {
            _isAnswer = false;
            if (CheckIsWinOrEndQuestions(idTest))
            {
                return(false);
            }
            spStartGame.Visibility     = Visibility.Visible;
            btnReference.Visibility    = Visibility.Visible;
            btnNextQuestion.Visibility = Visibility.Visible;

            btnAnswerA.Background = Brushes.LightGray;
            btnAnswerB.Background = Brushes.LightGray;
            btnAnswerC.Background = Brushes.LightGray;
            btnAnswerD.Background = Brushes.LightGray;

            lblResult.Content    = null;
            lblResult.Background = null;
            lblResult.Foreground = null;

            requestUrl = _hostUrl + $"/api/jsstudygame/test?login={MainWindow.playerLogin}" +
                         $"&password={MainWindow.playerPassword}&id={idTest}";
            _test = ServerWorker.GetInfoFromServer <TestVM>(requestUrl);
            if (_test == null)
            {
                return(false);
            }

            txtbtnAnswerA.Text = null;
            txtbtnAnswerB.Text = null;
            txtbtnAnswerC.Text = null;
            txtbtnAnswerD.Text = null;

            Random random = new Random();

            switch (random.Next(4))
            {
            case 0:
                txtQuestion.Text   = _test.Question;
                txtbtnAnswerA.Text = _test.CorrectAnswer;
                txtbtnAnswerB.Text = _test.AnswerA;
                txtbtnAnswerC.Text = _test.AnswerB;
                txtbtnAnswerD.Text = _test.AnswerC;
                break;

            case 1:
                txtbtnAnswerA.Text = _test.AnswerA;
                txtbtnAnswerB.Text = _test.CorrectAnswer;
                txtbtnAnswerC.Text = _test.AnswerB;
                txtbtnAnswerD.Text = _test.AnswerC;
                break;

            case 2:
                txtbtnAnswerA.Text = _test.AnswerA;
                txtbtnAnswerB.Text = _test.AnswerB;
                txtbtnAnswerC.Text = _test.CorrectAnswer;
                txtbtnAnswerD.Text = _test.AnswerC;
                break;

            case 3:
                txtbtnAnswerA.Text = _test.AnswerA;
                txtbtnAnswerB.Text = _test.AnswerB;
                txtbtnAnswerC.Text = _test.AnswerC;
                txtbtnAnswerD.Text = _test.CorrectAnswer;
                break;

            default:
                txtbtnAnswerA.Text = _test.AnswerA;
                txtbtnAnswerB.Text = _test.AnswerB;
                txtbtnAnswerC.Text = _test.AnswerC;
                txtbtnAnswerD.Text = _test.CorrectAnswer;
                break;
            }
            txtQuestion.Text     = _test.Question;
            lblQuestionN.Content = _test.Id;

            try
            {
                requestUrl = _hostUrl + $"/api/jsstudygame/section?login={MainWindow.playerLogin}" +
                             $"&password={MainWindow.playerPassword}&id={_test.IdSection}";
                _sectionVM = ServerWorker.GetInfoFromServer <SectionVM>(requestUrl);

                if (_sectionVM != null)
                {
                    lblSection.Content = _sectionVM.NameOFSection;
                }
            }
            catch (Exception) { Debug.WriteLine("some mistake"); }
            return(true);
        }
Ejemplo n.º 7
0
 private static string GetTitle(SectionVM model)
 {
     return
         ((model.Section.Name.ToLowerInvariant().Contains("курсы") ? "" :
           "Курсы ") + model.Section.Name + " в Специалисте");
 }