Exemple #1
0
    def render(self):
        self.head.render() #Render course
        for data in self.page_annexe: #Render annexe
            jinja(
                os.path.join(data["output_path"],"index.html"),
                "specific_page.html",
                False,
                title=data["title"],
                mooc=self,
                content=data["content"],
                rooturl="../../"
            )

        if self.wiki:
            annexe.render_wiki(self)
        if self.forum_category:
            annexe.render_forum(self)
        if len(self.book_list_list) != 0:
            annexe.render_booknav(self)
        if not self.no_homepage:
            jinja( #Render home page
                os.path.join(self.output_path,"index.html"),
                "home.html",
                False,
                messages=self.html_homepage,
                mooc=self,
                render_homepage=True
            )
        copy_tree(os.path.join(os.path.abspath(os.path.dirname(__file__)) ,'static'), os.path.join(self.output_path, 'static'))
Exemple #2
0
def render_forum(mooc):
    threads=mooc.forum_thread
    staff_user=mooc.staff_user_forum
    forum_output=os.path.join(mooc.output_path, "forum")
    category=mooc.forum_category

    thread_by_category=defaultdict(list)
    for thread in threads: 
        thread_by_category[thread["commentable_id"]].append(thread)
    jinja(
            os.path.join(forum_output,"index.html"),
            "forum.html",
            False,
            category=category,
            thread_by_category=thread_by_category,
            staff_user=staff_user,
            mooc=mooc,
            rooturl="../",
            display_on_mobile=True
    )
    for thread in threads:
        jinja(
                os.path.join(forum_output,thread["id"],"index.html"),
                "forum.html",
                False,
                thread=thread["data_thread"]["content"],
                category=category,
                thread_by_category=thread_by_category,
		staff_user=staff_user,
                mooc=mooc,
                rooturl="../../../",
                forum_menu=True
        )
Exemple #3
0
def render_wiki(mooc):
    wiki_data=mooc.wiki
    wiki_name=mooc.wiki_name
    for page in wiki_data:
        if "text" in wiki_data[page]: #this is a page
            jinja(
                os.path.join(wiki_data[page]["path"],"index.html"),
                "wiki_page.html",
                False,
                content=wiki_data[page],
                dir=wiki_data[page]["dir"].replace(mooc.instance_url + "/wiki/","") + "index.html",
                mooc=mooc,
                rooturl=wiki_data[page]["rooturl"]
            )
    
        make_dir(os.path.join(wiki_data[page]["path"],"_dir"))
        if len(wiki_data[page]["children"]) != 0: #this is a list page
            page_to_list=[]
            for child_page in wiki_data[page]["children"]:
                if "title" in wiki_data[child_page]:
                    page_to_list.append({ "url": wiki_data[page]["rooturl"]+ "/.." + child_page.replace(mooc.instance_url,""), "title": wiki_data[child_page]["title"], "last-modif": wiki_data[child_page]["last-modif"]})
            jinja(
                os.path.join(wiki_data[page]["path"],"_dir","index.html"),
                "wiki_list.html",
                False,
                pages=page_to_list,
                wiki_name=wiki_name,
                mooc=mooc,
                rooturl=wiki_data[page]["rooturl"] + "../"
            )
Exemple #4
0
def render_booknav(mooc):
    for book_nav in mooc.book_list_list:
        jinja(
          os.path.join(book_nav["output_path"], "index.html"),
	  "booknav.html",
	  False,
	  book_list=book_nav["book_list"],
          dir_path=book_nav["dir_path"],
	  mooc=mooc,
	  rooturl="../../../"
        )
Exemple #5
0
 def render(self):
     return jinja(None,
                  "video.html",
                  False,
                  format="webm" if self.mooc.convert_in_webm else "mp4",
                  folder_name=self.folder_name,
                  title=self.json["display_name"],
                  subs=self.subs)
Exemple #6
0
 def render(self, pred_vertical, next_vertical, chapter, sequential):
     vertical = []
     video = False
     for x in self.descendants:
         vertical.append(x.render())
     jinja(os.path.join(self.output_path, self.path, "index.html"),
           "vertical.html",
           False,
           rooturl=self.rooturl,
           mooc=self.mooc,
           chapter=chapter,
           sequential=sequential,
           vertical=self,
           extracted_id=self.json["id"].split("@")[-1],
           vertical_content=vertical,
           pred_vertical=pred_vertical,
           next_vertical=next_vertical,
           side_menu=True)
Exemple #7
0
    def render(self):
        for x in range(0,len(self.descendants)):
            if x==0:
                pred_info=None
            else:
                pred_info=self.descendants[x-1].get_last()
            if x+1==len(self.descendants):
                next_info=None
            else:
                next_info=self.descendants[x+1].get_first()
            self.descendants[x].render(pred_info,next_info)
        if len(self.descendants) == 0:
            logging.warning("This course has no content")
        else:
            jinja(
                os.path.join(self.output_path,self.path,"index.html"),
                "course_menu.html",
                False,
                course=self,
                rooturl=self.rooturl,
                mooc=self.mooc,
		all_side_menu_open=True,
                display_on_mobile=True
            )
Exemple #8
0
 def render(self):
     if self.category_title != "":
         return jinja(
             None,
             "discussion.html",
             False,
             category_title=self.category_title,
             threads=self.data,
             discussion=self,
             staff_user=self.mooc.staff_user_forum,
             rooturl="/".join(
                 self.rooturl.split("/")[:-1])  #rooturl - 1 folder
         )
     else:
         return "This discussion is not supported, sorry !"
Exemple #9
0
 def render(self):
     return jinja(None, "problem.html", False, problem=self)
 def render(self):
     return jinja(None,
                  "freetextresponse.html",
                  False,
                  freetextresponse=self,
                  mooc=self.mooc)
Exemple #11
0
 def render(self):
     return jinja(None, "DragAndDropV2.html", False, DragDrop=self)