openlab-at-city-tech / webworkqa

WeBWorK integration for WordPress and BuddyPress
GNU General Public License v2.0
4 stars 2 forks source link

BP activity stream integration #65

Open boonebgorges opened 8 years ago

boonebgorges commented 8 years ago

When activity occurs on the WW site, the following should happen:

The latter is now implemented on openlab.citytech.cuny.edu, though in a fashion that won't work for the distributed plugin. Here's the code:

+
/**
 * Update the associated group's last_activity when new content is posted.
 */
function openlab_webwork_bump_group_on_activity( $post_id ) {
        // We do this weird parsing because the request comes from the API,
        // and we need to maintain compat with openlabdev.org.
        $client_site_url = apply_filters( 'webwork_client_site_base', '' );
        $parts = parse_url( $client_site_url );
        $site = get_site_by_path( $parts['host'], $parts['path'] );
        if ( ! $site ) {
                return;
        }

        $group_id = openlab_get_group_id_by_blog_id( $site->blog_id );
        if ( ! $group_id ) {
                return;
        }

        groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
}
add_action( 'save_post_webwork_question', 'openlab_webwork_bump_group_on_activity' );
add_action( 'save_post_webwork_response', 'openlab_webwork_bump_group_on_activity' )

General activity integration will have to be group-sensitive based on whatever group-linking protocol we decide on.

moui72 commented 7 years ago

I don't think this belongs to the Fall 2017 milestone.

boonebgorges commented 7 years ago

Agreed :+1: