inginious.frontend package

Package that implements a webapp for INGInious

Subpackages

Submodules

inginious.frontend.accessible_time module

Contains AccessibleTime, class that represents the period of time when a course/task is accessible

class inginious.frontend.accessible_time.AccessibleTime(val=None)[source]

Bases: object

represents the period of time when a course/task is accessible

after_start(when=None)[source]

Returns True if the task/course is or have been accessible in the past

before_start(when=None)[source]

Returns True if the task/course is not yet accessible

get_end_date()[source]

Return a datetime object, representing the deadline for accessibility

get_soft_end_date()[source]

Return a datetime object, representing the soft deadline for accessibility

get_start_date()[source]

Return a datetime object, representing the date when the task/course become accessible

get_std_end_date()[source]

If the date is custom, return the end datetime with the format %Y-%m-%d %H:%M:%S. Else, returns “”.

get_std_soft_end_date()[source]

If the date is custom, return the soft datetime with the format %Y-%m-%d %H:%M:%S. Else, returns “”.

get_std_start_date()[source]

If the date is custom, return the start datetime with the format %Y-%m-%d %H:%M:%S. Else, returns “”.

is_always_accessible()[source]

Returns true if the course/task is always accessible

is_never_accessible()[source]

Returns true if the course/task is never accessible

is_open(when=None)[source]

Returns True if the course/task is still open

is_open_with_soft_deadline(when=None)[source]

Returns True if the course/task is still open with the soft deadline

inginious.frontend.accessible_time.parse_date(date, default=None)[source]

Parse a valid date

inginious.frontend.arch_helper module

inginious.frontend.arch_helper.create_arch(configuration, tasks_fs, context, course_factory)[source]
Helper that can start a simple complete INGInious arch locally if needed, or a client to a remote backend.
Intended to be used on command line, makes uses of exit() and the logger inginious.frontend.
Parameters:
  • configuration – configuration dict
  • tasks_fs – FileSystemProvider to the courses/tasks folders
  • context – a ZMQ context
  • course_factory – The course factory to be used by the frontend
  • is_testing – boolean
Returns:

a Client object

inginious.frontend.arch_helper.start_asyncio_and_zmq(debug_asyncio=False)[source]

Init asyncio and ZMQ. Starts a daemon thread in which the asyncio loops run. :return: a ZMQ context and a Thread object (as a tuple)

inginious.frontend.app module

Starts the webapp

inginious.frontend.app.get_app(config)[source]
Parameters:config – the configuration dict
Returns:A new app

inginious.frontend.courses module

A course class with some modification for users

class inginious.frontend.courses.WebAppCourse(courseid, content, course_fs, task_factory, hook_manager)[source]

Bases: inginious.common.courses.Course

A course with some modification for users

allow_preview()[source]
allow_unregister(plugin_override=True)[source]

Returns True if students can unregister from course

can_students_choose_group()[source]

Returns True if the students can choose their groups

get_access_control_list()[source]

Returns the list of all users allowed by the AC list

get_access_control_method()[source]

Returns either None, “username”, “binding”, or “email”, depending on the method used to verify that users can register to the course

get_accessibility(plugin_override=True)[source]

Return the AccessibleTime object associated with the accessibility of this course

get_admins()[source]

Returns a list containing the usernames of the administrators of this course

get_description(language)[source]

Returns the course description

get_name(language)[source]

Return the name of this course

get_registration_accessibility()[source]

Return the AccessibleTime object associated with the registration

get_registration_password()[source]

Returns the password needed for registration (None if there is no password)

get_staff()[source]

Returns a list containing the usernames of all the staff users

get_tags()[source]
get_tasks()[source]

Get all tasks in this course

get_tutors()[source]

Returns a list containing the usernames of the tutors assigned to this course

is_lti()[source]

True if the current course is in LTI mode

is_open_to_non_staff()[source]

Returns true if the course is accessible by users that are not administrator of this course

is_password_needed_for_registration()[source]

Returns true if a password is needed for registration

is_registration_possible(user_info)[source]

Returns true if users can register for this course

is_user_accepted_by_access_control(user_info)[source]

