Exemplo n.º 1
0
 public ActionResult Index()
 {
     if (Request.Params["student_id"] != null)
     {
         string student_username=Request.Params["student_id"];
         Student student;
         if (DocumentorDB.Students.Where(a => a.username.Equals(student_username)).Count() > 0)
         {
             student= DocumentorDB.Students.Where(a => a.username.Equals(student_username)).First();
         }
         else
         {
             Student new_student = new Student();
             Employee employee=KotakEmployeeDB.Employees.Where(a=>a.UserLoginName.Equals(student_username)).First();
             new_student.username = employee.UserLoginName;
             new_student.unique_id = employee.ID;
             new_student.time_spend = 0;
             new_student.first_visit = DateTime.Now;
             DocumentorDB.Students.InsertOnSubmit(new_student);
             DocumentorDB.SubmitChanges();
             student = DocumentorDB.Students.Where(a => a.username.Equals(student_username)).First();
             student.create_progress_tracker();
         }
         Session["student_id"] = "Indraneel More";
         ViewData["modules"] = DocumentorDB.Modules.ToList();
         ViewData["student_id"] = student.id;
         ViewData["student_username"] = student_username;
         return View();
     }
     else
     {
         return View("Error");
     }
 }
Exemplo n.º 2
0
 public ActionResult Index()
 {
     if (Request.Params["student_id"] != null)
     {
         string student_username=Request.Params["student_id"];
         Student student;
         if (DocumentorDB.Students.Where(a => a.username.Equals(student_username)).Count() > 0)
         {
             student= DocumentorDB.Students.Where(a => a.username.Equals(student_username)).First();
         }
         else
         {
             Student new_student = new Student();
             Employee employee=ElearningDB.Employees.Where(a=>a.UserLoginName.Equals(student_username)).First();
             new_student.username = employee.UserLoginName;
             new_student.emp_id = employee.EmpId;
             new_student.time_spend = 0;
             new_student.person_id = employee.PERSON_ID;
             new_student.first_visit = DateTime.Now;
             DocumentorDB.Students.InsertOnSubmit(new_student);
             DocumentorDB.SubmitChanges();
             student = DocumentorDB.Students.Where(a => a.username.Equals(student_username)).First();
             student.create_progress_tracker();
         }
         Employee emp = ElearningDB.Employees.Where(e => e.UserLoginName.Equals(student_username)).First();
         Session["student_id"] = emp.FirstName+" "+emp.LastName;
         if (student.Assignments.Where(a => a.iscomplete.Equals(false) && (int)a.time_spend < a.CaseStudy.duration).Count() > 0)
         {
             int case_study_id=student.Assignments.Where(a => a.iscomplete!=true).First().case_study_id;
             return RedirectToAction("GoToTest", "Test", new { student_id = student.id, case_study_id = case_study_id });
         }
         else
         {
             ViewData["modules"] = DocumentorDB.Modules.ToList();
             List<bool> module_status = new List<bool>();
             List<Module> modules = DocumentorDB.Modules.ToList();
             List<UserModuleTimeStatistic> user_time_stats = DocumentorDB.UserModuleTimeStatistics.Where(a => a.student_id.Equals(student.id)).ToList();
             List<UserProgress> user_progress = DocumentorDB.UserProgresses.Where(a => a.student_id.Equals(student.id)).ToList();
             int first_module_id = modules.First().id;
             int selected_module_id = modules.First().id;
             foreach (Module module in modules.OrderBy(a => a.id))
             {
                 bool module_time_complete = user_time_stats.Where(a => a.module_id.Equals(module.id)).First().time_spend >= module.time_allocated;
                 bool module_sections_complete = user_progress.Where(a => a.module_id.Equals(module.id) && (a.isComplete == false || a.isComplete == null)).Count() == 0&&user_progress.Where(a => a.module_id.Equals(module.id)).Count()>0;
                 if (module_sections_complete || module_time_complete)
                     if (modules.Where(a => a.id > module.id).OrderBy(a => a.id).Count() > 0)
                         selected_module_id = modules.Where(a => a.id > module.id).OrderBy(a => a.id).First().id;
                     else
                         selected_module_id = module.id;
             }
             ViewData["selected_module_id"] = selected_module_id;
             ViewData["selected_module_index"] = Array.IndexOf(modules.Select(m => m.id).OrderBy(m => m).ToArray(), selected_module_id) + 1;
             ViewData["first_module_id"] = first_module_id;
             ViewData["student_id"] = student.id;
             ViewData["student_username"] = student_username;
             return View();
         }
     }
     else
     {
         return View("Error");
     }
 }
Exemplo n.º 3
0
        public void SendMailToStudent(Student student)
        {
            Employee employee = EmpDB.Employees.Where(e=>e.UserLoginName.Equals(student.username)||e.PERSON_ID.Equals(student.person_id)||e.EmpId.Equals(student.emp_id)).First();
            var fromAddress = new MailAddress("*****@*****.**", "LMS-ADMIN");
            var toAddress = new MailAddress(employee.Email, employee.FirstName+" "+employee.LastName);
            const string fromPassword = "******";
            const string subject = "Checking system generated mail subject";
            const string body = "Checking system generated mail body";

            var smtp = new SmtpClient
            {
                Host = "mail.ptotem.com",
                Port = 26,
                EnableSsl = false,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
            };
            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }
        }
 partial void DeleteStudent(Student instance);
 partial void UpdateStudent(Student instance);
 partial void InsertStudent(Student instance);