codepost_stats.analyzers package
Subpackages
Submodules
codepost_stats.analyzers.pool module
This submodule contains the analyzer pool interface and an implementation.
An analyzer pool is a collection of analyzers, of which the events can be
triggered together by firing an event on the analyzer pool and have it
propagate to every analyzer registered in the pool. The analyzer pool is
the mechanism by which an event loop, such as those implemented in the
codepost_stats.event_loop
submodule, can keep track of analyzers
and how to propagate events to them.
- class codepost_stats.analyzers.pool.AbstractAnalyzerPool
Bases:
object
An abstract interface for an analyzer pool, a collection of analyzer objects, of which the event handlers can be triggered together using
fire_event()
or some inherited method by an event loop.- analyzers()
Returns a list of all analyzers registered with this analyzer pool.
To add an analyzer to this list, use the
register()
method.- Returns
A list of all analyzers registered with this analyzer pool
- Return type
List[BaseAnalyzer]
- fire_event(event_handler_name, arguments=None)
Fires an event throughout all analyzers registed in the pool.
This method takes
event_handler_name
, a string, which is the name of the event handler to trigger in the registered analyzers, such as"_event_course"
to trigger the event handlercodepost_stats.analyzers.abstract.base.BaseAnalyzer._event_course()
.This method also takes
arguments
, an optional dictionary of arguments to pass to the event handler as a**kwargs
argument.To avoid blocking or interrupting the execution of an event loop, the event handlers are called within a try-catch block. When an event handler fails, this is tracked. The final count of event handlers that succeeded and those that failed is returned as a tuple of integers.
- Parameters
event_handler_name (str) – The name of the event handler to trigger
arguments (Optional[dict]) – The dictionary of arguments to provide the event handler
- Returns
A pair reporting how many event triggers were successful and how many failed
- Return type
- items()
Returns a list of all pairs of name and analyzer registered with this analyzer pool.
To add an analyzer to this list, use the
register()
method.- Returns
A list of pairs
(name, analyzer)
of registered analyzers- Return type
List[Tuple[str, BaseAnalyzer]]
- keys()
Returns a list of the names of all analyzers registered with this analyzer pool.
To add an analyzer to this list, use the
register()
method.- Returns
A list of the names of all analyzers registered with this analyzer pool
- Return type
List[str]
- register(analyzer, name=None)
Adds an analyzer to the analyzer pool.
This method adds the provided analyzer to the analyzer pool, optionally, using the name that is provided. If no name is provided, the method while try to use the
BaseAnalyzer.name
attribute; if this attribute is undefined, a random unique name will be generated.Warning
Names must be unique within the analyzer pool. Therefore if two analyzers are registered with the same name, the second will overwrite the first analyzer in this pool.
- Parameters
analyzer (BaseAnalyzer) – The analyzer to add to the pool
name (Optional[str]) – An optional name under which to register the analyzer
- Raises
TypeError – If the provided
analyzer
is not a subclass ofcodepost_stats.analyzers.abstract.base.BaseAnalyzer
.- Return type
NoReturn
- values()
Returns a list of all analyzers registered with this analyzer pool. This function is an alias for the
analyzers()
function.To add an analyzer to this list, use the
register()
method.- Returns
A list of all analyzers registered with this analyzer pool
- Return type
List[BaseAnalyzer]
- class codepost_stats.analyzers.pool.AnalyzerPool
Bases:
AbstractAnalyzerPool
- fire_event_assignment(assignment)
- Parameters
assignment (Assignments) –
- fire_event_comment(assignment, submission, file, comment)
- Parameters
assignment (Assignments) –
submission (Submissions) –
file (Files) –
comment (Comments) –
- fire_event_course(course)
- Parameters
course (Courses) –
- Return type
- fire_event_file(assignment, submission, file)
- Parameters
assignment (Assignments) –
submission (Submissions) –
file (Files) –
- fire_event_reset()
- Return type
- fire_event_submission(assignment, submission)
- Parameters
assignment (Assignments) –
submission (Submissions) –
- class codepost_stats.analyzers.pool.SuccessFailurePairType(success=0, failure=0)
Bases:
tuple
A helper type to report the number of event firings that were successful or a failure, when triggering events using an analyzer pool.
- Parameters
success (int) –
failure (int) –
- property failure
Number of event firings that have failed.
- property success
Number of event firings that have succeeded.
codepost_stats.analyzers.standard module
This submodule contains standard analyzers for codePost data, representing the typical kind of statistics that a codePost instructor might want to collect. In addition, the code of these analyzers may provide a good starting base for authoring new analyzers.
- class codepost_stats.analyzers.standard.CustomCommentsCounter
Bases:
GenericCommentsCounter
An analyzer class to count the number of custom comments created (ignoring any comment that is tied to a rubric comment), for each assignment, by each grader.
This class extends
GenericCommentsCounter
, and contains all the capabilities of its parent class, in particular in terms of restricting comments by their character, word length or authorship.
- class codepost_stats.analyzers.standard.GenericCommentsCounter
Bases:
CounterAnalyzer
An analyzer class to count the number of comments created, for each assignment, by each grader.
This class has a number of properties to restrict which comments are included in the tally—depending on the number of characters, words, or whether the comment was authored by the grader of the submission.
The subclasses
CustomCommentsCounter
andRubricCommentsCounter
illustrate how to further restrict the kind of comments that are counted.In terms of counter storage, the
name
is the author of a comment and thesubcat
is the assignment name. Submissions will be ignored if they are not assigned to a grader, or if they are not yet finalized.- property min_characters: Optional[int]
Gets or sets the minimum number of characters threshold, under which a comment will be ignored. To remove this threshold, set this property to
None
.- Return type
Optional[int]
- property min_words: Optional[int]
Gets or sets the minimum number of words threshold, under which a comment will be ignored. To remove this threshold, set this property to
None
.Note
If
s
is the string representing the text of the comment, the number of words is computed using the Python expressionlen(s.split())
.- Return type
Optional[int]
- property only_graders: bool
Gets and sets a flag that indicates whether to ignore any comment of which the author is not the same as the grader of the submission (this may be the case if a course instructor or administrator has added a comment to a submission that may have been graded by someone else, for instance).
- Return type
bool
- class codepost_stats.analyzers.standard.RubricCommentsCounter
Bases:
GenericCommentsCounter
An analyzer class to count the number of comments created that are linked to a rubric comment (ignoring any custom comment), for each assignment, by each grader.
This class extends
GenericCommentsCounter
, and contains all the capabilities of its parent class, in particular in terms of restricting comments by their character, word length or authorship.
- class codepost_stats.analyzers.standard.SubmissionsGradedCounter
Bases:
CounterAnalyzer
An analyzer class to count the number of submissions graded, for each assignment, by each grader.
In terms of counter storage, the
name
is the grader and thesubcat
is the assignment name. Submissions will be ignored if they are not assigned to a grader, or if they are not yet finalized.
Module contents
The codepost_stats.analyzers
submodule contains all the logic
related to analyzers.
This includes:
The analyzer interfaces,
AbstractAnalyzer
andBaseAnalyzer
, are defined in thecodepost_stats.analyzers.abstract.base
submodule;Some generic high-level implementations of analyzers, such as
DictStorageAnalyzer
to define an analyzer that collects information in a nested dictionary, or such asCounterAnalyzer
which is an even more specialized analyzer that keeps track of integer counts, are defined in thecodepost_stats.analyzers.abstract.simple
submodule;Some examples of fully-implemented analyzers, such as
SubmissionsGradedCounter
orGenericCommentsCounter
, are available from thecodepost_stats.analyzers.standard
submodule;The interface and an implementation of analyzer pools is defined in the
codepost_stats.analyzers.pool
submodule.
The most important part of the codebase are the implementations of analyzers in the
codepost_stats.analyzers.standard
submodule: These provide good examples
from which to generate new analyzers.