model

package
v0.0.0-...-f26095a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package model it the core of the system for accessing DB.

Index

Constants

This section is empty.

Variables

View Source
var Db *gorm.DB

Db - shared DB connection

View Source
var DebugLevel int

DebugLevel - the level of verbosity of the debug information

View Source
var DryRun bool

DryRun - perform processing without actually updating or changing files

View Source
var ModelAnswerUserID = 10000

ModelAnswerUserID - the user ID of the model answers

View Source
var SolverNames = map[string]string{
	"solver_opt": "Set Objective",
	"solver_adj": "Changing variable cells",
	"solver_num": "number of constraints",
	"solver_lhs": "Constraint LHS ",
	"solver_rel": "Constraint Relation",
	"solver_rhs": "Constraint RHS",
	"solver_eng": "Solver Engine",
	"solver_typ": "Solver Type ",
	"solver_val": "Solver Value",
}

SolverNames - solver name mapping

View Source
var VerboseLevel int

VerboseLevel - the level of verbosity

Functions

func AutoCommentAnswerCells

func AutoCommentAnswerCells(isPlagiarisedCommentID, modelAnswerUserID int)

AutoCommentAnswerCells adds automatic comment to the student answer cells

func CellAddress

func CellAddress(rowIndex, colIndex int) string

CellAddress maps a cell coordinates (row, column) to its address

func ChangeFormula

func ChangeFormula(formula string) string

ChangeFormula removes _xlfn from cell formulas CWA-295 convert formulas to POI compatible formulas

func DeleteAllComments

func DeleteAllComments(file *excelize.File) (wasRemoved bool)

DeleteAllComments deletes all the comments in the workbook

func NewNullInt64

func NewNullInt64(value interface{}) sql.NullInt64

NewNullInt64 - a helper function that makes nullable from a plain int or a string

func NewNullString

func NewNullString(value string) sql.NullString

NewNullString creates a NULLable string

func OpenDb

func OpenDb(url string) (db *gorm.DB, err error)

OpenDb opens DB connection based on given URL

func RelCellAddress

func RelCellAddress(address string, rowIncrement, colIncrement int) (string, error)

RelCellAddress - relative cell R1R1 representation against the given cell

func RelativeCellAddress

func RelativeCellAddress(rowIndex, colIndex int, cellID string) string

RelativeCellAddress converts cell ID into a relative R1C1 representation

func RelativeFormula

func RelativeFormula(rowIndex, colIndex int, formula string) string

RelativeFormula transforms the cell formula into the relative in R1C1 notation

func SetDb

func SetDb()

SetDb initializes DB

func UnmarshalPivotCacheDefinition

func UnmarshalPivotCacheDefinition(fileContent []byte) (content xlsx.PivotCacheDefinition)

UnmarshalPivotCacheDefinition unmarshals a worksheets autofilter

func UnmarshalPivotTableDefinition

func UnmarshalPivotTableDefinition(fileContent []byte) (content xlsx.PivotTableDefinition)

UnmarshalPivotTableDefinition unmarshals a worksheets autofilter

func UnmarshalWorksheet

func UnmarshalWorksheet(fileContent []byte) (content xlsx.Worksheet)

UnmarshalWorksheet unmarshals a worksheets autofilter

Types

type Alignment

type Alignment struct {
	ID                   int
	Horizontal, Vertical string
	WrapText             bool
}

Alignment - cell alignment style definitions

func (Alignment) TableName

func (Alignment) TableName() string

TableName overrides default table name for the model

type Answer

type Answer struct {
	ID                  int `gorm:"column:StudentAnswerID;primary_key:true;AUTO_INCREMENT"`
	Assignment          Assignment
	StudentAssignment   StudentAssignment `gorm:"association_foreignkey:StudentAssignmentID;foreignkey:StudentAssignmentID"`
	StudentAssignmentID int               `gorm:"column:StudentAssignmentID"`
	MCQOptionID         sql.NullInt64     `gorm:"column:MCQOptionID;type:int"`
	ShortAnswer         string            `gorm:"column:ShortAnswerText;type:text"`
	Marks               float64           `gorm:"column:Marks;type:float"`
	SubmissionTime      time.Time         `gorm:"column:SubmissionTime;default:NULL"`
	Worksheets          []Worksheet       `gorm:"foreignkey:AnswerID"`
	Source              Source            `gorm:"Association_foreignkey:FileID"`
	SourceID            sql.NullInt64     `gorm:"column:FileID;type:int"`
	Question            Question
	QuestionID          sql.NullInt64 `gorm:"column:QuestionID;type:int"`
	WasCommentProcessed uint8         `gorm:"type:tinyint(1);default:0"`
	WasXLProcessed      uint8         `gorm:"type:tinyint(1);default:0"`
	WasAutocommented    bool
	GradedFile          Source              `gorm:"Association_foreignkey:FileID"`
	GradedFileID        sql.NullInt64       `gorm:"column:GradedFileID;type:int"`
	AnswerComments      []AnswerComment     `gorm:"foreignkey:AnswerID"`
	XLQTransformations  []XLQTransformation `gorm:"foreignkey:QuestionID"`
}

