module LectureModule; from interacting import all; export all; object Lecture is components: LectureTitle and RenderedHtml and HtmlContent and ToBeRendered and ToBeUpdated and LineNumber and Layer; description: (* A lecture is a title, rendered Html content to be displayed, HTML content from which the rendered HTML was created, a boolean that tracks if any changes have been made to the raw HTML, a boolean that tracks if any changes have been made to the rendered HTML, the location of the cursor in the lecture, and a layer associated with that topic for drawing; *); end Lecture; object LectureTitle is string; object ToBeRendered is boolean; object ToBeUpdated is boolean; object LectureElement is components: Topic or Image or SlideBreak or PlainText or SlideNumber; description: (* A LectureElement is a component of a lecture, it is either a text topic, an image, a slide break or a slide number *); end LectureElement; object Topic is components: LineNumber and string and Topic* or Image* and Expanded and LevelNumber and Visible; description: (* A topic has the text to be displayed, line location where to be displayed on a slide, a collection of its subtopics, a Boolean indicating expansion, level number specifying outline level of this topic and a visible boolean indicating if it is visible *); end Topic; object Expanded is boolean; object LevelNumber is integer; object LineNumber is integer; object Visible is boolean; object Image is components: LineNumber and string and Topic* and Image* and Expanded and LevelNumber and Visible and Dimensions; description: (* An Image has the location of an image to be displayed, line location where to be displayed on a slide, a collection of its subtopics or subimages, a Boolean indicating expansion and level number specifying outline level of this topic *); end Image; object Dimensions is Width and Hight; object Width is integer; object Hight is integer; object SlideBreak is integer; object PlainText is string; object SlideNumber is integer; object HtmlContent is components: HtmlTag* and RawContent*; description: (* HtmlContent is HTML code that meets WC3 standards for HTML. The content is then interpreted into RenderedHtml *); end HtmlContent; object RawContent is string; object RenderedHtml is components: LectureElement*; description: (* RenderedHtml has a collection of LectureElements that are intepreted from an HtmlContent *); end RenderedHtml; object HtmlTag is components: OrderedListTag or UnorderedListTag or ListItemTag or HeaderTag or SlideBreakTag or OtherHtmlTag; end HtmlTag; object OtherHtmlTag description: (* For a complete specification of HTML as published by the W3C organization, visit: http://www.w3.org/MarkUp". *); end OtherHtmlTag; object OrderedListTag is string; object UnorderedListTag is string; object ListItemTag is string; object HeaderTag is string; object SlideBreakTag is string; operation expand is inputs: t: Topic; outputs: t': Topic; (* Expand takes a topic and sets the expanded flag of that topic as well as the visibility of its sub-topics so that they are visible. *) precondition: t.Expanded = false and t.Visible = false; postcondition: t'.Expanded = true and t'.Visible = true; end expand; operation collapse is inputs: t: Topic; outputs: t': Topic; (* Collapse takes a topic and resets the expanded flag of that topic as well as the visibility of its sub-topics so that they are not visible in the lecture *) precondition: t.Expanded = true and t.Visible = true; postcondition: t'.Expanded = false and t'.Visible = false; end collapse; operation renderHtml is inputs: lect: Lecture; outputs: lect': Lecture; (* RenderHtml takes plain HTML code and interprets it into a series of lecture elements in a renderedHtml object that can be interpreted by e-Class as an expandable lecture presentation. *) precondition: lect.ToBeRendered = true; postcondition: (* the lectures renderedHtml should con*) lect'.ToBeRendered = false; end renderHtml; operation updateRawHtml is inputs: lect: Lecture; outputs: lect': Lecture; (* UpdateRawHtml takes a RenderedHtml and interprets it back to raw HTML content. This operation is used to reflect any changes that are made to a renderedHtml file in outline mode *) precondition: lect.ToBeUpdated = true; postcondition: (* because the program is already able to interpret HTML code, going from renderedHtml code back to HTML should be a reverse process *) lect'.ToBeUpdated = false; end updateRawHtml; operation importHtml is inputs: fs: FileSpace, t: ToBeUpdated, fn:FileName; outputs: h': HtmlContent, t': ToBeUpdated; (* importHtml takes an external HTML file with the given filename and imports it into the HtmlContent of a lecture*) precondition: (exists(file in fs) (file.name = fn) and (file.file_type?html_type)); postcondition: (* A new *) t' = true; end importHtml; object FileName is string; object FileSpace; operation insertTopic is inputs: lect: Lecture, t: string; outputs: t': Topic, lect': Lecture; (* insertTopic creates a new topic and inserts it into an existing RenderedHtml object of the input Lecture *) precondition:(* *); postcondition:(* Topic is created and inserted into the RenderedHtml of the lecture and ToBeUpdated is set *) exists(t' in lect'.renderedHtml) (t'.string = t) and (t'.LineNumber = lect.LineNumber); end insertTopic; operation insertSubTopic is inputs: lect: Lecture, top: Topic, t: string; outputs: t':Topic, lect': Lecture; (* insertSubTopic creates a new subtopic and inserts it into an existing RenderedHtml object of the input Lecture *) precondition:(* *); postcondition: (* Topic is created and inserted into the RenderedHtml of the lecture and ToBeUpdated is set *) exists(t' in lect'.renderedHtml)((t'.string = t) and (t'.LineNumber = lect.LineNumber)); end insertSubTopic; operation insertImage is inputs: lect: Lecture, img: string; outputs: t':Topic, lect': Lecture; (* insertImage creates a new Image and inserts it into an existing RenderedHtml object of the input Lecture. An image is like a topic, but the text is the location of the image to be displayed *) precondition:(* *); postcondition:(* *) exists(t' in lect'.renderedHtml)((t'.string = img) and (t'.LineNumber = lect.LineNumber)); end insertImage; end LectureModule;