Skip to content
Max Willembrinck edited this page Dec 9, 2022 · 3 revisions

Load the baseline

... in a new Pharo 9.0 image as instructed in the README

Metacello new
    baseline: 'OCDbgAnalysis';
    repository: 'github://Pharo-XP-Tools/OCDbgAnalysis:main';
    load.

Exporting JSON example

Short version: use the #asJSON method (mostly).

Doing this:

(ParticipantResult 
   newFromData: 
      (OCDbgEvents loadDataFromPath: '/Users/maxw/Documents/ocrex1pilot/User-a1eff302-b2a0-0d00-b9ea-48310c48fda453911402438000')
   withUserID:  'User-a1eff302-b2a0-0d00-b9ea-48310c48fda453911402438000') asJSON

Will produce the following JSON:

{
	"tasks" : [
		{
			"taskInfo" : {
				"title" : "Task 1"
			},
			"breakpointsAdded" : 4,
			"breakpointsHit" : 3,
			"breakpointsRemoved" : 4,
			"ocBreakpointsAdded" : 0,
			"ocBreakpointsHit" : 0,
			"ocBreakpointsRemoved" : 0,
			"stepActions" : 29,
			"order" : 1,
			"duration" : "0:00:33:41.505125"
		},
		{
			"taskInfo" : {
				"title" : "Tutorial"
			},
			"breakpointsAdded" : 0,
			"breakpointsHit" : 0,
			"breakpointsRemoved" : 0,
			"ocBreakpointsAdded" : 2,
			"ocBreakpointsHit" : 4,
			"ocBreakpointsRemoved" : 2,
			"stepActions" : 39,
			"order" : 2,
			"duration" : "0:00:13:47.212501"
		},
		{
			"taskInfo" : {
				"title" : "Warmup task 1"
			},
			"breakpointsAdded" : 1,
			"breakpointsHit" : 3,
			"breakpointsRemoved" : 1,
			"ocBreakpointsAdded" : 1,
			"ocBreakpointsHit" : 1,
			"ocBreakpointsRemoved" : 0,
			"stepActions" : 9,
			"order" : 3,
			"duration" : "0:00:09:32.989074"
		},
		{
			"taskInfo" : {
				"title" : "Warmup task 2"
			},
			"breakpointsAdded" : 1,
			"breakpointsHit" : 1,
			"breakpointsRemoved" : 2,
			"ocBreakpointsAdded" : 0,
			"ocBreakpointsHit" : 0,
			"ocBreakpointsRemoved" : 0,
			"stepActions" : 7,
			"order" : 4,
			"duration" : "0:00:03:45.593268"
		},
		{
			"taskInfo" : {
				"title" : "Task 2"
			},
			"breakpointsAdded" : 0,
			"breakpointsHit" : 0,
			"breakpointsRemoved" : 0,
			"ocBreakpointsAdded" : 0,
			"ocBreakpointsHit" : 0,
			"ocBreakpointsRemoved" : 0,
			"stepActions" : 66,
			"order" : 5,
			"duration" : "0:00:20:54.439057"
		}
	],
	"participant" : {
		"id" : "'User-a1eff302-b2a0-0d00-b9ea-48310c48fda453911402438000'"
	}
}

Exporting collections is also supported

{"First participant results"
(ParticipantResult 
   newFromData: 
      (OCDbgEvents loadDataFromPath: '/Users/maxw/Documents/ocrex1pilot/User-a1eff302-b2a0-0d00-b9ea-48310c48fda453911402438000')
   withUserID:  'User-a1eff302-b2a0-0d00-b9ea-48310c48fda453911402438000') .
"Second participant results"
(ParticipantResult 
   newFromData: 
      (OCDbgEvents loadDataFromPath: '/Users/maxw/Documents/ocrex1pilot/User-a1eff302-b2a0-0d00-b9ea-anotherID')
   withUserID:  'User-a1eff302-b2a0-0d00-b9ea-anotherID') } asJSON
"Exports a json list with the results"

Dev Notes

The classes that are exported to the JSON are the ones from the OCDbgAnalysis-ExportModel package.

The main class is ParticipantResult. There should be one per participant experience. ParticipantResult contains a list of all the task statistics and surveys.

Another important class is TaskStats. TaskStats is the structure that holds the metrics for a given task (of a participant). Most of the instance variable corresponds to these metrics, and they are exported into the JSON.

Extracting metrics

When a TaskStats object is created from the data, it executes all MetricExtractors to fill its instance variables. This means that an object of every subclass of MetricExtractor is instantiated and the extraction logic is executed. (See subclasses of MetricExtractor for examples).

The MetricExtractor subclasses-based implementation keeps the constructor of TaskStats simple, and it is easy to extend and maintain.

Adding more metrics and exporting

To add a new metric:

  1. Add the instance variable to TaskStats for such metric and generate accessors.
  2. Copy one of the subclasses of MetricExtractor, and rewrite its methods, ensuring that the #targetField matches the instance variable slot name.

Done!

New instance variables are not automatically added to the JSON.

To include the variable in the JSON the field must be included in the class side method: TaskStats>>#neoJsonMapping: (See it to see the examples).

Clone this wiki locally