Answer - student submitted answers

func (Answer) TableName

func (Answer) TableName() string

TableName overrides default table name for the model

type AnswerComment

type AnswerComment struct {
	Answer    Answer
	AnswerID  int `gorm:"column:StudentAnswerID;index"`
	Comment   Comment
	CommentID int `gorm:"column:CommentID"`
}

AnswerComment - answer-comment mapping:

func (AnswerComment) TableName

func (AnswerComment) TableName() string

TableName overrides default table name for the model

type Assignment

type Assignment struct {
	ID                 int    `gorm:"column:AssignmentID;primary_key:true;AUTO_INCREMENT"`
	Title              string `gorm:"column:Title;type:varchar(80)"`
	AssignmentSequence int    `gorm:"column:AssignmentSequence"`
	// StartDateAndTime   time.Time `gorm:"column:StartDateAndTime"`
	// DueDateAndTime     time.Time `gorm:"column:DueDateAndTime"`
	// UpdateTime         time.Time `gorm:"column:UpdateTime"`
	// IsHidden           bool
	// TotalMarks         float64   `gorm:"column:TotalMarks;type:float"`
	// TotalQuestion      int       `gorm:"column:TotalQuestion"`
	// CourseID           int      `gorm:"column:CourseID"`
	State        string `gorm:"column:State"` // `gorm:"column:State;type:enum('UNDER_CREATION','CREATED','READY_FOR_GRADING','GRADED')"`
	WasProcessed int8   `gorm:"type:tinyint(1)"`
}

Assignment - assigment

func (Assignment) TableName

func (Assignment) TableName() string

TableName overrides default table name for the model

type AutoEvaluation

type AutoEvaluation struct {
	ValueResult      string `gorm:"column:ValueResult;type:varchar(255);not_null;default '0'"`
	CellID           int    `gorm:"index;unique"`
	IsValueCorrect   bool   `gorm:"column:IsValueCorrect"`
	IsFormulaCorrect bool   `gorm:"column:IsFormulaCorrect"`
	IsHardcoded      bool
}

AutoEvaluation - ...

func (AutoEvaluation) TableName

func (AutoEvaluation) TableName() string

TableName overrides default table name for the model

type Block

type Block struct {
	ID              int `gorm:"column:ExcelBlockID;primary_key:true;AUTO_INCREMENT"`
	Color           string
	Range           string                `gorm:"column:BlockCellRange"`
	Formula         string                `gorm:"column:BlockFormula"` // first block cell formula
	RelativeFormula string                // first block cell relative formula formula
	Cells           []Cell                `gorm:"foreignkey:BlockID"`
	Worksheet       Worksheet             `gorm:"foreignkey:WorksheetID"`
	WorksheetID     int                   `gorm:"index"`
	CommentMappings []BlockCommentMapping `gorm:"foreignkey:ExcelBlockID"`
	Chart           Chart                 `gorm:"foreignkey:ChartId"`
	ChartID         sql.NullInt64         `grom:"type:int;index"`
	IsReference     bool                  // the block is used for referencing the expected bloks
	TRow            int                   `gorm:"index"` // Top row
	LCol            int                   `gorm:"index"` // Left column
	BRow            int                   `gorm:"index"` // Bottom row
	RCol            int                   `gorm:"index"` // Right column
	DataSourceID    sql.NullInt64         `gorm:"column:source_id;type:int"`
	FilterID        sql.NullInt64         `gorm:"type:int"`
	SortingID       sql.NullInt64         `gorm:"column:sort_id;type:int"`
	PivotID         sql.NullInt64         `gorm:"type:int"`
	// contains filtered or unexported fields
}

Block - Excel block

