Difference between revisions of "Features/Activity specific metadata in Journal"

From Sugar Labs
Jump to navigation Jump to search
Line 20: Line 20:
  
 
== Detailed Description ==
 
== Detailed Description ==
 +
 +
The Journal has a fixed set of metadata entries that are displayed in the Journal detail view for all entries, e.g., 'description', 'tags', 'preview', et al. It is proposed that we also include activity-specific metadata. For example, when assessing student work, it is of interest to teachers to know what tools a student may have used and, perhaps how many iterations a student made in creating an artifact. These data may vary from activity to activity, hence it is proposed to enhance the Journal Expanded View in a way that enables activities to specify which metadata fields would be useful to display.
 +
 +
The proposed mechanism is two-fold: (1) a special metadata field, 'public' is used to list those metadata fields that should be displayed; and (2) a new text field is added to the Expanded View to display these data. In the illustration above, two fields are displayed: Iterations and Block Types. These fields were set by the Turtle Art program. Other activities may set other fields (or no fields, in which case, the new text field would not be shown.)
 +
 +
<pre>
 +
# In the Turtle Art activity write_file method, the public metadata entry is set
 +
self.metadata['public'] = data_to_string([_('activity count'),
 +
                                          _('turtle blocks')])
 +
 +
# In expandedentry.py, the public fields are displayed
 +
 +
        activity_box, self._public_data = self._create_public_data()
 +
        second_column.append(activity_box)
 +
    ...
 +
 +
    if 'public' in self._metadata:
 +
        public_data = self._public_data.text_view_widget
 +
        activity_list = simplejson.loads(self._metadata['public'])
 +
        text = ''
 +
        for tag in activity_list:
 +
            logging.debug(tag)
 +
            text += '%s: %s\n' % (tag, str(metadata.get(tag, '')))
 +
        public_data.props.buffer.props.text = text
 +
 +
 +
    def _create_public_data(self):
 +
        vbox = hippo.CanvasBox()
 +
        vbox.props.spacing = style.DEFAULT_SPACING
 +
 +
        text = hippo.CanvasText(text=_('Activity Data:'),
 +
                                font_desc=style.FONT_NORMAL.get_pango_desc())
 +
        text.props.color = style.COLOR_BUTTON_GREY.get_int()
 +
 +
        if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
 +
            text.props.xalign = hippo.ALIGNMENT_END
 +
        else:
 +
            text.props.xalign = hippo.ALIGNMENT_START
 +
 +
        vbox.append(text)
 +
 +
        text_view = CanvasTextView('',
 +
                box_height=style.GRID_CELL_SIZE)
 +
        vbox.append(text_view, hippo.PACK_EXPAND)
 +
 +
        text_view.text_view_widget.props.accepts_tab = False
 +
        text_view.text_view_widget.connect('focus-out-event',
 +
                self._tags_focus_out_event_cb)
 +
 +
        return vbox, text_view
 +
</pre>
  
 
== Benefit to Sugar ==
 
== Benefit to Sugar ==

Revision as of 17:39, 11 November 2011



Summary

The idea is to record metadata related to the use of activity and display it in the detail view of the Journal.

TAtags.png

Owner

Current status

  • Targeted release: 0.96
  • Last updated:
  • Percentage of completion: 90%

Detailed Description

The Journal has a fixed set of metadata entries that are displayed in the Journal detail view for all entries, e.g., 'description', 'tags', 'preview', et al. It is proposed that we also include activity-specific metadata. For example, when assessing student work, it is of interest to teachers to know what tools a student may have used and, perhaps how many iterations a student made in creating an artifact. These data may vary from activity to activity, hence it is proposed to enhance the Journal Expanded View in a way that enables activities to specify which metadata fields would be useful to display.

The proposed mechanism is two-fold: (1) a special metadata field, 'public' is used to list those metadata fields that should be displayed; and (2) a new text field is added to the Expanded View to display these data. In the illustration above, two fields are displayed: Iterations and Block Types. These fields were set by the Turtle Art program. Other activities may set other fields (or no fields, in which case, the new text field would not be shown.)

# In the Turtle Art activity write_file method, the public metadata entry is set
self.metadata['public'] = data_to_string([_('activity count'),
                                           _('turtle blocks')])

# In expandedentry.py, the public fields are displayed

        activity_box, self._public_data = self._create_public_data()
        second_column.append(activity_box)
    ...

    if 'public' in self._metadata:
        public_data = self._public_data.text_view_widget
        activity_list = simplejson.loads(self._metadata['public'])
        text = ''
        for tag in activity_list:
            logging.debug(tag)
            text += '%s: %s\n' % (tag, str(metadata.get(tag, '')))
        public_data.props.buffer.props.text = text


    def _create_public_data(self):
        vbox = hippo.CanvasBox()
        vbox.props.spacing = style.DEFAULT_SPACING

        text = hippo.CanvasText(text=_('Activity Data:'),
                                font_desc=style.FONT_NORMAL.get_pango_desc())
        text.props.color = style.COLOR_BUTTON_GREY.get_int()

        if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
            text.props.xalign = hippo.ALIGNMENT_END
        else:
            text.props.xalign = hippo.ALIGNMENT_START

        vbox.append(text)

        text_view = CanvasTextView('',
                box_height=style.GRID_CELL_SIZE)
        vbox.append(text_view, hippo.PACK_EXPAND)

        text_view.text_view_widget.props.accepts_tab = False
        text_view.text_view_widget.connect('focus-out-event',
                self._tags_focus_out_event_cb)

        return vbox, text_view

Benefit to Sugar

Scope

How To Test

Features/Activity specific metadata in Journal/Testing

User Experience

Dependencies

No new dependencies

Contingency Plan

Documentation

Release Notes

Comments and Discussion