public int AddLogItem(DBClassesDataContext dbc, CompletionLog compLog) { // is there a record of this user performing this lesson ? bool bFound = false; foreach (LessonLogItem lli in mLog) { if (lli.StudentID == compLog.Student && lli.LessonID == compLog.LESSONID) { bFound = true; break; } } if (!bFound) { LessonLogItem log = new LessonLogItem(); log.DoneOn = compLog.DateCompleted; log.InstructorID = compLog.Instructor; log.InstructorName = AppUser.getUser(compLog.Instructor).GetFullName(); log.StudentID = compLog.Student; log.StudentName = AppUser.getUser(compLog.Student).GetFullName(); log.LessonID = compLog.LESSONID; log.LessonName = LESSON.GetLesson(dbc, compLog.LESSONID).Title; log.StageID = compLog.STAGEID; log.StageName = STAGE.GetStage(dbc, compLog.STAGEID).Name; // Update flight hours for this lesson for this student log.UpdateFlightHours(dbc); mLog.Add(log); } return(mLog.Count); }
public void LoadStages(string optionalStudent) { DBClassesDataContext dbc = new DBClassesDataContext(); IEnumerable <STAGE> lst = from s in dbc.STAGEs where s.CertificationID == CertificationID select s; mStages = new List <STAGE>(); foreach (STAGE l in lst) { mStages.Add(l); } IsComplete = true; foreach (STAGE stg in mStages) { stg.LoadLessons(dbc); // if student is specified, load his completion status if (!String.IsNullOrEmpty(optionalStudent)) { IEnumerable <CompletionLog> log = CompletionLog.LoadStudentLog(dbc, optionalStudent); List <CompletionLog> logcopy = new List <CompletionLog>(); foreach (CompletionLog l in log) { logcopy.Add(l); } IEnumerable <LessonTimeLog> timelog = LessonTimeLog.LoadStudentLog(dbc, optionalStudent); List <LessonTimeLog> timelogcopy = new List <LessonTimeLog>(); foreach (LessonTimeLog l in timelog) { timelogcopy.Add(l); } stg.LoadStudentStatus(timelogcopy, logcopy, optionalStudent); } if (stg.IsAllStarted) { IsStarted = true; } if (!stg.IsAllComplete) { IsComplete = false; } } }
/** * See if there is a completion record for this student */ public void LoadStudentStatus(IEnumerable <CompletionLog> loglist, string studentID) { CompletionLog log = null; // look in the list for the log for this lessonguid. foreach (CompletionLog l in loglist) { if (l.LessonGUID == LESSONGUID) { log = l; break; } } if (log == null) { IsComplete = false; return; } // load the completion details IsComplete = true; CompletedOn = log.DateCompleted; Instructor = log.Instructor; }