func (*Block) Address

func (b *Block) Address() string

Address - the block range

func (*Block) InnerAddress

func (b *Block) InnerAddress() string

InnerAddress - the block "inner" range excluding empty cells

func (*Block) IsInside

func (b *Block) IsInside(r, c int) bool

IsInside tests if the cell with given coordinates is inside the coordinates

func (Block) String

func (b Block) String() string

func (Block) TableName

func (b Block) TableName() string

TableName overrides default table name for the model

type BlockCommentMapping

type BlockCommentMapping struct {
	Block     Block
	BlockID   int `gorm:"column:ExcelBlockID"`
	Comment   Comment
	CommentID int `gorm:"column:ExcelCommentID"`
}

BlockCommentMapping - block-comment mapping

func (BlockCommentMapping) TableName

func (BlockCommentMapping) TableName() string

TableName overrides default table name for the model

type BlockCommentRow

type BlockCommentRow struct {
	Range                  string
	CommentText            string
	Marks                  float64
	TRow, LCol, BRow, RCol int
}

BlockCommentRow - a block comment row

type Border

type Border struct {
	ID                                 int
	Left, Right, Top, Bottom, Diagonal string
}

Border - cell border style definition

func (Border) TableName

func (Border) TableName() string

TableName overrides default table name for the model

type Cell

type Cell struct {
	ID                    int
	Block                 Block         `gorm:"foreignkey:BlockID"`
	BlockID               sql.NullInt64 `gorm:"index;type:int"`
	Worksheet             Worksheet
	WorksheetID           int    `gorm:"index"`
	Range                 string `gorm:"column:cell_range"`
	Formula               string
	Value                 string `gorm:"size:2000"`
	Comment               Comment
	CommentID             sql.NullInt64   `gorm:"column:CommentID;type:int"`
	Row                   int             `gorm:"index"`
	Col                   int             `gorm:"index"`
	AutoEvaluation        *AutoEvaluation `gorm:"save_associations:false"`
	Fill, Font            bool
	Borders, Alignments   string
	CellFormat, MergedRef string
	Type                  sql.NullString `gorm:"column:cell_type"`
	BorderID              sql.NullInt64  `gorm:"index;type:int"`
	Border                *Border
	AlignmentID           sql.NullInt64 `gorm:"index;type:int"`
	Alignment             *Alignment
}

Cell - a single cell of the block

func (Cell) TableName

func (Cell) TableName() string

TableName overrides default table name for the model

type CellCommentRow

type CellCommentRow struct {
	Range       string
	CommentText string
	Marks       float64
	Row, Col    int
}

CellCommentRow - a cell comment row

type Chart

type Chart struct {
	ID                                         int
	Worksheet                                  Worksheet
	WorksheetID                                int `gorm:"index"`
	Title, XLabel, YLabel                      string
	FromCol, FromRow, ToCol, ToRow, ItemCount  int
	Data, XData, YData, Type                   string
	XMinValue, XMaxValue, YMaxValue, YMinValue string
}

Chart - Excel chart

type Comment

type Comment struct {
	ID              int                   `gorm:"column:CommentID;primary_key:true;AUTO_INCREMENT"`
	Text            string                `gorm:"column:CommentText"`
	Marks           float64               `gorm:"column:Marks;type:float"`
	CommentMappings []BlockCommentMapping `gorm:"foreignkey:ExcelCommentID"`
	AnswerComments  []AnswerComment       `gorm:"foreignkey:CommentID"`
}

Comment - added comments with marks

func (Comment) TableName

func (Comment) TableName() string

TableName overrides default table name for the model

type ConditionalFormatting

type ConditionalFormatting struct {
	ID           int
	DataSourceID int    `gorm:"column:DataSourceId"`
	Type         string `gorm:"column:Type;type:varchar(50)"`
	Operator     string `gorm:"column:Operator;type:varchar(50)"`
	Formula1     string `gorm:"column:Formula1;type:varchar(255)"`
	Formula2     string `gorm:"column:Formula2;type:varchar(255)"`
	Formula3     string `gorm:"column:Formula3;type:varchar(255)"`
}

ConditionalFormatting - conditional formatting entries

func (ConditionalFormatting) TableName

func (ConditionalFormatting) TableName() string

TableName overrides default table name for the model

type DataSource

type DataSource struct {
	ID          int
	WorksheetID int
	Worksheet   Workbook
	Range       string `gorm:"column:Sourcerange;type:varchar(255)"`
}