Returns True if the user is allowed by the ACL

lti_keys()[source]

{name: key} for the LTI customers

lti_send_back_grade()[source]

True if the current course should send back grade to the LTI Tool Consumer

use_classrooms()[source]

Returns True if classrooms are used

inginious.frontend.database_updater module

inginious.frontend.installer module

Custom installer for the web app

class inginious.frontend.installer.Installer(config_path=None)[source]

Bases: object

Custom installer for the WebApp frontend

ask_backend()[source]

Ask the user to choose the backend

configuration_filename()[source]

Returns the name of the configuration file

configure_authentication(database)[source]

Configure the authentication

configure_backup_directory()[source]

Configure backup directory

configure_containers(current_options)[source]

Configures the container dict

configure_misc()[source]

Configure various things

configure_mongodb()[source]

Configure MongoDB

configure_task_directory()[source]

Configure task directory

download_containers(to_download, current_options)[source]

Download the chosen containers on all the agents

ldap_plugin()[source]

Configures the LDAP plugin

run()[source]

Run the installator

support_remote_debugging()[source]

Returns True if the frontend supports remote debugging, False else

test_local_docker_conf()[source]

Test to connect to a local Docker daemon

try_mongodb_opts(host='localhost', database_name='INGInious')[source]

Try MongoDB configuration

inginious.frontend.parsable_text module

Tools to parse text

