Skip to main content

Scheduler

The scheduler is the brain of the entire architecture of EASEx. It is the central point of communication between the clients and the backend services, manages all the databases, coordinates and distributes tasks to the NLU and R3D, processes all metrics, and is capable of a lot more. The internal function of the scheduler is not necessary for usage of EASEx. Developers are requested to kindly have a look at the GoDoc below:

api

import "github.com/ECA-Learning/ECAL-Proxy/pkg/api"

Index​

func Recovery​

func Recovery(next http.Handler) http.Handler

func Serve​

func Serve() error

database

import "github.com/ECA-Learning/ECAL-Proxy/pkg/database"

Index​

type BadgerClient​

type BadgerClient struct {
*badger.DB
}

func (BadgerClient) Get​

func (b BadgerClient) Get(key string, dest interface{}) error

func (BadgerClient) Iterate​

func (b BadgerClient) Iterate(callback func(k, v []byte, txn *badger.Txn) error) error

func (BadgerClient) Save​

func (b BadgerClient) Save(key string, value interface{}) error

type SQLClient​

type SQLClient struct {
*gorm.DB
Path string
}

func NewSQLiteDB​

func NewSQLiteDB(path string) SQLClient

func (*SQLClient) Insert​

func (s *SQLClient) Insert(value interface{}) error

func (*SQLClient) Open​

func (s *SQLClient) Open(models ...interface{})

mathx

import "github.com/ECA-Learning/ECAL-Proxy/pkg/mathx"

Index​

func GeneratePin​

func GeneratePin() (string, error)

func Map​

func Map[T1 any, T2 any](array []T1, f func(T1) T2) []T2

func Max​

func Max(x, y int64) int64

func StringInSlice​

func StringInSlice(a string, list []string) bool

type Set​

type Set[T comparable] map[T]bool

func New​

func New[T comparable]() Set[T]

func (BADRECV) Add​

func (s Set[T]) Add(values ...T)

func (BADRECV) Clone​

func (s Set[T]) Clone() Set[T]

func (BADRECV) Delete​

func (s Set[T]) Delete(values ...T)

func (BADRECV) Has​

func (s Set[T]) Has(value T) bool

func (BADRECV) Intersection​

func (s Set[T]) Intersection(other Set[T]) Set[T]

func (BADRECV) Iterate​

func (s Set[T]) Iterate(it func(T))

func (BADRECV) Len​

func (s Set[T]) Len() int

func (BADRECV) Union​

func (s Set[T]) Union(other Set[T]) Set[T]

func (BADRECV) Values​

func (s Set[T]) Values() []T

models

import "github.com/ECA-Learning/ECAL-Proxy/pkg/models"

Index​

Variables​

var File_protobuf_notebook_proto protoreflect.FileDescriptor

type Action​

type Action struct {
ID int `yaml:"id" json:"id"`
Dialogue string `yaml:"dialogue" json:"dialogue"`
Data string `yaml:"data" json:"data"`
PyCode string `yaml:"pyCode" json:"pyCode"`
Type ActionType `yaml:"type" json:"type"`
}

func CreateActions​

func CreateActions(upload graphql.Upload) []Action

func (Action) GetURL​

func (a Action) GetURL() url.URL

type ActionType​

type ActionType string
const (
MotivationalAction ActionType = "motivational"
EmotionalAction ActionType = "emotional"
)

type Actions​

type Actions struct {
Responsiveness []Action `json:"Responsiveness"`
Stuck []Action `json:"Stuck"`
Error []Action `json:"Error"`
ModuleUsage []Action `json:"ModuleUsage"`
FunctionUsage []Action `json:"FunctionUsage"`
Passive []Action `json:"Passive"`
}

type CellData​