DataSource - autofilter

func (DataSource) TableName

func (DataSource) TableName() string

TableName overrides default table name for the model

type DateGroupItem

type DateGroupItem struct {
	ID                   int
	Grouping             string        `gorm:"column:datetTimeGroupingType;type:varchar(10)"`
	Year, Month, Day     sql.NullInt64 `gorm:"type:int"`
	Hour, Minute, Second sql.NullInt64 `gorm:"type:int"`
	FilterID             int
	Filter               *Filter
}

DateGroupItem - data group

func (DateGroupItem) TableName

func (DateGroupItem) TableName() string

TableName overrides default table name for the model

type DefinedName

type DefinedName struct {
	ID          int
	Name        string
	Value       string
	IsHidden    bool
	SolverName  string
	Description string
	WorksheetID int
	Worksheet   *Worksheet
	CellID      int
	Cell        *Cell
}

DefinedName - defined names

func (DefinedName) TableName

func (DefinedName) TableName() string

TableName overrides default table name for the model

type Filter

type Filter struct {
	ID           int
	WorksheetID  int
	Worksheet    *Workbook
	DataSourceID int `gorm:"column:DataSourceID"`
	DataSource   *DataSource
	ColID        int    `gorm:"column:ColID"`
	ColName      string `gorm:"column:ColName;type:varchar(255)"`
	Operator     string `gorm:"column:Operator;type:varchar(50)"`
	Value        string `gorm:"column:Value;type:varchar(255)"`
}

Filter - filters

func (*Filter) Formula

func (f *Filter) Formula() (rf string)

Formula gets the value that should be inserted into the linked Block:

func (Filter) TableName

func (Filter) TableName() string

TableName overrides default table name for the model

type GARow

type GARow struct {
	// contains filtered or unexported fields
}

GARow - GradingAssistance entry

type MySQLQuestion

type MySQLQuestion struct {
	ID                 int                 `gorm:"column:QuestionID;primary_key:true;AUTO_INCREMENT"`
	QuestionType       QuestionType        `gorm:"column:QuestionType;type:ENUM('ShortAnswer','MCQ','FileUpload')"`
	QuestionSequence   int                 `gorm:"column:QuestionSequence;not null"`
	QuestionText       string              `gorm:"column:QuestionText;type:text;not null"`
	AnswerExplanation  sql.NullString      `gorm:"column:AnswerExplanation;type:text"`
	MaxScore           float32             `gorm:"column:MaxScore;type:float;not null"`
	SourceID           sql.NullInt64       `gorm:"column:FileID;type:int"`
	AuthorUserID       int                 `gorm:"column:AuthorUserID;not null"`
	WasCompared        bool                `gorm:"default:0"`
	IsProcessed        bool                `gorm:"column:IsProcessed;default:0"`
	Source             Source              `gorm:"foreignkey:FileID"`
	Answers            []Answer            `gorm:"foreignkey:QuestionID"`
	QuestionExcelDatas []QuestionExcelData `gorm:"foreignkey:QuestionID"`
	ReferenceID        sql.NullInt64       `gorm:"index;type:int"`
	IsFormatting       bool
	IsRubricCreated    bool
}

MySQLQuestion - questions

func (MySQLQuestion) TableName

func (MySQLQuestion) TableName() string

TableName overrides default table name for the model

type PivotTable

type PivotTable struct {
	ID           int
	DataSourceID int    `gorm:"column:DataSourceId"`
	Type         string `gorm:"column:Type;type:varchar(50)"`
	Label        string `gorm:"column:Label;type:varchar(255)"`
	DisplayName  string `gorm:"column:DisplayName;type:varchar(255)"`
	Function     string `gorm:"column:Function;type:varchar(255)"`
}

PivotTable - pivot table

func (PivotTable) TableName

func (PivotTable) TableName() string

TableName overrides default table name for the model

type Problem

type Problem struct {
	ID             int    // `gorm:"column:FileID;primary_key:true;AUTO_INCREMENT"`
	NumberOfSheets int    `gorm:"column:Number_of_sheets"`
	Name           string //`gorm:"column:S3BucketName;size:100"`
	Category       sql.NullString
	IsProcessed    bool `gorm:"column:IsProcessed;default:0"`
	Marks          sql.NullFloat64
	SourceID       int           `gorm:"column:FileID;index"`
	Source         *Source       `gorm:"foreignkey:SourceID"`
	ReferenceID    sql.NullInt64 `gorm:"index;type:int"`
}

