Documentation
¶
Overview ¶
Package editor provides functionnality for a frontend to edit and preview math questions.
Index ¶
- func LoadQuestionVariants(db ed.DB, id ed.IdQuestiongroup) ([]ed.Question, error)
- func ValidateAllQuestions(db ed.DB) error
- type ChapterItems
- type CheckExerciceParametersIn
- type CheckExerciceParametersOut
- type CheckQuestionParametersIn
- type CheckQuestionParametersOut
- type Controller
- func (ct *Controller) EditorCheckExerciceParameters(c echo.Context) error
- func (ct *Controller) EditorCheckQuestionParameters(c echo.Context) error
- func (ct *Controller) EditorCreateExercice(c echo.Context) error
- func (ct *Controller) EditorCreateQuestiongroup(c echo.Context) error
- func (ct *Controller) EditorDeleteExercice(c echo.Context) error
- func (ct *Controller) EditorDeleteExercicegroup(c echo.Context) error
- func (ct *Controller) EditorDeleteQuestion(c echo.Context) error
- func (ct *Controller) EditorDeleteQuestiongroup(c echo.Context) error
- func (ct *Controller) EditorDuplicateExercice(c echo.Context) error
- func (ct *Controller) EditorDuplicateExercicegroup(c echo.Context) error
- func (ct *Controller) EditorDuplicateQuestion(c echo.Context) error
- func (ct *Controller) EditorDuplicateQuestiongroup(c echo.Context) error
- func (ct *Controller) EditorExerciceCreateQuestion(c echo.Context) error
- func (ct *Controller) EditorExerciceDuplicateQuestion(c echo.Context) error
- func (ct *Controller) EditorExerciceExportLateX(c echo.Context) error
- func (ct *Controller) EditorExerciceImportQuestion(c echo.Context) error
- func (ct *Controller) EditorExerciceUpdateQuestions(c echo.Context) error
- func (ct *Controller) EditorGenerateSyntaxHint(c echo.Context) error
- func (ct *Controller) EditorGetExerciceContent(c echo.Context) error
- func (ct *Controller) EditorGetExercicesIndex(c echo.Context) error
- func (ct *Controller) EditorGetQuestions(c echo.Context) error
- func (ct *Controller) EditorGetQuestionsIndex(c echo.Context) error
- func (ct *Controller) EditorGetTags(c echo.Context) error
- func (ct *Controller) EditorQuestionExportLateX(c echo.Context) error
- func (ct *Controller) EditorSaveExerciceAndPreview(c echo.Context) error
- func (ct *Controller) EditorSaveExerciceMeta(c echo.Context) error
- func (ct *Controller) EditorSaveQuestionAndPreview(c echo.Context) error
- func (ct *Controller) EditorSaveQuestionMeta(c echo.Context) error
- func (ct *Controller) EditorSearchExercices(c echo.Context) error
- func (ct *Controller) EditorSearchQuestions(c echo.Context) error
- func (ct *Controller) EditorUpdateExerciceTags(c echo.Context) error
- func (ct *Controller) EditorUpdateExercicegroup(c echo.Context) error
- func (ct *Controller) EditorUpdateExercicegroupVis(c echo.Context) error
- func (ct *Controller) EditorUpdateQuestionTags(c echo.Context) error
- func (ct *Controller) EditorUpdateQuestiongroup(c echo.Context) error
- func (ct *Controller) EditorUpdateQuestiongroupVis(c echo.Context) error
- func (ct *Controller) LoopackEvaluateQuestion(c echo.Context) error
- func (ct *Controller) LoopbackShowQuestionAnswer(c echo.Context) error
- type DeleteExerciceOut
- type DeleteQuestionOut
- type ExerciceCreateQuestionIn
- type ExerciceDuplicateQuestionIn
- type ExerciceExt
- type ExerciceHeader
- type ExerciceImportQuestionIn
- type ExerciceQuestionExt
- type ExerciceUpdateIn
- type ExerciceUpdateQuestionsIn
- type ExerciceUpdateVisiblityIn
- type ExerciceWithPreview
- type ExercicegroupExt
- type ExportExerciceLatexIn
- type ExportExerciceLatexOut
- type ExportQuestionLatexOut
- type GenerateSyntaxHintIn
- type Index
- type LevelItems
- type ListExercicesOut
- type ListQuestionsOut
- type OriginKind
- type Query
- type QuestionHeader
- type QuestionOrigin
- type QuestionUpdateVisiblityIn
- type QuestiongroupExt
- type SaveExerciceAndPreviewIn
- type SaveExerciceAndPreviewOut
- type SaveQuestionAndPreviewIn
- type SaveQuestionAndPreviewOut
- type SaveQuestionMetaIn
- type SearchExercicesIn
- type SearchQuestionsIn
- type TagsDB
- type TaskDetails
- type TaskUses
- type UpdateExercicegroupTagsIn
- type UpdateQuestiongroupTagsIn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadQuestionVariants ¶
LoadQuestionVariants returns the question of the group [id], sorted by Id
func ValidateAllQuestions ¶
ValidateAllQuestions fetches all questions from the DB and calls Validate, returning all the errors encountered. It should be used as a maintenance helper when migrating the DB.
Types ¶
type ChapterItems ¶
the question/exercice for one chapter
type CheckExerciceParametersIn ¶
type CheckExerciceParametersIn struct {
IdExercice ed.IdExercice
QuestionParameters []questions.Parameters
}
type CheckExerciceParametersOut ¶
type CheckExerciceParametersOut struct {
ErrDefinition questions.ErrParameters
QuestionIndex int // ignored if ErrDefinition is empty
}
type CheckQuestionParametersIn ¶
type CheckQuestionParametersIn struct {
Parameters questions.Parameters
}
type CheckQuestionParametersOut ¶
type CheckQuestionParametersOut struct {
ErrDefinition questions.ErrParameters
// Variables is the list of the variables defined
// in the parameteres (intrinsics included)
Variables []expression.Variable
}
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the global object responsible to handle incoming requests regarding the editor for questions and exercices
func NewController ¶
func NewController(db *sql.DB, admin teacher.Teacher) *Controller
func (*Controller) EditorCheckExerciceParameters ¶
func (ct *Controller) EditorCheckExerciceParameters(c echo.Context) error
func (*Controller) EditorCheckQuestionParameters ¶
func (ct *Controller) EditorCheckQuestionParameters(c echo.Context) error
func (*Controller) EditorCreateExercice ¶
func (ct *Controller) EditorCreateExercice(c echo.Context) error
EditorCreateExercice creates a new exercice group with one exercice
func (*Controller) EditorCreateQuestiongroup ¶
func (ct *Controller) EditorCreateQuestiongroup(c echo.Context) error
EditorCreateQuestion creates a group with one question.
func (*Controller) EditorDeleteExercice ¶
func (ct *Controller) EditorDeleteExercice(c echo.Context) error
EditorDeleteExercice remove the given exercice, also cleaning up the exercice group if needed. It returns information if the exercice is used in tasks
func (*Controller) EditorDeleteExercicegroup ¶
func (ct *Controller) EditorDeleteExercicegroup(c echo.Context) error
EditorDeleteExercice remove the whole exercice group. It returns information if the exercice is used in tasks
func (*Controller) EditorDeleteQuestion ¶
func (ct *Controller) EditorDeleteQuestion(c echo.Context) error
EditorDeleteQuestion remove the given question, also removing the group if needed. An information is returned if the question is used in monoquestions (tasks)
func (*Controller) EditorDeleteQuestiongroup ¶
func (ct *Controller) EditorDeleteQuestiongroup(c echo.Context) error
EditorDeleteQuestiongroup remove the whole group. An information is returned if the question is used in monoquestions (tasks)
func (*Controller) EditorDuplicateExercice ¶
func (ct *Controller) EditorDuplicateExercice(c echo.Context) error
EditorDuplicateExercice duplicate one variant inside a group.
func (*Controller) EditorDuplicateExercicegroup ¶
func (ct *Controller) EditorDuplicateExercicegroup(c echo.Context) error
EditorDuplicateExercicegroup duplicates the whole group, deep copying every exercice (variant), and assigns it to the current user.
func (*Controller) EditorDuplicateQuestion ¶
func (ct *Controller) EditorDuplicateQuestion(c echo.Context) error
EditorDuplicateQuestion duplicate one variant inside a group.
func (*Controller) EditorDuplicateQuestiongroup ¶
func (ct *Controller) EditorDuplicateQuestiongroup(c echo.Context) error
EditorDuplicateQuestiongroup duplicates the whole group, deep copying every question, and assigns it to the current user.
func (*Controller) EditorExerciceCreateQuestion ¶
func (ct *Controller) EditorExerciceCreateQuestion(c echo.Context) error
EditorExerciceCreateQuestion creates a question and appends it to the given exercice.
func (*Controller) EditorExerciceDuplicateQuestion ¶
func (ct *Controller) EditorExerciceDuplicateQuestion(c echo.Context) error
EditorExerciceDuplicateQuestion duplicate the question at the given index in the given exercice (variant), also updating the preview
func (*Controller) EditorExerciceExportLateX ¶
func (ct *Controller) EditorExerciceExportLateX(c echo.Context) error
EditorExerciceExportLateX instantiate the given exercice and generates a LaTeX version, returning the code as a string
func (*Controller) EditorExerciceImportQuestion ¶
func (ct *Controller) EditorExerciceImportQuestion(c echo.Context) error
EditorExerciceImportQuestion imports an already existing question, making a copy and associating it with the given exercice. It also updates the preview
func (*Controller) EditorExerciceUpdateQuestions ¶
func (ct *Controller) EditorExerciceUpdateQuestions(c echo.Context) error
EditorExerciceUpdateQuestions updates the question links and the preview
func (*Controller) EditorGenerateSyntaxHint ¶
func (ct *Controller) EditorGenerateSyntaxHint(c echo.Context) error
EditorGenerateSyntaxHint generate a TextBlock with hints about the command used in the given expression field
func (*Controller) EditorGetExerciceContent ¶
func (ct *Controller) EditorGetExerciceContent(c echo.Context) error
EditorGetExerciceContent loads the questions associated with the given exercice
func (*Controller) EditorGetExercicesIndex ¶
func (ct *Controller) EditorGetExercicesIndex(c echo.Context) error
func (*Controller) EditorGetQuestions ¶
func (ct *Controller) EditorGetQuestions(c echo.Context) error
EditorGetQuestions returns the questions for the given group
func (*Controller) EditorGetQuestionsIndex ¶
func (ct *Controller) EditorGetQuestionsIndex(c echo.Context) error
func (*Controller) EditorGetTags ¶
func (ct *Controller) EditorGetTags(c echo.Context) error
EditorGetTags return all tags currently used by questions. It also add the special level tags.
func (*Controller) EditorQuestionExportLateX ¶
func (ct *Controller) EditorQuestionExportLateX(c echo.Context) error
EditorQuestionExportLateX instantiate the given question and generates a LaTeX version, returning the code as a string
func (*Controller) EditorSaveExerciceAndPreview ¶
func (ct *Controller) EditorSaveExerciceAndPreview(c echo.Context) error
For non personnal questions, only preview.
func (*Controller) EditorSaveExerciceMeta ¶
func (ct *Controller) EditorSaveExerciceMeta(c echo.Context) error
EditorSaveExerciceMeta update the exercice metadata.
func (*Controller) EditorSaveQuestionAndPreview ¶
func (ct *Controller) EditorSaveQuestionAndPreview(c echo.Context) error
For non personnal questions, only preview.
func (*Controller) EditorSaveQuestionMeta ¶
func (ct *Controller) EditorSaveQuestionMeta(c echo.Context) error
EditorSaveQuestionMeta only save the meta data of the question, not its content.
func (*Controller) EditorSearchExercices ¶
func (ct *Controller) EditorSearchExercices(c echo.Context) error
func (*Controller) EditorSearchQuestions ¶
func (ct *Controller) EditorSearchQuestions(c echo.Context) error
func (*Controller) EditorUpdateExerciceTags ¶
func (ct *Controller) EditorUpdateExerciceTags(c echo.Context) error
func (*Controller) EditorUpdateExercicegroup ¶
func (ct *Controller) EditorUpdateExercicegroup(c echo.Context) error
func (*Controller) EditorUpdateExercicegroupVis ¶
func (ct *Controller) EditorUpdateExercicegroupVis(c echo.Context) error
func (*Controller) EditorUpdateQuestionTags ¶
func (ct *Controller) EditorUpdateQuestionTags(c echo.Context) error
func (*Controller) EditorUpdateQuestiongroup ¶
func (ct *Controller) EditorUpdateQuestiongroup(c echo.Context) error
func (*Controller) EditorUpdateQuestiongroupVis ¶
func (ct *Controller) EditorUpdateQuestiongroupVis(c echo.Context) error
func (*Controller) LoopackEvaluateQuestion ¶
func (ct *Controller) LoopackEvaluateQuestion(c echo.Context) error
LoopackEvaluateQuestion expects a question definition, a set of random variables, an answer, and performs the evaluation.
func (*Controller) LoopbackShowQuestionAnswer ¶
func (ct *Controller) LoopbackShowQuestionAnswer(c echo.Context) error
LoopbackShowQuestionAnswer expects a question, random parameters, and returns the correct answer for these parameters. It is shared between question and exercice loopback preview.
type DeleteExerciceOut ¶
type DeleteQuestionOut ¶
type ExerciceCreateQuestionIn ¶
type ExerciceCreateQuestionIn struct {
IdExercice ed.IdExercice
}
type ExerciceDuplicateQuestionIn ¶
type ExerciceDuplicateQuestionIn struct {
QuestionIndex int
IdExercice ed.IdExercice
}
type ExerciceExt ¶
type ExerciceExt struct {
Exercice ed.Exercice
Questions []ExerciceQuestionExt
}
type ExerciceHeader ¶
type ExerciceHeader struct {
Id ed.IdExercice
Subtitle string
Difficulty ed.DifficultyTag
}
type ExerciceImportQuestionIn ¶
type ExerciceImportQuestionIn struct {
IdQuestion ed.IdQuestion
IdExercice ed.IdExercice
}
type ExerciceQuestionExt ¶
type ExerciceUpdateIn ¶
type ExerciceUpdateIn = ExerciceHeader
type ExerciceUpdateQuestionsIn ¶
type ExerciceUpdateQuestionsIn struct {
Questions ed.ExerciceQuestions
IdExercice ed.IdExercice
}
type ExerciceUpdateVisiblityIn ¶
type ExerciceUpdateVisiblityIn struct {
ID ed.IdExercicegroup
Public bool
}
type ExerciceWithPreview ¶
type ExerciceWithPreview struct {
Ex ExerciceExt
Preview preview.LoopbackShowExercice
}
type ExercicegroupExt ¶
type ExercicegroupExt struct {
Group ed.Exercicegroup
Origin tcAPI.Origin
Tags ed.Tags
Variants []ExerciceHeader
}
func NewExercicegroupExt ¶
func NewExercicegroupExt(group ed.Exercicegroup, variants []ed.Exercice, tags ed.Tags, inReview tcAPI.OptionalIdReview, userID, adminID uID, ) ExercicegroupExt
type ExportExerciceLatexIn ¶
type ExportExerciceLatexIn struct {
Parameters questions.Parameters // shared parameters
Questions []questions.QuestionPage // questions content
}
type ExportExerciceLatexOut ¶
type ExportExerciceLatexOut struct {
Error questions.ErrQuestionInvalid
QuestionIndex int // of the error
IsValid bool
Latex string
}
type ExportQuestionLatexOut ¶
type ExportQuestionLatexOut struct {
Error questions.ErrQuestionInvalid
IsValid bool
Latex string
}
type GenerateSyntaxHintIn ¶
type GenerateSyntaxHintIn struct {
Block questions.ExpressionFieldBlock
QuestionParameters questions.Parameters
}
type LevelItems ¶
type LevelItems struct {
Level ed.LevelTag
Chapters []ChapterItems // sorted by Chapter
}
the question/exercice for one level
type ListExercicesOut ¶
type ListExercicesOut struct {
Groups []ExercicegroupExt
NbExercices int // Number of variants in [Groups]
}
type ListQuestionsOut ¶
type ListQuestionsOut struct {
Groups []QuestiongroupExt
NbQuestions int // Number of variants in [Groups]
}
type Query ¶
type Query struct {
TitleQuery string // empty means all
LevelTags []string // union, empty means all; an empty tag means "with no level"
ChapterTags []string // union, empty means all; an empty tag means "with no chapter"
SubLevelTags []string // union, empty means all
Origin OriginKind
Matiere teacher.MatiereTag
}
type QuestionHeader ¶
type QuestionHeader struct {
Id ed.IdQuestion
Subtitle string
Difficulty ed.DifficultyTag
HasCorrection bool // has the question a non empty [Correction] content
}
QuestionHeader is a summary of the meta data of a question
type QuestionUpdateVisiblityIn ¶
type QuestionUpdateVisiblityIn struct {
ID ed.IdQuestiongroup
Public bool
}
type QuestiongroupExt ¶
type QuestiongroupExt struct {
Group ed.Questiongroup
Origin tcAPI.Origin
Tags ed.Tags
Variants []QuestionHeader
}
QuestiongroupExt adds the question and tags to a QuestionGroup Standalone question are represented by a group of length one.
func NewQuestiongroupExt ¶
func NewQuestiongroupExt(group ed.Questiongroup, variants []ed.Question, tags ed.Tags, inReview tcAPI.OptionalIdReview, userID, adminID uID, ) QuestiongroupExt
type SaveExerciceAndPreviewIn ¶
type SaveExerciceAndPreviewIn struct {
OnlyPreview bool // if true, skip the save part (Parameters and Questions are thus ignored)
IdExercice ed.IdExercice
Parameters questions.Parameters // shared parameters
Questions []ed.Question // questions content
CurrentQuestion int // to update the preview accordingly
// Set the initial view to display the correction,
// instead of the enonce.
ShowCorrection bool
}
type SaveExerciceAndPreviewOut ¶
type SaveExerciceAndPreviewOut struct {
Error questions.ErrQuestionInvalid
// Index of the error, meaningful only if Error is non empty
QuestionIndex int
IsValid bool
Preview preview.LoopbackShowExercice
}
type SaveQuestionAndPreviewIn ¶
type SaveQuestionAndPreviewIn struct {
Id ed.IdQuestion
Page questions.QuestionPage
// Set the initial view to display the correction,
// instead of the enonce.
ShowCorrection bool
}
type SaveQuestionAndPreviewOut ¶
type SaveQuestionAndPreviewOut struct {
Error questions.ErrQuestionInvalid
IsValid bool
Preview preview.LoopbackShowQuestion
}
type SaveQuestionMetaIn ¶
type SearchExercicesIn ¶
type SearchExercicesIn = Query
type SearchQuestionsIn ¶
type SearchQuestionsIn = Query
type TagsDB ¶
type TaskUses ¶
type TaskUses []TaskDetails // the task containing the [Monoquestions]
type UpdateExercicegroupTagsIn ¶
type UpdateExercicegroupTagsIn struct {
Id ed.IdExercicegroup
Tags ed.Tags
}
type UpdateQuestiongroupTagsIn ¶
type UpdateQuestiongroupTagsIn struct {
Id ed.IdQuestiongroup
Tags ed.Tags
}