type CellData struct {
Status string `json:"status"`
Timestamp int64 `json:"timestamp"`
UserTz int `json:"user_tz"`
Elapsed int `json:"elapsed"`
User struct {
DisplayName string `json:"displayName"`
PhotoURL string `json:"photoUrl"`
UserID string `json:"userId"`
} `json:"user"`
ExecutionCount int `json:"execution_count"`
}

type CellDataBuffer​

type CellDataBuffer struct {
Input string `protobuf:"bytes,1,opt,name=input,proto3" json:"input,omitempty"`
Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"`
// contains filtered or unexported fields
}

func (*CellDataBuffer) Descriptor​

func (*CellDataBuffer) Descriptor() ([]byte, []int)

Deprecated: Use CellDataBuffer.ProtoReflect.Descriptor instead.

func (*CellDataBuffer) GetInput​

func (x *CellDataBuffer) GetInput() string

func (*CellDataBuffer) GetOutput​

func (x *CellDataBuffer) GetOutput() string

func (*CellDataBuffer) ProtoMessage​

func (*CellDataBuffer) ProtoMessage()

func (*CellDataBuffer) ProtoReflect​

func (x *CellDataBuffer) ProtoReflect() protoreflect.Message

func (*CellDataBuffer) Reset​

func (x *CellDataBuffer) Reset()

func (*CellDataBuffer) String​

func (x *CellDataBuffer) String() string

type Metrics​

type Metrics struct {
CellData []struct {
Index int `json:"index"`
Input string `json:"input"`
Output string `json:"output"`
IsExecuted bool `json:"isExecuted"`
Info CellData `json:"info"`
HasError bool `json:"hasError"`
Busy bool `json:"busy"`
ParsedModules []string `json:"parsed_modules"`
ParsedFunctions []struct {
Module string `json:"module"`
Name string `json:"name"`
} `json:"parsed_functions"`
} `json:"celldata"`
LastKeyPressTime int `json:"lastkeypressTime"`
WindowURL string `json:"windowURL"`
LastMouseMoveTime int `json:"lastmousemoveTime"`
Timestamp int `json:"timestamp"`
}

type Model​

type Model struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}

type NotebookDataBuffer​

type NotebookDataBuffer struct {
Celldata []*CellDataBuffer `protobuf:"bytes,1,rep,name=celldata,proto3" json:"celldata,omitempty"`
// contains filtered or unexported fields
}

func (*NotebookDataBuffer) Descriptor​

func (*NotebookDataBuffer) Descriptor() ([]byte, []int)

Deprecated: Use NotebookDataBuffer.ProtoReflect.Descriptor instead.

func (*NotebookDataBuffer) GetCelldata​

func (x *NotebookDataBuffer) GetCelldata() []*CellDataBuffer

func (*NotebookDataBuffer) ProtoMessage​

func (*NotebookDataBuffer) ProtoMessage()

func (*NotebookDataBuffer) ProtoReflect​

func (x *NotebookDataBuffer) ProtoReflect() protoreflect.Message

func (*NotebookDataBuffer) Reset​

func (x *NotebookDataBuffer) Reset()

func (*NotebookDataBuffer) String​

func (x *NotebookDataBuffer) String() string

type ParsedCellDataBuffer​

type ParsedCellDataBuffer struct {
Modules []string `protobuf:"bytes,1,rep,name=modules,proto3" json:"modules,omitempty"`
Functions []string `protobuf:"bytes,2,rep,name=functions,proto3" json:"functions,omitempty"`
SyntaxErrors []bool `protobuf:"varint,3,rep,packed,name=syntaxErrors,proto3" json:"syntaxErrors,omitempty"`
// contains filtered or unexported fields
}

func (*ParsedCellDataBuffer) Descriptor​

func (*ParsedCellDataBuffer) Descriptor() ([]byte, []int)

Deprecated: Use ParsedCellDataBuffer.ProtoReflect.Descriptor instead.

func (*ParsedCellDataBuffer) GetFunctions​

func (x *ParsedCellDataBuffer) GetFunctions() []string

