Beispiel #1
0
        public void LoadProblemFromDatabase(string pathName)
        {
            OleDbConnection dbConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathName);

            dbConnection.Open();

            OleDbCommand dbCommand = dbConnection.CreateCommand();

            dbCommand.CommandText = "select * from Pitanje";

            OleDbDataReader dbReader = dbCommand.ExecuteReader();

            while (dbReader.Read())
            {
                int idPitanja  = (int)dbReader.GetValue(1);
                int idPredmeta = (int)dbReader.GetValue(2);
                ProgrammingProblem newProblem = new ProgrammingProblem();
                newProblem.ProblemID = Convert.ToString(idPredmeta) + " - " + Convert.ToString(idPitanja);

                OleDbCommand solCommand = dbConnection.CreateCommand();
                solCommand.CommandText = "select * from StudentskoRjesenje WHERE IDPitanja = " + Convert.ToString(idPitanja) + " AND IDPredmeta = " + Convert.ToString(idPredmeta);

                OleDbDataReader solReader = solCommand.ExecuteReader();

                while (solReader.Read())
                {
                    newProblem.addStudentSolution(solReader.GetValue(7).ToString(), solReader.GetValue(1).ToString());
                }

                _listLoadedProblems.Add(newProblem);
            }



            // uèitavamo sve fajlove

            /*DirectoryInfo di = new DirectoryInfo(pathName);
             * FileInfo[] rgFiles = di.GetFiles("*.txt");
             *
             * foreach (FileInfo fi in rgFiles)
             * {
             *      newProblem.addStudentSolution(fi);
             * }
             *
             * _listLoadedProblems.Add(newProblem);*/

            dbConnection.Close();
        }
Beispiel #2
0
        public void LoadProblemFromDirectory(string pathName, string problemID)
        {
            ProgrammingProblem newProblem = new ProgrammingProblem();

            newProblem.ProblemID = problemID;

            // uèitavamo sve fajlove
            DirectoryInfo di = new DirectoryInfo(pathName);

            FileInfo[] rgFiles = di.GetFiles("*.txt");

            foreach (FileInfo fi in rgFiles)
            {
                newProblem.addStudentSolution(fi);
            }

            _listLoadedProblems.Add(newProblem);
        }