コード例 #1
0
    def create_course(self, courseid, init_content):
        """
        :param courseid: the course id of the course
        :param init_content: initial descriptor content
        :raise InvalidNameException or CourseAlreadyExistsException
        Create a new course folder and set initial descriptor content, folder can already exist
        """
        if not id_checker(courseid):
            raise InvalidNameException("Course with invalid name: " + courseid)

        course_fs = self.get_course_fs(courseid)
        course_fs.ensure_exists()

        if course_fs.exists("course.yaml") or course_fs.exists("course.json"):
            raise CourseAlreadyExistsException("Course with id " + courseid +
                                               " already exists.")
        else:
            course_fs.put("course.yaml",
                          get_json_or_yaml("course.yaml", init_content))

        get_course_logger(courseid).info("Course %s created in the factory.",
                                         courseid)
        self._hook_manager.call_hook('course_created',
                                     courseid=courseid,
                                     new_content=init_content)
コード例 #2
0
 def update_course_descriptor_content(self, courseid, content):
     """
     Updates the content of the dict that describes the course
     :param courseid: the course id of the course
     :param content: the new dict that replaces the old content
     :raise InvalidNameException, CourseNotFoundException
     """
     path = self._get_course_descriptor_path(courseid)
     self._filesystem.put(path, get_json_or_yaml(path, content))
コード例 #3
0
ファイル: course_factory.py プロジェクト: UCL-INGI/INGInious
 def update_course_descriptor_content(self, courseid, content):
     """
     Updates the content of the dict that describes the course
     :param courseid: the course id of the course
     :param content: the new dict that replaces the old content
     :raise InvalidNameException, CourseNotFoundException
     """
     path = self._get_course_descriptor_path(courseid)
     self._filesystem.put(path, get_json_or_yaml(path, content))
コード例 #4
0
 def update_template_descriptor_content(self, templateid, content):
     """
     Updates the content of the file that describes the template
     :param templateid: the id of the template
     :param content: the new content that replaces the old one
     :raise InvalidNameException, CourseNotFoundException
     """
     path = self._get_template_descriptor_path(templateid)
     self._filesystem.put(path, get_json_or_yaml(path, content))
コード例 #5
0
ファイル: webapp_course.py プロジェクト: bensim602/INGInious
def update_toc_content(course_factory, courseid, content):
    """
    Updates the content of the structure that describes the course
    :param course_factory: the course factory
    :param courseid: the course id of the course
    :param content: the new structure that replaces the old content
    :raise InvalidNameException, CourseNotFoundException
    """
    if not id_checker(courseid):
        raise InvalidNameException("Course with invalid name: " + courseid)

    get_sections_ids_and_make_unique(content)

    course_factory.get_course_fs(courseid).put(
        "toc.yaml", get_json_or_yaml("toc.yaml", content))
コード例 #6
0
ファイル: course_factory.py プロジェクト: UCL-INGI/INGInious
    def create_course(self, courseid, init_content):
        """
        :param courseid: the course id of the course
        :param init_content: initial descriptor content
        :raise InvalidNameException or CourseAlreadyExistsException
        Create a new course folder and set initial descriptor content, folder can already exist
        """
        if not id_checker(courseid):
            raise InvalidNameException("Course with invalid name: " + courseid)

        course_fs = self.get_course_fs(courseid)
        course_fs.ensure_exists()

        if course_fs.exists("course.yaml") or course_fs.exists("course.json"):
            raise CourseAlreadyExistsException("Course with id " + courseid + " already exists.")
        else:
            course_fs.put("course.yaml", get_json_or_yaml("course.yaml", init_content))

        get_course_logger(courseid).info("Course %s created in the factory.", courseid)
コード例 #7
0
 def create_course(self, templateid, init_content, init_description=None):
     """
     :param init_description: initial template descriptor content
     :param templateid: the course id of the course
     :param init_content: initial descriptor content
     :param init_description: initial description of the template
     :raise InvalidNameException or CourseAlreadyExistsException
     Create a new course folder and set initial descriptor content, folder can already exist
     Set initial template description
     """
     super().create_course(templateid, init_content)
     template_fs = self.get_course_fs(templateid)
     if template_fs.exists("template.yaml"):
         raise CourseAlreadyExistsException("Template with id " +
                                            templateid + " already exists.")
     else:
         template_fs.put(
             "template.yaml",
             get_json_or_yaml("template.yaml", init_description))
コード例 #8
0
ファイル: task_factory.py プロジェクト: pchaow/INGInious
    def create_task(self, course, taskid, init_content):
        """ Create a new course folder and set initial descriptor content, folder can already exist
        :param course: a Course object
        :param taskid: the task id of the task
        :param init_content: initial descriptor content
        :raise: InvalidNameException or TaskAlreadyExistsException
        """
        if not id_checker(taskid):
            raise InvalidNameException("Task with invalid name: " + taskid)

        task_fs = self.get_task_fs(course.get_id(), taskid)
        task_fs.ensure_exists()

        if task_fs.exists("task.yaml"):
            raise TaskAlreadyExistsException("Task with id " + taskid + " already exists.")
        else:
            task_fs.put("task.yaml", get_json_or_yaml("task.yaml", init_content))

        get_course_logger(course.get_id()).info("Task %s created in the factory.", taskid)