Ejemplo n.º 1
0
        }//end of getStudentsList
        //Aurelio Arango
        //4-6-14
        //This method generates the problems sets into xml
        public void generate_StudentXMLProblemSet( ProblemSet set)
        {
            XmlDocument doc;
            List<int> problems= new List<int>();
            if (!File.Exists(@"c:\users\public\MathDrills\ProblemSets\setGroup" + set.group + ".xml"))
            {
                doc = new XmlDocument();
                XmlElement allProblemSets = doc.CreateElement("AllProblemSets");
                doc.AppendChild(allProblemSets);
                doc.Save(@"c:\users\public\MathDrills\ProblemSets\setGroup" + set.group + ".xml");
            }

            XDocument xml = XDocument.Load(@"c:\users\public\MathDrills\ProblemSets\setGroup" + set.group + ".xml");
            XElement newProblemSet = new XElement("ProblemSet");
            XElement problemSetID = new XElement("ProblemSetID", Program.getNextProblemSetID());
            XElement problemSetSolved = new XElement("IsSetSolved", "0");
            XElement availableUntil = new XElement("AvailableUntil", set.dueDate);

            newProblemSet.Add(problemSetID);
            newProblemSet.Add(problemSetSolved);
            newProblemSet.Add(availableUntil);
            
            for(int i=0; i<set.problems.Count; i++)
            {
                XElement newProblem = new XElement("Problem",
                    new XElement("Operator" , set.problems[i].operation),
                    new XElement("Operand1", set.problems[i].operand1.ToString()),
                    new XElement("Operand2", set.problems[i].operand2.ToString()),
                    new XElement("IsSolved", "0"),
                    new XElement("Attempts", "0")
                    );

                    //newProblemSet.Add(operation);
                    
                    newProblemSet.Add(newProblem);

            }
            xml.Root.Add(newProblemSet);
            xml.Save(@"c:\users\public\MathDrills\ProblemSets\setGroup" + set.group + ".xml");

        }
Ejemplo n.º 2
0
        //Aurelio Arango and Stephanie Yao, 4-8-14
        /*  NOTE: Heavy code reference from load_users(...)         */
        public List<ProblemSet> load_ProblemSet(string group)
        {
            List<ProblemSet> problemSets = new List<ProblemSet>();
            XElement problemSetsXML = XElement.Load(@"c:\users\public\MathDrills\ProblemSets\setGroup" + group + ".xml");
            int index = 0;
            if (File.Exists(@"c:\users\public\MathDrills\ProblemSets\setGroup" + group + ".xml"))
                foreach (XElement set in problemSetsXML.Descendants("ProblemSet"))
            {
                string problemsetId = set.Element("ProblemSetID").Value;
                string dueDate = set.Element("AvailableUntil").Value;
                List<Problem> problems = load_Problem(set);
                //List<Student> studentList = getStudentList(user);
                //Teacher tempTeacher = new Teacher(newName, userID, studentList, pass);
                
                int psI = Convert.ToInt32(problemsetId);
                //string problem_set_id, string operation, bool isSolved, int solvedQuant, int totalQuant, string score, string last attempt, string group, int min, int max
                ProblemSet prob_set = new ProblemSet(psI, problems[0].operation, false, 0, problems.Count, "0", dueDate, group, 0, 0);

                //Debug.WriteLine(" handler op1" + problems[index].operand1 + " handler op2" + problems[index].operand2);   
                 //Debug.Write("Problems Count: " + problems.Count);
                //problemSets[index].problems = problems;
                 prob_set.problems = problems; 
                problemSets.Add(prob_set);
                
                index++;
            }
            return problemSets;
        }
Ejemplo n.º 3
0
 //Aurelio Arango
 //Save all the problems into xml
 public static void saveProblemSet(ProblemSet set)
 {
     xml.generate_StudentXMLProblemSet(set);
 }