func (*ParsedCellDataBuffer) GetModules​

func (x *ParsedCellDataBuffer) GetModules() []string

func (*ParsedCellDataBuffer) GetSyntaxErrors​

func (x *ParsedCellDataBuffer) GetSyntaxErrors() []bool

func (*ParsedCellDataBuffer) ProtoMessage​

func (*ParsedCellDataBuffer) ProtoMessage()

func (*ParsedCellDataBuffer) ProtoReflect​

func (x *ParsedCellDataBuffer) ProtoReflect() protoreflect.Message

func (*ParsedCellDataBuffer) Reset​

func (x *ParsedCellDataBuffer) Reset()

func (*ParsedCellDataBuffer) String​

func (x *ParsedCellDataBuffer) String() string

type ParsedNotebookDataBuffer​

type ParsedNotebookDataBuffer struct {
Celldata []*ParsedCellDataBuffer `protobuf:"bytes,1,rep,name=celldata,proto3" json:"celldata,omitempty"`
// contains filtered or unexported fields
}

func (*ParsedNotebookDataBuffer) Descriptor​

func (*ParsedNotebookDataBuffer) Descriptor() ([]byte, []int)

Deprecated: Use ParsedNotebookDataBuffer.ProtoReflect.Descriptor instead.

func (*ParsedNotebookDataBuffer) GetCelldata​

func (x *ParsedNotebookDataBuffer) GetCelldata() []*ParsedCellDataBuffer

func (*ParsedNotebookDataBuffer) ProtoMessage​

func (*ParsedNotebookDataBuffer) ProtoMessage()

func (*ParsedNotebookDataBuffer) ProtoReflect​

func (x *ParsedNotebookDataBuffer) ProtoReflect() protoreflect.Message

func (*ParsedNotebookDataBuffer) Reset​

func (x *ParsedNotebookDataBuffer) Reset()

func (*ParsedNotebookDataBuffer) String​

func (x *ParsedNotebookDataBuffer) String() string

type Question​

type Question struct {
ID string `yaml:"ID"`
Title string `yaml:"title"`
Actions Actions `yaml:"actions"`
NotebookURLS []url.URL `yaml:"url"`
}

func ParseQuestion​

func ParseQuestion(input gqlmodels.QuestionInput) (Question, error)

type RulesType​

type RulesType struct {
Responsiveness struct {
Frequency string `yaml:"frequency"`
Indicators struct {
NoMouseMovement struct {
Enabled bool `yaml:"enabled"`
Threshold time.Duration `yaml:"threshold"`
} `yaml:"no_mouse_movement"`
NoKeyboardActivity struct {
Enabled bool `yaml:"enabled"`
Threshold time.Duration `yaml:"threshold"`
} `yaml:"no_keyboard_activity"`
NoCellExecution struct {
Enabled bool `yaml:"enabled"`
Threshold time.Duration `yaml:"threshold"`
} `yaml:"no_cell_execution"`
} `yaml:"indicators"`
Expr string `yaml:"expr"`
} `yaml:"responsiveness"`
Stuck struct {
Frequency string `yaml:"frequency"`
Indicators struct {
HighErrorFrequency struct {
Enabled bool `yaml:"enabled"`
MinNormalizedFrequency interface{} `yaml:"min_normalized_frequency"`
Time interface{} `yaml:"time"`
EarlyTrigger interface{} `yaml:"early_trigger"`
} `yaml:"high_error_frequency"`
TimeElapsedSinceLastExecutionWasAnError struct {
Enabled bool `yaml:"enabled"`
Threshold interface{} `yaml:"threshold"`
ResetThreshold interface{} `yaml:"reset_threshold"`
} `yaml:"time_elapsed_since_last_execution_was_an_error"`
} `yaml:"indicators"`
Expr string `yaml:"expr"`
Actions []int `yaml:"actions"`
} `yaml:"stuck"`
Error struct {
Indicators struct {
JupyterOutput struct {
Enabled bool `yaml:"enabled"`
Threshold time.Duration `yaml:"threshold"`
} `yaml:"jupyter_output"`
SyntaxChecker struct {
Threshold time.Duration `yaml:"threshold"`
Enabled bool `yaml:"enabled"`
} `yaml:"syntax_checker"`
} `yaml:"indicators"`
Expr string `yaml:"expr"`
Actions []int `yaml:"actions"`
} `yaml:"error"`
ModuleUsage struct {
Modules []struct {
Name string `yaml:"name"`
Threshold time.Duration `yaml:"threshold"`
Actions []int `yaml:"actions"`
} `yaml:"modules"`
Expr string `yaml:"expr"`
} `yaml:"module_usage"`
FunctionUsage struct {
Functions []struct {
Name string `yaml:"name"`
Module string `yaml:"module"`
Threshold time.Duration `yaml:"threshold"`
Actions []int `yaml:"actions"`
} `yaml:"functions"`
Expr string `yaml:"expr"`
} `yaml:"function_usage"`
Passive []struct {
Action int `yaml:"action"`
Threshold time.Duration `yaml:"threshold"`
} `yaml:"passive"`
}

