Beispiel #1
0
        // GET: Course
        public ActionResult JoinACourse(string courseCode)
        {
            CourseGetResponse  cgr = _courseCom.GetCourse(courseCode);
            DisplayCourseModel dcm = new DisplayCourseModel();

            if (cgr != null)
            {
                dcm.CourseCode             = cgr.CourseCode;
                dcm.CourseDescription      = cgr.CourseDescription;
                dcm.CourseName             = cgr.CourseName;
                dcm.DesiredSkillSets       = cgr.DesiredSkillSets;
                dcm.GroupSize              = (int)cgr.GroupSize;
                dcm.GroupType              = cgr.GroupType;
                dcm.PreferSimiliarSkillSet = (bool)cgr.PreferSimiliarSkillSet;
                dcm.Users     = new List <GT.BuddyUp.WebApp.Models.DisplayCourseUser>();
                dcm.Questions = new List <GT.BuddyUp.WebApp.Models.DsiplayQuestion>();
            }
            foreach (var user in cgr.UserList)
            {
                dcm.Users.Add(new DisplayCourseUser()
                {
                    emailId = user.EmailID,
                    name    = user.Name,
                    role    = user.RoleCode
                });
            }

            QuestionnaireGetResponse qgr = _questionnaireCom.GetQuestionnaire(cgr.QuestionnaireCode);

            if (qgr != null)
            {
                foreach (var q in qgr.Questions)
                {
                    dcm.Questions.Add(new GT.BuddyUp.WebApp.Models.DsiplayQuestion()
                    {
                        QuestionText  = q.questionText,
                        QuestionType  = q.questionType,
                        AnswerChoices = q.answerChoices
                    });
                }
            }
            return(View(dcm));
        }
Beispiel #2
0
 public async Task <ActionResult> JoinACourse(DisplayCourseModel Model)
 {
     if (ModelState.IsValid)
     {
         StringBuilder answerSet = new StringBuilder();
         foreach (var question in Model.Questions)
         {
             if (!string.IsNullOrWhiteSpace(question.selectedAnswer))
             {
                 answerSet.Append(question.selectedAnswer + ",");
             }
         }
         answerSet.Remove(answerSet.Length - 1, 1);
         CourseUserUpdateRequest cuur = new CourseUserUpdateRequest()
         {
             email      = User.Identity.Name,
             courseCode = Model.CourseCode,
             RoleCode   = "Student",
             answerSet  = answerSet.ToString()
         };
         bool result = _courseUserCom.UpdateCourseUser(cuur);
         if (result)
         {
             //MvcApplication.courses.Add(Model.CourseCode, Model.CourseName);
             //MvcApplication.courseDescription.Add(Model.CourseCode, Model.CourseDescription);
             return(RedirectToAction("Student", "Course"));
         }
         else
         {
             ModelState.AddModelError("", "Oops! Something wrong happened! Please try again.");
             return(View(Model));
         }
     }
     ModelState.AddModelError("", "Oops! Something wrong happened! Please try again.");
     return(View(Model));
 }
Beispiel #3
0
        public ActionResult CourseTeacher(string courseId)
        {
            CourseGetResponse  cgr = _courseCom.GetCourse(courseId);
            DisplayCourseModel dcm = new DisplayCourseModel();

            if (cgr != null)
            {
                dcm.CourseCode        = cgr.CourseCode;
                dcm.CourseDescription = cgr.CourseDescription;
                dcm.CourseName        = cgr.CourseName;
                dcm.DesiredSkillSets  = cgr.DesiredSkillSets;
                dcm.GroupSize         = (int)cgr.GroupSize;
                dcm.GroupType         = cgr.GroupType;
                if (!string.IsNullOrWhiteSpace(cgr.Roaster))
                {
                    dcm.Roaster = cgr.Roaster.Split(',').ToList();
                }
                else
                {
                    dcm.Roaster = null;
                }
                dcm.PreferSimiliarSkillSet = (bool)cgr.PreferSimiliarSkillSet;
                dcm.Users     = new List <GT.BuddyUp.WebApp.Models.DisplayCourseUser>();
                dcm.Questions = new List <GT.BuddyUp.WebApp.Models.DsiplayQuestion>();
                dcm.Groups    = new List <DisplayGroup>();
            }

            foreach (var user in cgr.UserList)
            {
                dcm.Users.Add(new DisplayCourseUser()
                {
                    emailId = user.EmailID,
                    name    = user.Name,
                    role    = user.RoleCode
                });
            }

            foreach (var grp in cgr.CourseGroups)
            {
                var dg = new DisplayGroup()
                {
                    GroupCode    = grp.GroupCode,
                    GroupName    = grp.GroupName,
                    Objective    = grp.Objective,
                    TimeZone     = grp.TimeZone,
                    GroupMembers = new List <DisplayCourseUser>()
                };
                foreach (var gm in grp.GroupUsers)
                {
                    dg.GroupMembers.Add(new DisplayCourseUser()
                    {
                        emailId = gm.EmailID,
                        name    = gm.Name,
                        role    = gm.RoleCode
                    });
                }
                dcm.Groups.Add(dg);
            }

            QuestionnaireGetResponse qgr = _questionnaireCom.GetQuestionnaire(cgr.QuestionnaireCode);

            if (qgr != null)
            {
                foreach (var q in qgr.Questions)
                {
                    dcm.Questions.Add(new GT.BuddyUp.WebApp.Models.DsiplayQuestion()
                    {
                        QuestionText  = q.questionText,
                        QuestionType  = q.questionType,
                        AnswerChoices = q.answerChoices
                    });
                }
            }
            return(View(dcm));
        }