(*
 *
 * This file defines operations related to Creating a Question Functionality.  
 *
 *)


module QuestionCreateFunctionality;

    from Questions import all;
    from Database import all;
    export all;

    object TextBlank is
        components: string;
        description: (*
            String reference of the text blank in the code.
        *);
    end TextBlank;

    object ImageFile is
        components: string;
        description: (*
            String reference of the image file in the code.
        *);
    end ImageFile;

    object TextFile is
        components: string;
        description: (*
            String of content read from the file.
        *);
    end TextFile; 

    operation CreateQuestion 
        inputs: Question;
        outputs: Question;
        description: (*
            CreateQuestion creates the basic properties of the question that are 
            shared between all different types.
        *);
    end CreateQuestion;

    operation ImportBlank
        inputs: Question, TextBlank;
        outputs: Question;
        description: (*
            ImportBlank imports a psudo-code blank into the question text
            of the question that will show in the presented question.
        *);
    end ImportBlank;

    operation ImportImage
        inputs: Question, ImageFile;
        outputs: Question;
        description: (*
            ImportImage imports a psudo-code image into the question text
            of the question that will show in the presented question.
        *);
    end ImportImage;

    operation CreateMultChoice 
        inputs: Question, Answer;
        outputs: MultipleChoice;
        description: (*
            Takes the generic question and adds the rest of the information
            to it to make it a multiple choice question.
        *);
    end CreateMultChoice;
 
    operation CreateTrueFalse 
        inputs: Question, TrueOrFalse;
        outputs: TrueFalse;
        description: (*
            Takes the generic question and adds the rest of the information
            to it to make it a true/false question.
        *);
    end CreateTrueFalse;

    operation CreateCoding
        inputs: Question, CodeOutput, ProgramText;
        outputs: Coding;
        description: (*
            Takes the generic question and adds the rest of the information
            to it to make it a coding question.
        *);
    end CreateCoding;

    operation ImportFile
        inputs: Coding, TextFile;
        outputs: Coding;
        description: (*
            From CreateCoding, selects a file to import programing text from
        *);
    end ImportFile;

    operation CreateEssay
        inputs: Question, Keyword;
        description: (*
            Takes the generic question and adds the rest of the information
            to it to make it an essay question.
        *);
    end CreateEssay;

    operation CreateFillInTheBlank
        inputs: Question, Answer;
        outputs: FillInTheBlank;
        description: (*
            Takes the generic question and adds the rest of the information
            to it to make it a fill in the blank question.
        *);
    end CreateFillInTheBlank;

    operation CreateMatching
        inputs: Question, Bank, Bank;
        outputs: Matching;
        description: (*
            Takes the generic question and adds the rest of the information
            to it to make it a matching question.
        *);
    end CreateMatching;

    operation PreviewConfirm
        inputs: q:Question, ldb:LocalDatabase;
        outputs: ldb':LocalDatabase;
        precondition: (*All question properties specified*);
        postcondition: (*Question is added to the LocalDatabase*)
                       q in ldb';
        description: (*
            Takes the generic question and adds the rest of the information
            to it to make it a matching question.
        *);
    end PreviewConfirm;

end QuestionCreateFunctionality;