type SQLQuestion​

type SQLQuestion struct {
Model
ID string `gorm:"primaryKey"`
Title string
Details datatypes.JSON
Tests []SQLTest `gorm:"foreignKey:ID"`
}

type SQLSession​

type SQLSession struct {
Model
ID string `gorm:"primaryKey"`
Details datatypes.JSON
}

type SQLStudent​

type SQLStudent struct {
Model
ID string `gorm:"primaryKey"`
UserName string
Password string
Sessions []SQLSession `gorm:"foreignKey:ID"`
}

type SQLTest​

type SQLTest struct {
Model
ID string `gorm:"primaryKey"`
Title string
StartTime int
EndTime int
Students []SQLStudent `gorm:"foreignKey:ID"`
Details datatypes.JSON
}

type Status​

type Status struct {
Responsiveness struct {
Indicators struct {
NoMouseMovement struct {
TimeElapsed int64 `json:"since"`
} `json:"no_mouse_movement"`
NoKeyboardActivity struct {
TimeElapsed int `json:"since"`
} `json:"no_keyboard_activity"`
NoCellExecution struct {
TimeElapsed int64 `json:"since"`
} `json:"no_cell_execution"`
} `json:"indicators"`
Expr bool `json:"expr"`
} `json:"responsiveness"`
Stuck struct {
Frequency string `json:"frequency"`
Indicators struct {
CellExecutions struct {
TimeElapsed int `json:"since"`
} `json:"cell_executions"`
ErrorsOccured struct {
Type string `json:"type"`
Enabled bool `json:"enabled"`
TimeElapsed int `json:"since"`
} `json:"errors_occured"`
} `json:"indicators"`
} `json:"stuck"`
Error struct {
Indicators struct {
JupyterOutput struct {
TimeElapsed int `json:"since"`
} `json:"jupyter_output"`
SyntaxChecker struct {
Enabled int `json:"enabled"`
} `json:"syntax_checker"`
} `json:"indicators"`
} `json:"error"`
ModuleUsage struct {
Modules mathx.Set[string] `json:"modules"`
Expr string `json:"expr"`
} `json:"module_usage"`
FunctionUsage struct {
Functions mathx.Set[string] `json:"functions"`
Expr string `json:"expr"`
} `json:"function_usage"`
}

type Student​

type Student struct {
ID string `json:"ID" gorm:"primaryKey"`
UserName string `json:"userName"`
Password string `json:"password"`
}

func NewStudent​

func NewStudent(generator namegenerator.Generator) Student

NewStudent Generates a new student with random id and password.

type StudentList​

type StudentList []Student

func NewStudentList​

func NewStudentList(size int) StudentList