class inginious.frontend.parsable_text.CustomAdmonition(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: inginious.frontend.parsable_text.CustomBaseAdmonition

A custom admonition with a specific class if needed

node_class

alias of docutils.nodes.admonition

required_arguments = 1
class inginious.frontend.parsable_text.CustomBaseAdmonition(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.directives.admonitions.BaseAdmonition

A custom admonition that can have a title

option_spec = {'class': <function class_option>, 'name': <function unchanged>, 'title': <function unchanged>}
class inginious.frontend.parsable_text.EmptiableCodeBlock(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.directives.body.CodeBlock

run()[source]
class inginious.frontend.parsable_text.HiddenUntilDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: docutils.parsers.rst.Directive, object

has_content = True
option_spec = {}
optional_arguments = 0
required_arguments = 1
run()[source]
class inginious.frontend.parsable_text.ParsableText(content, mode='rst', show_everything=False, translation=<gettext.NullTranslations object>)[source]

Bases: object

Allow to parse a string with different parsers

classmethod html(string, show_everything=False, translation=<gettext.NullTranslations object>)[source]

Parses HTML

original_content()[source]

Returns the original content

parse(debug=False)[source]

Returns parsed text

classmethod rst(string, show_everything=False, translation=<gettext.NullTranslations object>, initial_header_level=3, debug=False)[source]

Parses reStructuredText

inginious.frontend.plugin_manager module

Plugin Manager

class inginious.frontend.plugin_manager.PluginManager[source]

Bases: inginious.common.hook_manager.HookManager

Registers an manage plugins. The init method inits only the Hook Manager; you have to call the method load() to start the plugins

add_page(pattern, classname)[source]

Add a new page to the web application. Only available after that the Plugin Manager is loaded

add_task_file_manager(task_file_manager)[source]

Add a task file manager. Only available after that the Plugin Manager is loaded

get_database()[source]

Returns the frontend database

get_submission_manager()[source]

Returns the submission manager

get_user_manager()[source]

Returns the user manager

load(client, webpy_app, course_factory, task_factory, database, user_manager, submission_manager, config)[source]

Loads the plugin manager. Must be done after the initialisation of the client

register_auth_method(auth_method)[source]

Register a new authentication method

name
the name of the authentication method, typically displayed by the webapp

input_to_display

Only available after that the Plugin Manager is loaded

exception inginious.frontend.plugin_manager.PluginManagerNotLoadedException[source]

Bases: Exception

inginious.frontend.session_mongodb module

Saves sessions in the database

class inginious.frontend.session_mongodb.MongoStore(database, collection_name='sessions')[source]

Bases: web.session.Store

Allow to store web.py sessions in MongoDB

cleanup(timeout)[source]

Removes all sessions older than timeout seconds. Called automatically on every session access.

decode(sessiondict)[source]

decodes the data to get back the session dict

encode(sessiondict)[source]

encodes session dict as a string

inginious.frontend.session_mongodb.needs_encode(obj)[source]
>>> from re import compile
>>> atomics = (True, 1, 1.0, '', None, compile(''), datetime.now(), b'')
>>> any(needs_encode(i) for i in atomics)
False
>>> needs_encode([1, 2, 3])
False
>>> needs_encode([])
False
>>> needs_encode([1, [2, 3]])
False
>>> needs_encode({})
False
>>> needs_encode({'1': {'2': 3}})
False
>>> needs_encode({'1': [2]})
False
>>> needs_encode(b'1')
False

Objects that don’t round trip need encoding:

>>> needs_encode(tuple())

True >>> needs_encode(set()) True >>> needs_encode([1, [set()]]) True >>> needs_encode({‘1’: {‘2’: set()}}) True

Mongo rejects dicts with non-string keys so they need encoding too:

>>> needs_encode({1: 2})

True >>> needs_encode({‘1’: {None: True}}) True

inginious.frontend.static_middleware module

A middleware for Web.py that serves static content

class inginious.frontend.static_middleware.StaticApp(base_path, environ, start_response)[source]

Bases: web.httpserver.StaticApp, object

WSGI application for serving static files.

translate_path(path)[source]

Translate a /-separated PATH to the local filename syntax.

Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.)

class inginious.frontend.static_middleware.StaticMiddleware(app, paths)[source]

Bases: object

WSGI middleware for serving static files.

normpath(path)[source]

Normalize the path

inginious.frontend.submission_manager module

Manages submissions

class inginious.frontend.submission_manager.WebAppSubmissionManager(client, user_manager, database, gridfs, hook_manager, lti_outcome_manager)[source]

Bases: object

Manages submissions. Communicates with the database and the client.

add_job(task, inputdata, debug=False)[source]

Add a job in the queue and returns a submission id. :param task: Task instance :type task: inginious.frontend.tasks.WebAppTask :param inputdata: the input as a dictionary :type inputdata: dict :param debug: If debug is true, more debug data will be saved :type debug: bool or string :returns: the new submission id and the removed submission id

get_available_environments()[source]

:return a list of available environments

get_feedback_from_submission(submission, only_feedback=False, show_everything=False, translation=<gettext.NullTranslations object>)[source]

Get the input of a submission. If only_input is False, returns the full submissions with a dictionnary object at the key “input”. Else, returns only the dictionnary.

If show_everything is True, feedback normally hidden is shown.

get_gridfs()[source]

Returns the GridFS used by the submission manager

get_input_from_submission(submission, only_input=False)[source]

Get the input of a submission. If only_input is False, returns the full submissions with a dictionnary object at the key “input”. Else, returns only the dictionnary.

get_job_queue_info(jobid)[source]
Parameters:jobid – the JOB id (not the submission id!). You should retrieve it before calling this function by calling get_submission(…)[

“job_id”]. :return: If the submission is in the queue, then returns a tuple (nb tasks before running (or -1 if running), approx wait time in seconds)

Else, returns None
get_job_queue_snapshot()[source]
Get a snapshot of the remote backend job queue. May be a cached version.
May not contain recent jobs. May return None if no snapshot is available

Return a tuple of two lists (None, None): jobs_running: a list of tuples in the form

(job_id, is_current_client_job, info, launcher, started_at, max_end) where - job_id is a job id. It may be from another client. - is_current_client_job is a boolean indicating if the client that asked the request has started the job - agent_name is the agent name - info is “courseid/taskid” - launcher is the name of the launcher, which may be anything - started_at the time (in seconds since UNIX epoch) at which the job started - max_end the time at which the job will timeout (in seconds since UNIX epoch), or -1 if no timeout is set
jobs_waiting: a list of tuples in the form
(job_id, is_current_client_job, info, launcher, max_time) where - job_id is a job id. It may be from another client. - is_current_client_job is a boolean indicating if the client that asked the request has started the job - info is “courseid/taskid” - launcher is the name of the launcher, which may be anything - max_time the maximum time that can be used, or -1 if no timeout is set
get_submission(submissionid, user_check=True)[source]

Get a submission from the database

get_submission_archive(submissions, sub_folders, aggregations, archive_file=None)[source]
Parameters:
  • submissions – a list of submissions
  • sub_folders – possible values: []: put all submissions in / [‘taskid’]: put all submissions for each task in a different directory /taskid/ [‘username’]: put all submissions for each user in a different directory /username/ [‘taskid’,’username’]: /taskid/username/ [‘username’,’taskid’]: /username/taskid/
Returns:

a file-like object containing a tgz archive of all the submissions

get_user_last_submissions(limit=5, request=None)[source]

Get last submissions of a user

get_user_submissions(task)[source]

Get all the user’s submissions for a given task

is_done(submissionid_or_submission, user_check=True)[source]

Tells if a submission is done and its result is available

is_running(submissionid, user_check=True)[source]

Tells if a submission is running/in queue

kill_running_submission(submissionid, user_check=True)[source]

Attempt to kill the remote job associated with this submission id. :param submissionid: :param user_check: Check if the current user owns this submission :return: True if the job was killed, False if an error occurred

replay_job(task, submission, copy=False, debug=False)[source]

Replay a submission: add the same job in the queue, keeping submission id, submission date and input data :param submission: Submission to replay :param copy: If copy is true, the submission will be copied to admin submissions before replay :param debug: If debug is true, more debug data will be saved

user_is_submission_owner(submission)[source]

Returns true if the current user is the owner of this jobid, false else

inginious.frontend.submission_manager.update_pending_jobs(database)[source]

Updates pending jobs status in the database

inginious.frontend.task_page_helpers module

inginious.frontend.task_problems module

Displyable problems

class inginious.frontend.task_problems.DisplayableCodeProblem(task, problemid, content)[source]

Bases: inginious.common.tasks_problems.CodeProblem, inginious.frontend.task_problems.DisplayableProblem

A basic class to display all BasicCodeProblem derivatives

adapt_input_for_backend(input_data)[source]

Adapt the input from web.py for the inginious.backend

classmethod get_type_name(language)[source]
classmethod show_editbox(template_helper, key, language)[source]

get the edit box html for this problem

classmethod show_editbox_templates(template_helper, key, language)[source]
show_input(template_helper, language, seed)[source]

Show BasicCodeProblem and derivatives

class inginious.frontend.task_problems.DisplayableCodeSingleLineProblem(task, problemid, content)[source]

Bases: inginious.common.tasks_problems.CodeSingleLineProblem, inginious.frontend.task_problems.DisplayableProblem

A displayable single code line problem

adapt_input_for_backend(input_data)[source]

Adapt the input from web.py for the inginious.backend

classmethod get_type_name(language)[source]
classmethod show_editbox(template_helper, key, language)[source]

get the edit box html for this problem

classmethod show_editbox_templates(template_helper, key, language)[source]
show_input(template_helper, language, seed)[source]

Show InputBox

class inginious.frontend.task_problems.DisplayableFileProblem(task, problemid, content)[source]

Bases: inginious.common.tasks_problems.FileProblem, inginious.frontend.task_problems.DisplayableProblem

A displayable code problem

adapt_input_for_backend(input_data)[source]

Adapt the input from web.py for the inginious.backend

classmethod get_type_name(language)[source]
classmethod show_editbox(template_helper, key, language)[source]

get the edit box html for this problem

classmethod show_editbox_templates(template_helper, key, language)[source]
show_input(template_helper, language, seed)[source]

Show FileBox

class inginious.frontend.task_problems.DisplayableMatchProblem(task, problemid, content)[source]

Bases: inginious.common.tasks_problems.MatchProblem, inginious.frontend.task_problems.DisplayableProblem

A displayable match problem

classmethod get_type_name(language)[source]
classmethod show_editbox(template_helper, key, language)[source]

get the edit box html for this problem

classmethod show_editbox_templates(template_helper, key, language)[source]
show_input(template_helper, language, seed)[source]

Show MatchProblem

class inginious.frontend.task_problems.DisplayableMultipleChoiceProblem(task, problemid, content)[source]

Bases: inginious.common.tasks_problems.MultipleChoiceProblem, inginious.frontend.task_problems.DisplayableProblem

A displayable multiple choice problem

classmethod get_type_name(language)[source]
classmethod show_editbox(template_helper, key, language)[source]

get the edit box html for this problem

classmethod show_editbox_templates(template_helper, key, language)[source]
show_input(template_helper, language, seed)[source]

Show multiple choice problems

class inginious.frontend.task_problems.DisplayableProblem(task, problemid, content)[source]

Bases: inginious.common.tasks_problems.Problem

Basic problem

adapt_input_for_backend(input_data)[source]

Adapt the input from web.py for the inginious.backend

classmethod get_renderer(template_helper)[source]

Get the renderer for this class problem

classmethod get_type_name(language)[source]
classmethod show_editbox(template_helper, key, language)[source]

get the edit box html for this problem

classmethod show_editbox_templates(template_helper, key, language)[source]
show_input(template_helper, language, seed)[source]

get the html for this problem

inginious.frontend.tasks module

Classes modifying basic tasks, problems and boxes classes

class inginious.frontend.tasks.WebAppTask(course, taskid, content, task_fs, translations_fs, hook_manager, task_problem_types)[source]

Bases: inginious.common.tasks.Task

A task that stores additional context information, specific to the web app

adapt_input_for_backend(input_data)[source]

Adapt the input from web.py for the inginious.backend

get_accessible_time(plugin_override=True)[source]

Get the accessible time of this task

get_authors(language)[source]

Return the list of this task’s authors

get_categories()[source]

Returns the tags id associated to the task

get_context(language)[source]

Get the context(description) of this task

get_deadline()[source]

Returns a string containing the deadline for this task

get_evaluate()[source]

Indicates the default download for the task

get_grading_weight()[source]

Get the relative weight of this task in the grading

get_name(language)[source]

Returns the name of this task

get_number_input_random()[source]

Return the number of random inputs

get_stored_submissions()[source]

Indicates if only the last submission must be stored for the task

get_submission_limit()[source]

Returns the submission limits et for the task

is_group_task()[source]

Indicates if the task submission mode is per groups

is_visible_by_students()[source]

Returns true if the task is accessible by all students that are not administrator of the course

regenerate_input_random()[source]

Indicates if random inputs should be regenerated

inginious.frontend.tasks_code_boxes module

inginious.frontend.template_helper module

TemplateManager

class inginious.frontend.template_helper.TemplateHelper(plugin_manager, user_manager, default_template_dir, default_layout, default_layout_lti, use_minified=True)[source]

Bases: object

Class accessible from templates that calls function defined in the Python part of the code.

add_css(link)[source]

Add a css file to load

add_javascript(link, position='footer')[source]

Add a javascript file to load. Position can either be “header” or “footer”

add_other(name, func)[source]

Add another callback to the template helper

add_to_template_globals(name, value)[source]

Add a variable to will be accessible in the templates

call(name, **kwargs)[source]
get_custom_renderer(dir_path, layout=True)[source]

Create a template renderer on templates in the directory specified, and returns it. :param dir_path: the path to the template dir. If it is not absolute, it will be taken from the root of the inginious package. :param layout: can either be True (use the base layout of the running app), False (use no layout at all), or the path to the layout to use.

If this path is relative, it is taken from the INGInious package root.
get_renderer(with_layout=True)[source]

Get the default renderer

is_lti()[source]

True if the current session is an LTI one

inginious.frontend.user_manager module

Manages users data and session

exception inginious.frontend.user_manager.AuthInvalidInputException[source]

Bases: Exception

exception inginious.frontend.user_manager.AuthInvalidMethodException[source]

Bases: Exception

class inginious.frontend.user_manager.AuthMethod[source]

Bases: object

allow_share()[source]
Returns:True if the auth method allow sharing, else false
callback(auth_storage)[source]
Parameters:auth_storage – The session auth method storage dict
Returns:User tuple and , or None, if failed
Parameters:auth_storage – The session auth method storage dict
Returns:The authentication link
get_id()[source]
Returns:The auth method id
Returns:The image link
get_name()[source]
Returns:The name of the auth method, to be displayed publicly
share(auth_storage, course, task, submission, language)[source]
Parameters:auth_storage – The session auth method storage dict
Returns:False if error
class inginious.frontend.user_manager.UserManager(session_dict, database, superadmins)[source]

Bases: object

attempt_lti_login()[source]

Given that the current session is an LTI one (session_lti_info does not return None), attempt to find an INGInious user linked to this lti username/consumer_key. If such user exists, logs in using it.

Returns True (resp. False) if the login was successful

auth_user(username, password)[source]

Authenticate the user in database :param username: Username/Login :param password: User password :return: Returns a dict represrnting the user

bind_user(auth_id, user)[source]
connect_user(username, realname, email, language)[source]

Opens a session for the user :param username: Username :param realname: User real name :param email: User email

course_is_open_to_user(course, username=None, lti=None)[source]

Checks if a user is can access a course :param course: a Course object :param username: The username of the user that we want to check. If None, uses self.session_username() :param lti: indicates if the user is currently in a LTI session or not.

  • None to ignore the check
  • True to indicate the user is in a LTI session
  • False to indicate the user is not in a LTI session
  • “auto” to enable the check and take the information from the current session
Returns:True if the user can access the course, False else
course_is_user_registered(course, username=None)[source]

Checks if a user is registered :param course: a Course object :param username: The username of the user that we want to check. If None, uses self.session_username() :return: True if the user is registered, False else

course_register_user(course, username=None, password=None, force=False)[source]

Register a user to the course :param course: a Course object :param username: The username of the user that we want to register. If None, uses self.session_username() :param password: Password for the course. Needed if course.is_password_needed_for_registration() and force != True :param force: Force registration :return: True if the registration succeeded, False else

course_unregister_user(course, username=None)[source]

Unregister a user to the course :param course: a Course object :param username: The username of the user that we want to unregister. If None, uses self.session_username()

create_lti_session(user_id, roles, realname, email, course_id, task_id, consumer_key, outcome_service_url, outcome_result_id, tool_name, tool_desc, tool_url, context_title, context_label)[source]

Creates an LTI cookieless session. Returns the new session id

disconnect_user()[source]

Disconnects the user currently logged-in :param ip_addr: the ip address of the client, that will be logged

classmethod generate_api_key()[source]
get_auth_method(auth_method_id)[source]

:param the auth method id, as provided by get_auth_methods_inputs() :return: AuthMethod if it exists, otherwise None

get_auth_methods()[source]
Returns:The auth methods dict
get_course_aggregations(course)[source]

Returns a list of the course aggregations

get_course_cache(username, course)[source]
Parameters:
  • username – The username
  • course – A Course object
Returns:

a dict containing info about the course, in the form:

{"task_tried": 0, "total_tries": 0, "task_succeeded": 0, "task_grades":{"task_1": 100.0, "task_2": 0.0, ...}}

Note that only the task already seen at least one time will be present in the dict task_grades.

get_course_caches(usernames, course)[source]
Parameters:
  • username – List of username for which we want info. If usernames is None, data from all users will be returned.
  • course – A Course object
Returns:

Returns data of the specified users for a specific course. users is a list of username.

The returned value is a dict:

{"username": {"task_tried": 0, "total_tries": 0, "task_succeeded": 0, "task_grades":{"task_1": 100.0, "task_2": 0.0, ...}}}

Note that only the task already seen at least one time will be present in the dict task_grades.

get_course_registered_users(course, with_admins=True)[source]

Get all the users registered to a course :param course: a Course object :param with_admins: include admins? :return: a list of usernames that are registered to the course

get_course_user_aggregation(course, username=None)[source]

Returns the classroom whose username belongs to :param course: a Course object :param username: The username of the user that we want to register. If None, uses self.session_username() :return: the classroom description

get_task_cache(username, courseid, taskid)[source]

Shorthand for get_task_caches([username], courseid, taskid)[username]

get_task_caches(usernames, courseid, taskid)[source]
Parameters:
  • usernames – List of username for which we want info. If usernames is None, data from all users will be returned.
  • courseid – the course id
  • taskid – the task id
Returns:

A dict in the form:

{
    "username": {
        "courseid": courseid,
        "taskid": taskid,
        "tried": 0,
        "succeeded": False,
        "grade": 0.0
    }
}

get_user_api_key(username, create=True)[source]

Get the API key of a given user. API keys are generated on demand. :param username: :param create: Create the API key if none exists yet :return: the API key assigned to the user, or None if none exists and create is False.

get_user_email(username)[source]
Parameters:username
Returns:the email of the user if it can be found, None else
get_user_info(username)[source]
Parameters:username
Returns:a tuple (realname, email) if the user can be found, None else
get_user_realname(username)[source]
Parameters:username
Returns:the real name of the user if it can be found, None else
get_users_info(usernames)[source]
Parameters:usernames – a list of usernames
Returns:a dict, in the form {username: val}, where val is either None if the user cannot be found, or a tuple (realname, email)
has_admin_rights_on_course(course, username=None, include_superadmins=True)[source]

Check if a user can be considered as having admin rights for a course :type course: webapp.custom.courses.WebAppCourse :param username: the username. If None, the username of the currently logged in user is taken :param include_superadmins: Boolean indicating if superadmins should be taken into account :return: True if the user has admin rights, False else

has_staff_rights_on_course(course, username=None, include_superadmins=True)[source]

Check if a user can be considered as having staff rights for a course :type course: webapp.custom.courses.WebAppCourse :param username: the username. If None, the username of the currently logged in user is taken :param include_superadmins: Boolean indicating if superadmins should be taken into account :return: True if the user has staff rights, False else

register_auth_method(auth_method)[source]

Registers an authentication method :param auth_method: an AuthMethod object

session_api_key()[source]

Returns the API key for the current user. Created on first demand.

session_auth_storage()[source]

Returns the oauth state for login

session_cookieless()[source]

Indicates if the current session is cookieless

session_email()[source]

Returns the email of the current user in the session, if one is open. Else, returns None

session_id()[source]

Returns the current session id

session_language()[source]

Returns the current session language

session_logged_in()[source]

Returns True if a user is currently connected in this session, False else

session_lti_info()[source]

If the current session is an LTI one, returns a dict in the form {

“email”: email, “username”: username “realname”: realname, “roles”: roles, “task”: (course_id, task_id), “outcome_service_url”: outcome_service_url, “outcome_result_id”: outcome_result_id, “consumer_key”: consumer_key

} where all these data where provided by the LTI consumer, and MAY NOT be equivalent to the data contained in database for the currently connected user.

If the current session is not an LTI one, returns None.

session_realname()[source]

Returns the real name of the current user in the session, if one is open. Else, returns None

session_token()[source]

Returns the token of the current user in the session, if one is open. Else, returns None

session_username()[source]

Returns the username from the session, if one is open. Else, returns None

set_session_language(language)[source]
set_session_realname(realname)[source]

Sets the real name of the current user in the session, if one is open.

set_session_token(token)[source]

Sets the token of the current user in the session, if one is open.

task_can_user_submit(task, username=None, only_check=None, lti=None)[source]

returns true if the user can submit his work for this task :param only_check : only checks for ‘groups’, ‘tokens’, or None if all checks :param lti: indicates if the user is currently in a LTI session or not. - None to ignore the check - True to indicate the user is in a LTI session - False to indicate the user is not in a LTI session - “auto” to enable the check and take the information from the current session

task_is_visible_by_user(task, username=None, lti=None)[source]

Returns true if the task is visible by the user :param lti: indicates if the user is currently in a LTI session or not.

  • None to ignore the check
  • True to indicate the user is in a LTI session
  • False to indicate the user is not in a LTI session
  • “auto” to enable the check and take the information from the current session
update_user_stats(username, task, submission, result_str, grade, state, newsub)[source]

Update stats with a new submission

user_is_superadmin(username=None)[source]
Parameters:username – the username. If None, the username of the currently logged in user is taken
Returns:True if the user is superadmin, False else
user_saw_task(username, courseid, taskid)[source]

Set in the database that the user has viewed this task