Proplem - TODO: ...

func (*Problem) ImportBlocks

func (p *Problem) ImportBlocks(file *xlsx.File, color string, verbose, skipHidden bool) (wb Workbook)

ImportBlocks extracts blocks from the given question file and stores in the DB for referencing

func (*Problem) ImportFile

func (p *Problem) ImportFile(fileName, color string, verbose, skipHidden bool, manager s3.FileManager) error

ImportFile imports form Excel file QuestionExcleData

func (Problem) String

func (p Problem) String() string

func (Problem) TableName

func (Problem) TableName() string

TableName overrides default table name for the model

type ProblemSheet

type ProblemSheet struct {
	ID             int
	SequenceNumber int `gorm:"column:Sequence_Number"`
	Name           string
	ProblemID      int      `gorm:"index"`
	Problem        *Problem `gorm:"foreignkey:ProblemID"`
}

ProblemSheet - TODO: ...

func (ProblemSheet) TableName

func (ProblemSheet) TableName() string

TableName overrides default table name for the model

type ProblemSheetData

type ProblemSheetData struct {
	ID             int
	Range          string `gorm:"column:CellRange;size:10"`
	Value          sql.NullString
	Comment        sql.NullString
	Formula        sql.NullString
	IsReference    bool
	ProblemID      int           `gorm:"index"`
	Problem        *Problem      `gorm:"foreignkey:ProblemID"`
	ProblemSheetID int           `gorm:"column:ProblemWorkSheet_ID;index"`
	ProblemSheet   *ProblemSheet `gorm:"foreignkey:ProblemSheetID"`
}

ProblemSheetData - TODO: ...

func (ProblemSheetData) TableName

func (ProblemSheetData) TableName() string

TableName overrides default table name for the model

type Question

type Question struct {
	ID                 int            `gorm:"column:QuestionID;primary_key:true;AUTO_INCREMENT"`
	QuestionType       QuestionType   `gorm:"column:QuestionType"`
	QuestionSequence   int            `gorm:"column:QuestionSequence;not null"`
	QuestionText       string         `gorm:"column:QuestionText;type:text;not null"`
	AnswerExplanation  sql.NullString `gorm:"column:AnswerExplanation;type:text"`
	MaxScore           float32        `gorm:"column:MaxScore;type:float;not null"`
	AuthorUserID       int            `gorm:"column:AuthorUserID;not null"`
	WasCompared        bool
	IsProcessed        bool `gorm:"column:IsProcessed;default:0"`
	Source             Source
	SourceID           sql.NullInt64       `gorm:"column:FileID;type:int"`
	Answers            []Answer            `gorm:"foreignkey:QuestionID"`
	QuestionExcelDatas []QuestionExcelData `gorm:"foreignkey:QuestionID"`
	ReferenceID        sql.NullInt64       `gorm:"index;type:int"`
	IsFormatting       bool
	IsRubricCreated    bool
}

Question - questions

func QuestionsToProcess

func QuestionsToProcess() ([]Question, error)

QuestionsToProcess returns list of questions that need to be processed

func (*Question) GetGAEntries

func (q *Question) GetGAEntries(file *xlsx.File, userID int) (entries map[int]GARow, err error)

GetGAEntries - build the GA entry list (map) for the question and answer file

func (*Question) ImportBlocks

func (q *Question) ImportBlocks(file *xlsx.File, color string, verbose, skipHidden bool) (wb Workbook)

ImportBlocks extracts blocks from the given question file and stores in the DB for referencing

func (*Question) ImportFile

func (q *Question) ImportFile(fileName, color string, verbose, skipHidden bool) error

ImportFile imports form Excel file QuestionExcleData

func (Question) String

func (q Question) String() string

func (Question) TableName

func (Question) TableName() string

TableName overrides default table name for the model

type QuestionAssignment

type QuestionAssignment struct {
	Assignment   Assignment
	AssignmentID int `gorm:"column:AssignmentID"`
	Question     Question
	QuestionID   int `gorm:"column:QuestionID"`
}

QuestionAssignment - question-assignment mapping

func (QuestionAssignment) TableName

func (QuestionAssignment) TableName() string

TableName overrides default table name for the model

type QuestionExcelData