NewStudentList Given a length, generate multiple student id

func (StudentList) ToCSVString​

func (s StudentList) ToCSVString() (string, error)

ToCSVString Converts the Student List into a comma delimited CSV string.

type TriggerStatus​

type TriggerStatus struct {
Responsiveness bool
Stuck bool
Error bool
ModuleUsage struct {
Modules []struct {
Name string `json:"name"`
TimeElapsed string `json:"since"`
Actions []int `json:"actions"`
} `json:"modules"`
Expr string `json:"expr"`
} `json:"module_usage"`
FunctionUsage struct {
Functions []struct {
Name string `json:"name"`
Module string `json:"module"`
TimeElapsed string `json:"since"`
Actions []int `json:"actions"`
} `json:"functions"`
Expr string `json:"expr"`
} `json:"function_usage"`
}

parser

import "github.com/ECA-Learning/ECAL-Proxy/pkg/parser"

Index​

func StudentList​

func StudentList(csv graphql.Upload) ([]string, error)

quiz

import "github.com/ECA-Learning/ECAL-Proxy/pkg/quiz"

Index​

type Action​

type Action struct {
ID int `yaml:"id" json:"id"`
Dialogue string `yaml:"dialogue" json:"dialogue"`
Data string `yaml:"data" json:"data"`
PyCode string `yaml:"pyCode" json:"pyCode"`
Type ActionType `yaml:"type" json:"type"`
}

type ActionType​

type ActionType string
const (
MotivationalAction ActionType = "motivational"
EmotionalAction ActionType = "emotional"
)

type Actions​

type Actions struct {
Responsiveness []Action `json:"Responsiveness"`
Stuck []Action `json:"Stuck"`
Error []Action `json:"Error"`
ModuleUsage []Action `json:"ModuleUsage"`
FunctionUsage []Action `json:"FunctionUsage"`
Passive []Action `json:"Passive"`
}

type Broker​

type Broker interface {
Broadcast(net.Event)
Send(string, net.Event) error
}

type Database​

type Database interface {
Iterate(func(k, v []byte, txn *badger.Txn) error) error
Save(key string, value interface{}) error
}

type Manager​

type Manager struct {
ActiveTests map[string]*Test
Store database.SQLClient
Scheduler TestScheduler
Broker *net.Broker
}

func NewManager​

func NewManager(broker *net.Broker) *Manager

func (*Manager) CheckScaffoldingConfig​

func (m *Manager) CheckScaffoldingConfig(c *fiber.Ctx) error

func (*Manager) FetchData​

func (m *Manager) FetchData(c *fiber.Ctx) error

func (*Manager) GeneratePins​

func (m *Manager) GeneratePins()

func (*Manager) GetActiveTests​

func (m *Manager) GetActiveTests(c *fiber.Ctx) error

func (*Manager) GetQuestion​

func (m *Manager) GetQuestion(id string) (models.Question, error)

func (*Manager) GetQuestions​

func (m *Manager) GetQuestions() ([]*gqlmodels.Question, error)

func (*Manager) Login​

func (m *Manager) Login(c *fiber.Ctx) error

func (*Manager) OpenTest​

func (m *Manager) OpenTest(c *fiber.Ctx) error

func (*Manager) SSEHandler​

func (m *Manager) SSEHandler(writer http.ResponseWriter, request *http.Request)

func (*Manager) SaveQuestion​

func (m *Manager) SaveQuestion(question gqlmodels.QuestionInput) error

func (*Manager) SaveTest​

func (m *Manager) SaveTest(data gqlmodels.TestDataInput, students []models.Student) error

func (*Manager) SetupTestLoop​

func (m *Manager) SetupTestLoop(database database.SQLClient)

func (*Manager) Start​

func (m *Manager) Start()

func (*Manager) Submit​

func (m *Manager) Submit(c *fiber.Ctx) error

func (*Manager) UpdateMetrics​

