Exemple #1
0
        public static IudicoCourseInfo Parse(Course course, ICourseStorage storage)
        {
            int id = course.Id;
            IudicoCourseInfo ci = new IudicoCourseInfo();
            ci.Id = id;

            var nodes = storage.GetNodes(id).ToList();

            for (var i = 0; i < nodes.Count; i++)
            {
                if (nodes[i].IsFolder == false)
                {
                    try
                    {
                        ci.NodesInfo.Add(ParseNode(nodes[i], storage));
                    }
                    catch
                    {
                        
                    }
                }
                else
                {
                    var subNodes = storage.GetNodes(id, nodes[i].Id);
                    nodes.AddRange(subNodes);
                }
            }

            return ci;
        }
Exemple #2
0
      public static void GenerateAllCourses(ICourseStorage courseStorage, ICacheProvider cacheProvider)
      {

         var path = (new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;
         path = path.Replace("IUDICO.LMS/Plugins/IUDICO.DataGenerator.DLL", "IUDICO.DataGenerator/Content/Courses/");

         if (Directory.Exists(path))
         {
            var files = Directory.GetFiles(path, "*.zip",SearchOption.TopDirectoryOnly);

            foreach (var file in files)
            {
               var name = Path.GetFileNameWithoutExtension(file);

               if (!courseStorage.GetCourses().Any(c => c.Name == name && c.Owner == "prof3"))
               {
                  courseStorage.Import(file, "prof3");
                  Course course = courseStorage.GetCourses().SingleOrDefault(c => c.Name == name && c.Owner == "prof3");
                  if (course != null && course.Locked.Value)
                  {
                     courseStorage.Parse(course.Id);
                     cacheProvider.Invalidate("course-" + course.Id, "courses");
                  }
               }
            }
         }
      }
Exemple #3
0
 public Importer(Manifest manifest, Course course, ICourseStorage courseStorage)
 {
     this.manifest = manifest;
     this.course = course;
     this.courseStorage = courseStorage;
     this.coursePath = this.courseStorage.GetCoursePath(this.course.Id);
     this.courseTempPath = this.courseStorage.GetCourseTempPath(this.course.Id);
 }
Exemple #4
0
 public Importer(Manifest manifest, Course course, ICourseStorage courseStorage)
 {
     _Manifest = manifest;
     _Course = course;
     _CourseStorage = courseStorage;
     _CoursePath = _CourseStorage.GetCoursePath(_Course.Id);
     _CourseTempPath = _CourseStorage.GetCourseTempPath(_Course.Id);
 }
Exemple #5
0
		public static void PascalCourse(ICourseStorage courseStorage, ICacheProvider cacheProvider, string path)
		{
			if (Directory.Exists(path))
			{
				var files = Directory.GetFiles(path,"*.zip");

				foreach (var file in files)
				{
					var name = Path.GetFileNameWithoutExtension(file);

					if (!courseStorage.GetCourses().Any(c => c.Name == name && c.Owner == "OlehVukladachenko"))
					{
						courseStorage.Import(file, "OlehVukladachenko");
					}

					Course course = courseStorage.GetCourses().SingleOrDefault(c => c.Name == name && c.Owner == "OlehVukladachenko");
					if (course != null && course.Locked.Value )
					{
						courseStorage.Parse(course.Id);
						cacheProvider.Invalidate("course-" + course.Id, "courses");
					}
				}
			}
		}
Exemple #6
0
 public NodeController(ICourseStorage courseStorage)
 {
     _Storage = courseStorage;
 }
Exemple #7
0
 public CourseService(ICourseStorage courseStorage)
 {
     _CourseStorage = courseStorage;
 }
Exemple #8
0
        private static IudicoNodeInfo ParseNode(Node node, ICourseStorage storage)
        {
            IudicoNodeInfo ni = new IudicoNodeInfo();
            ni.Id = node.Id;
            ni.CourseId = node.CourseId;

            var path = storage.GetNodePath(node.Id) + ".html";
            TextReader reader = File.OpenText(path);
            XmlDocument xmlDoc = FromHtml(reader);

            // find iudico object nodes <object iudico-question="..." ... >
            foreach (XmlElement el in xmlDoc.GetElementsByTagName("object"))
            {
                bool iudicoQuestion = false;
                IudicoQuestionInfo qi = null;

                // check if it is iudico object
                if (el.Attributes["iudico-question"] != null && el.Attributes["iudico-question"].Value == "true")
                {
                    iudicoQuestion = true;
                    switch (el.Attributes["iudico-type"].Value)
                    {
                        case "iudico-simple":
                            qi = new IudicoSimpleQuestion { Type = IudicoQuestionType.IudicoSimple };
                            break;

                        case "iudico-choice":
                            qi = new IudicoChoiceQuestion { Type = IudicoQuestionType.IudicoChoice };
                            break;

                        case "iudico-compile":
                            qi = new IudicoCompiledTest { Type = IudicoQuestionType.IudicoCompile };
                            break;
                    }
                }

                if (iudicoQuestion == true)
                {
                    // <param name="..." value="..." />
                    foreach (XmlNode xmlNode in el.ChildNodes)
                    {
                        if (xmlNode.Attributes["name"] != null && xmlNode.Attributes["name"].Value == "rank")
                        {
                            double score = 0;
                            double.TryParse(xmlNode.Attributes["value"].Value, out score);
                            qi.MaxScore += score;
                        }
                        if (xmlNode.Attributes["name"] != null && xmlNode.Attributes["name"].Value == "question")
                        {
                            qi.QuestionText = xmlNode.Attributes["value"].Value;
                        }

                        switch (qi.Type)
                        {
                            case IudicoQuestionType.IudicoSimple:
                                if (xmlNode.Attributes["name"] != null && xmlNode.Attributes["name"].Value == "correctAnswer")
                                {
                                    (qi as IudicoSimpleQuestion).CorrectAnswer = xmlNode.Attributes["value"].Value;
                                }
                                break;

                            case IudicoQuestionType.IudicoChoice:
                                if (xmlNode.Attributes["name"] != null && xmlNode.Attributes["name"].Value == "correct")
                                {
                                    (qi as IudicoChoiceQuestion).CorrectChoice = xmlNode.Attributes["value"].Value;
                                }
                                if (xmlNode.Attributes["name"] != null && xmlNode.Attributes["name"].Value.StartsWith("option"))
                                {
                                    (qi as IudicoChoiceQuestion).Options.Add(new Tuple<string, string>(xmlNode.Attributes["name"].Value, xmlNode.Attributes["value"].Value));
                                }
                                break;

                            case IudicoQuestionType.IudicoCompile:
                                if (xmlNode.Attributes["name"] != null && xmlNode.Attributes["name"].Value.StartsWith("testInput"))
                                {
                                    (qi as IudicoCompiledTest).TestInputs.Add(new Tuple<string, string>(xmlNode.Attributes["name"].Value, xmlNode.Attributes["value"].Value));
                                }
                                if (xmlNode.Attributes["name"] != null && xmlNode.Attributes["name"].Value.StartsWith("testOutput"))
                                {
                                    (qi as IudicoCompiledTest).TestOutputs.Add(new Tuple<string, string>(xmlNode.Attributes["name"].Value, xmlNode.Attributes["value"].Value));
                                }
                                break;
                        }
                    }
                    ni.QuestionsInfo.Add(qi);
                }
            }

            return ni;
        }
Exemple #9
0
 public CourseController(ICourseStorage courseStorage)
 {
     _Storage     = courseStorage;
     _UserService = LmsService.FindService <IUserService>();
 }
Exemple #10
0
 public CourseController(ICourseStorage courseStorage)
 {
     this.storage     = courseStorage;
     this.userService = LmsService.FindService <IUserService>();
 }
Exemple #11
0
 public CourseService(ICourseStorage courseStorage)
 {
     _CourseStorage = courseStorage;
 }
Exemple #12
0
 public NodeController(ICourseStorage courseStorage)
 {
     this.storage = courseStorage;
 }
Exemple #13
0
 public NodeController(ICourseStorage courseStorage)
 {
     _Storage = courseStorage;
 }
Exemple #14
0
 public CourseController(ICourseStorage courseStorage)
 {
     this.storage = courseStorage;
     this.userService = LmsService.FindService<IUserService>();
 }
Exemple #15
0
 public CourseService(ICourseStorage courseStorage)
 {
     this.courseStorage = courseStorage;
 }
 public CachedCourseStorage(ICourseStorage storage, ICacheProvider cachePrvoider)
 {
     this.storage = storage;
     this.cacheProvider = cachePrvoider;
 }
Exemple #17
0
 public CourseController(ICourseStorage courseStorage)
 {
     _Storage = courseStorage;
     _UserService = LmsService.FindService<IUserService>();
 }
Exemple #18
0
 public CachedCourseStorage(ICourseStorage storage, ICacheProvider cachePrvoider)
 {
     this.storage       = storage;
     this.cacheProvider = cachePrvoider;
 }