type QuestionExcelData struct {
	ID         int    `gorm:"column:Id;primary_key:true;AUTO_INCREMENT"`
	SheetName  string `gorm:"column:SheetName"`
	CellRange  string `gorm:"column:CellRange;size:10"`
	Value      string `gorm:"column:Value;size:2000"`
	Comment    string `gorm:"column:Comment"`
	Formula    string `gorm:"column:Formula"`
	Question   Question
	QuestionID int `gorm:"column:QuestionID"`
}

QuestionExcelData - extracted cells from question Workbooks

func (QuestionExcelData) TableName

func (QuestionExcelData) TableName() string

TableName overrides default table name for the model

type QuestionFile

type QuestionFile struct {
	ID         int
	SourceID   int    `gorm:"column:FileID;type:int;index"`
	Source     Source `gorm:"foreignkey:SourceID"`
	QuestionID int    `gorm:"column:QuestionID;index"`
	Question   *Question
}

QuestionFile - TODO: ...

func (QuestionFile) TableName

func (QuestionFile) TableName() string

TableName overrides default table name for the model

type QuestionFileSheet

type QuestionFileSheet struct {
	ID             int
	Sequence       int    `gorm:"column:Sheet_Sequence"`
	Name           string `gorm:"column:Sheet_Name"`
	QuestionFileID int    `gorm:"column:QuestionFileID;type:int;index"`
	QuestionFile   *QuestionFile
	ProblemSheetID int `gorm:"column:ProblemWorkSheetsID;type:int;index"`
	ProblemSheet   *ProblemSheet
	ProblemID      int      `gorm:"index"`
	Problem        *Problem `gorm:"foreignkey:ProblemID"`
}

QuestionFileSheet - TODO: ...

func (QuestionFileSheet) TableName

func (QuestionFileSheet) TableName() string

TableName overrides default table name for the model

type QuestionType

type QuestionType string

QuestionType - workaround for MySQL EMUM(...)

func (*QuestionType) Scan

func (qt *QuestionType) Scan(value interface{}) error

Scan - workaround for MySQL EMUM(...)

func (QuestionType) Value

func (qt QuestionType) Value() (driver.Value, error)

Value - workaround for MySQL EMUM(...)

type RowsToProcessResult

type RowsToProcessResult struct {
	ID              int           `gorm:"column:FileID"`
	S3BucketName    string        `gorm:"column:S3BucketName"`
	S3Key           string        `gorm:"column:S3Key"`
	FileName        string        `gorm:"column:FileName"`
	StudentAnswerID int           `gorm:"column:StudentAnswerID"`
	QuestionID      sql.NullInt64 `gorm:"column:QuestionID;type:int"`
}

RowsToProcessResult stores query resut

func RowsToComment

func RowsToComment(assignmentID int) ([]RowsToProcessResult, error)

RowsToComment returns slice with all recored of source files and AswerIDs that need to be commeted

func RowsToProcess

func RowsToProcess(assignmentID int) ([]RowsToProcessResult, error)

RowsToProcess returns answer file sources

type Rubric

type Rubric struct {
	ID         int
	TotalMarks sql.NullFloat64
	Item1      sql.NullFloat64
	Item2      sql.NullFloat64
	Item3      sql.NullFloat64
	Item4      sql.NullFloat64
	Item5      sql.NullFloat64
	Range      string `gorm:"column:block_cell_range"`
	NumCell    int
	Block      *Block
	BlockID    int `gorm:"column:ExcelBlockID;index;not null"`
	Question   *Question
	QuestionID int `gorm:"column:QuestionID;index;not null"`
}

Rubric ...

func (Rubric) TableName

func (Rubric) TableName() string

TableName overrides default table name for the model

type SharedStrings

type SharedStrings []string

SharedStrings - workbook shared strings

func GetSharedStrings

func GetSharedStrings(file *excelize.File) SharedStrings

GetSharedStrings - loads and stores the shared string into a string slice

func (SharedStrings) Get

func (sharedStrings SharedStrings) Get(idx interface{}) (ss string)

Get returns a shared string

type Sorting

type Sorting struct {
	ID           int
	DataSourceID int    `gorm:"column:DataSourceID"`
	Method       string `gorm:"column:SortMethod;type:varchar(10);not null"`
	Reference    string `gorm:"column:SortingReference;type:varchar(255);not null"`
	Type         string `gorm:"column:SortType;type:varchar(50);not null"`
	SortBy       string `gorm:"column:sortBy;type:varchar(50);not null"`
	CustomList   string `gorm:"column:customList;type:varchar(255)"`
	IconSet      string `gorm:"column:iconSet;type:varchar(255)"`
	IconID       string `gorm:"column:iconId;type:varchar(255)"`
}