func (m *Manager) UpdateMetrics(c *fiber.Ctx) error

func (*Manager) VerifySession​

func (m *Manager) VerifySession(c *fiber.Ctx) error

type Scheduler​

type Scheduler struct {
*gocron.Scheduler
}

func (*Scheduler) SetupActionLoop​

func (scheduler *Scheduler) SetupActionLoop(broker Broker, db Database, r gqlmodels.Rules, q models.Question, a models.Actions)

func (*Scheduler) SetupJupyterHeartbeat​

func (scheduler *Scheduler) SetupJupyterHeartbeat(broker Broker, tid string)

type Session​

type Session struct {
ID string
Url url.URL
Metrics []models.Metrics
Status models.Status
Actions []struct {
Timestamp int64
Action models.Action
}
InitTimestamp int64
LastModified int64
Closed bool
}

func (*Session) CheckError​

func (s *Session) CheckError(Rules gqlmodels.Rules) bool

func (Session) CheckResponsiveness​

func (s Session) CheckResponsiveness(Rules gqlmodels.Rules) bool

func (*Session) GetTriggers​

func (s *Session) GetTriggers(Rules gqlmodels.Rules, q models.Question) int

func (*Session) TriggerAction​

func (s *Session) TriggerAction(a models.Action, broker Broker)

func (*Session) Update​

func (s *Session) Update(m models.Metrics)

func (*Session) UpdateError​

func (s *Session) UpdateError(m models.Metrics)

func (*Session) UpdateModuleAndFunctionUsage​

func (s *Session) UpdateModuleAndFunctionUsage(m models.Metrics) error

func (*Session) UpdateResponsiveness​

func (s *Session) UpdateResponsiveness(m models.Metrics)

type Test​

type Test struct {
ID string `json:"id"`
SessionDB *database.BadgerClient `json:"-"`
Scheduler Scheduler `json:"-"`
Broker *net.Broker `json:"-"`
SessionDBPath string `json:"path"`
AllowedNotebookURLs []url.URL `json:"allowedNotebookURLs"`
PinIDMap map[string]string `json:"-"`
Rules gqlmodels.Rules `json:"rules"`
Question models.Question `json:"question"`
Metrics []*gqlmodels.Metric `json:"-"`
MetricObservers map[string]chan []*gqlmodels.Metric `json:"-"`
Mu *sync.Mutex `json:"-"`
}

func (*Test) Close​

func (t *Test) Close()

func (*Test) CreateSession​

func (t *Test) CreateSession(s Session)

func (*Test) Serialize​

func (t *Test) Serialize() datatypes.JSON

func (*Test) SetupMetricLoop​

func (t *Test) SetupMetricLoop()

func (*Test) Start​

func (t *Test) Start()

type TestScheduler​

type TestScheduler struct {
*gocron.Scheduler
}

func NewTestScheduler​

func NewTestScheduler() TestScheduler

services

import "github.com/ECA-Learning/ECAL-Proxy/pkg/services"

Index​

type ParsedPython​

type ParsedPython struct {
Modules []string `json:"modules"`
Functions []string `json:"function"`
}

type ZerqMQBroker​

type ZerqMQBroker struct {
*zmq.Socket
Endpoint string
}

func NewZMQSocket​

func NewZMQSocket(endpoint string) (ZerqMQBroker, error)

func (*ZerqMQBroker) Bind​

func (s *ZerqMQBroker) Bind() error

func (*ZerqMQBroker) Connect​

func (s *ZerqMQBroker) Connect() error

func (*ZerqMQBroker) ParseNotebookData​

func (socket *ZerqMQBroker) ParseNotebookData(input models.Metrics) (ParsedPython, error)

func (*ZerqMQBroker) Send​

func (socket *ZerqMQBroker) Send(msg protoreflect.ProtoMessage, resp protoreflect.ProtoMessage) error

Generated by gomarkdoc