Exemplo n.º 1
0
        /*
         *   NAME
         *
         *        IO::Students_To_File - Exports students to individual files
         *
         *   SYNOPSIS
         *
         *        void Students_To_File (List<Student> students);
         *
         *             students       --> a list of student objects to be exported.
         *
         *   DESCRIPTION
         *
         *        This function takes each student and saves their data to a unique file.
         */
        //https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-write-to-a-text-file
        public static void Students_To_File(List <Student> students)
        {
            try
            {
                string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\HomeroomHelper\";
                foreach (Student s in students)
                {
                    string filename = path + s.FirstName + s.LastName + Generate_File_Date() + ".csv";

                    string line = "";
                    line += s.ID + ",";
                    line += s.FirstName + ",";
                    line += s.LastName + ",";
                    line += s.StartLevel + ",";
                    line += s.CurrentLevel + ",";
                    line += s.GoalLevel + Environment.NewLine;

                    System.IO.File.WriteAllText(filename, line);

                    List <Note> notes = Database_Interface.Query_Note(s.ID);
                    foreach (Note n in notes)
                    {
                        string note_line = "note,";
                        note_line += n.id + ",";
                        note_line += n.student_id + ",";
                        note_line += n.date + ",";
                        note_line += n.note + ",";
                        note_line += n.category + Environment.NewLine;

                        System.IO.File.AppendAllText(filename, note_line);
                    }

                    List <History_Entry> entries = Database_Interface.Query_History_Entries(s.ID);
                    foreach (History_Entry h in entries)
                    {
                        string entry_line = "entry,";
                        entry_line += h.id + ",";
                        entry_line += h.student_id + ",";
                        entry_line += h.date + ",";
                        entry_line += h.current_lvl + Environment.NewLine;

                        System.IO.File.AppendAllText(filename, entry_line);
                    }
                }
            }
            catch (Exception e)
            {
                new Log(e, "IO.cs: Students_To_File", "Failed to save student data to file.");
            }
        }
Exemplo n.º 2
0
        /*
         * NAME
         *
         *      Analytics_Form::Instantiate_Line_Graph - instantiates the line graph for a student.
         *
         * SYNOPSIS
         *
         *     void Analytics_Form::Instantiate_Line_Graph(int id);
         *
         *          id             --> the id of the selected student.
         *
         * DESCRIPTION
         *
         *      This function retrieves the historical data using the student's id,
         *      and displays it in a line graph using a chart object.
         */
        private void Instantiate_Line_Graph(int id)
        {
            Lvl_History_Chart.Series.Clear();
            Lvl_History_Chart.Series.Add("Reading Levels");
            Lvl_History_Chart.Series["Reading Levels"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            //Lvl_History_Chart.ChartAreas.Add("Reading Levels");

            List <History_Entry> entries = new List <History_Entry>();

            entries = Database_Interface.Query_History_Entries(id);    //all entries for that student



            foreach (History_Entry he in entries)
            {
                Lvl_History_Chart.Series["Reading Levels"].Points.AddXY(he.date, (int)he.current_lvl);
            }

            Lvl_History_Chart.DataBind();
        }