Sorting - column sorting

func (Sorting) TableName

func (Sorting) TableName() string

TableName overrides default table name for the model

type Source

type Source struct {
	ID           int        `gorm:"column:FileID;primary_key:true;AUTO_INCREMENT"`
	S3BucketName string     `gorm:"column:S3BucketName;size:100"`
	S3Key        string     `gorm:"column:S3Key;size:100"`
	FileName     string     `gorm:"column:FileName;size:100"`
	ContentType  string     `gorm:"column:ContentType;size:100"`
	FileSize     int64      `gorm:"column:FileSize"`
	Answers      []Answer   `gorm:"foreignkey:FileID"`
	Questions    []Question `gorm:"foreignkey:FileID"`
}

Source - student answer file sources

func (Source) DownloadTo

func (s Source) DownloadTo(manager s3.FileManager, dest string) (fileName string, err error)

DownloadTo - download and store source file to a specified directory

func (Source) TableName

func (Source) TableName() string

TableName overrides default table name for the model

type StudentAssignment

type StudentAssignment struct {
	ID           int `gorm:"column:StudentAssignmentID;primary_key:true;AUTO_INCREMENT"`
	UserID       int `gorm:"column:UserID;type:int"`
	User         User
	AssignmentID int `gorm:"column:AssignmentID"`
	Assignment   Assignment
}

StudentAssignment - stuendent assigment

func (StudentAssignment) TableName

func (StudentAssignment) TableName() string

TableName overrides default table name for the model

type User

type User struct {
	ID int `gorm:"column:UserID;primary_key;auto_increment"`
}

User - users

func (User) TableName

func (User) TableName() string

TableName overrides default table name for the model

type Workbook

type Workbook struct {
	ID          int `gorm:"primary_key:true"`
	FileName    string
	CreatedAt   time.Time
	AnswerID    sql.NullInt64 `gorm:"column:StudentAnswerID;index;type:int"`
	Answer      Answer        `gorm:"foreignkey:AnswerID"`
	Worksheets  []Worksheet   // `gorm:"foreignkey:WorkbookID"`
	IsReference bool          // the workbook is used for referencing the expected blocks
}

Workbook - Excel file / workbook

func ExtractBlocksFromFile

func ExtractBlocksFromFile(fileName, color string, force, verbose, skipHidden bool, answerIDs ...int) (wb Workbook, err error)

ExtractBlocksFromFile extracts blocks from the given file and stores in the DB

func (*Workbook) ImportComments

func (wb *Workbook) ImportComments(fileName string) (err error)

ImportComments - import comments from workbook file

func (*Workbook) ImportWorksheets

func (wb *Workbook) ImportWorksheets(fileName string)

ImportWorksheets - import charts, filters, ... form workbook file also read and match plagiarism key

func (*Workbook) MatchPlagiarismKeys

func (wb *Workbook) MatchPlagiarismKeys(file *excelize.File)

MatchPlagiarismKeys reads plagiarism key and match with the one stored in SpreadsheetTransformationTable (NB! the worksheets should be already imported)

func (*Workbook) Reset

func (wb *Workbook) Reset()

Reset deletes all underlying objects: worksheets, blocks, and cells

func (Workbook) TableName

func (Workbook) TableName() string

TableName overrides default table name for the model

type Worksheet

type Worksheet struct {
	ID               int
	Name             string
	WorkbookFileName string
	Blocks           []Block       `gorm:"foreignkey:WorksheetID"`
	Answer           Answer        `gorm:"foreignkey:AnswerID"`
	AnswerID         sql.NullInt64 `gorm:"column:StudentAnswerID;index;type:int"`
	Workbook         Workbook      `gorm:"foreignkey:WorkbookId"`
	WorkbookID       int           `gorm:"index"`
	IsReference      bool
	OrderNum         int
	Idx              int
	IsPlagiarised    bool   // sql.NullBool
	Cells            []Cell `gorm:"foreignkey:WorksheetID"`
	// contains filtered or unexported fields
}

Worksheet - Excel workbook worksheet

func (*Worksheet) AddAuxBlock

func (ws *Worksheet) AddAuxBlock(b *Block, cellType string)

AddAuxBlock creates a block with an auxilary cell entry related to the whorksheet data entry.

func (*Worksheet) FindBlocksInside

func (ws *Worksheet) FindBlocksInside(sheet *xlsx.Sheet, rb Block, importFormatting bool) (err error)

FindBlocksInside - find answer blocks within the reference block (rb) and store them

func (*Worksheet) GetBlockComments

func (ws *Worksheet) GetBlockComments() (res map[int][]BlockCommentRow, err error)

GetBlockComments retrieves all block comments in a form of a map

func (*Worksheet) GetCellComments

func (ws *Worksheet) GetCellComments() (res []CellCommentRow, err error)

GetCellComments retrieves all block comments in a form of a map

func (*Worksheet) ImportCharts

func (ws *Worksheet) ImportCharts(file *excelize.File)

ImportCharts - import charts for the worksheet

func (*Worksheet) ImportWorksheetData

func (ws *Worksheet) ImportWorksheetData(file *excelize.File, sharedStrings SharedStrings)

ImportWorksheetData imports all filters

func (Worksheet) TableName

func (Worksheet) TableName() string

TableName overrides default table name for the model

type XLQTransformation

type XLQTransformation struct {
	ID             int
	CellReference  string    `gorm:"type:varchar(10);not null"`
	TimeStamp      time.Time `gorm:"not null"`
	UserID         int       `gorm:"column:UserID;not null;index"`
	User           *User
	QuestionID     int `gorm:"column:QuestionID;not null;index"`
	Question       Question
	SourceID       int       `gorm:"column:FileID;not null;index"`
	Source         *Source   `gorm:"foreignkey:SourceID"`
	QuestionFileID int       `gorm:"column:questionfile_id;not null;index"`
	QuestionFile   *Question `gorm:"foreignkey:questionfile_id"`
	Randomstring   string
}

XLQTransformation - XLQ Transformations

func (XLQTransformation) TableName

func (XLQTransformation) TableName() string

TableName overrides default table name for the model

type XlsxBareChart

type XlsxBareChart struct {
	XMLName xml.Name `xml:"http://schemas.openxmlformats.org/drawingml/2006/chart chartSpace"`
	// XMLNSc         string          `xml:"xmlns:c,attr"`
	// XMLNSa         string          `xml:"xmlns:a,attr"`
	// XMLNSr         string          `xml:"xmlns:r,attr"`
	// XMLNSc16r2     string          `xml:"xmlns:c16r2,attr"`
	// Date1904       *attrValBool    `xml:"c:date1904"`
	// Lang           *attrValString  `xml:"lang"`
	// RoundedCorners *attrValBool    `xml:"c:roundedCorners"`
	// Chart          cChart          `xml:"c:chart"`
	// SpPr           *cSpPr          `xml:"c:spPr"`
	// TxPr           *cTxPr          `xml:"c:txPr"`
	// PrintSettings *cPrintSettings `xml:"c:printSettings"`
	// Title    string       `xml:"chart>title>tx>rich>p>r>t"`
	Title    xlsxTitle    `xml:"chart>title"`
	PlotArea xlsxPlotArea `xml:"chart>plotArea"`
}

XlsxBareChart - minial requiered implementation of the Chart object

func UnmarshalChart

func UnmarshalChart(fileContent []byte) (content XlsxBareChart)

UnmarshalChart unmarshals the chart data

func (*XlsxBareChart) ItemCount

func (c *XlsxBareChart) ItemCount() int

ItemCount - shortcut for number of itmems displayed

func (*XlsxBareChart) Type

func (c *XlsxBareChart) Type() string

Type - chart type - short-cut

func (*XlsxBareChart) XLabel

func (c *XlsxBareChart) XLabel() string

XLabel - X-axis title

func (*XlsxBareChart) XMaxValue

func (c *XlsxBareChart) XMaxValue() string

XMaxValue - X-axis max value

func (*XlsxBareChart) XMinValue

func (c *XlsxBareChart) XMinValue() string

XMinValue - X-axis min value

func (*XlsxBareChart) YLabel

func (c *XlsxBareChart) YLabel() string

YLabel - Y-axis title

func (*XlsxBareChart) YMaxValue

func (c *XlsxBareChart) YMaxValue() string

YMaxValue - Y-axis max value

func (*XlsxBareChart) YMinValue

func (c *XlsxBareChart) YMinValue() string

YMinValue - Y-axis min value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL