fccn / nau-openedx-extensions

0 stars 1 forks source link

Add filter to block students to obtain certificate #42

Closed igobranco closed 4 days ago

igobranco commented 7 months ago

From the internal ticket: https://plataforma-nau.atlassian.net/browse/FAN-107


Add a new filter that allows to block the students to obtain course certificate if the proctoring services are enabled on the course. This is needed for the course team to be able to check if any irregular activities were reported by the proctoring system.

Add a flag on STUDIO > Advanced settings > Other course settings

If the flag is true, then execute more code. Alternatively, if the key to the service is set in other course settings and the course is instructor paced activate this feature.

I think we should include the openedx_filters.learning.filters.CertificateCreationRequested filter available since Open edX Release Olive, on the NAU Open edX Lilac branch.

https://github.com/openedx/openedx-filters/blob/f61c59988f9a5d50dcb4cbcfe1d122ab05eb97f9/openedx_filters/learning/filters.py#L122

The custom code would be implemented by NAU. Nevertheless we need that eduNEXT send us a code block to be called by this code, that allow us to find all course activities in a course for an user of a specific type (SMOWL xblock).

Arguments:

Output:

Then for each list of activities for the course and user, we would call the SMOWL API and verify if the user is ok on all the activities. If not raise an error and disallow the certificate emission. There should also be a way to communicate this with the user, via a message on the progress tab.

This would be NAU responsibility to implement.


from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.django import modulestore
from django.contrib.auth import get_user_model
from lms.djangoapps.course_blocks.api import get_course_blocks
User = get_user_model()
def get_activities_ids(user_id, course_id, xblock_type):
    """function that returns the identifiers of the 
    blocks corresponding to the type of xblock consulted.
    Arguments:
    user_id -- User's integer identifier
    course_id -- String representation of the course to be consulted
    xblock_type -- String representation of the xblock to be consulted
    Returns:
        xblock_keys - A list of block_id corresponding to the xblock_type
    """
    xblock_keys =[]
    user = User.objects.get(id=user_id)
    course_key = CourseKey.from_string(course_id)
    course_usage_key = modulestore().make_course_usage_key(course_key)
    course_blocks = get_course_blocks(user, course_usage_key)
    block_keys = course_blocks.get_block_keys()
    for block_key in block_keys:
        if xblock_type in str(block_key):
            xblock_keys.append(block_key)
    return xblock_keys
# Example data
course_id = 'course-v1:org+id+run'
user_id = 4
xblock_type = 'scorm'
scorms = get_activities_ids(user_id, course_id, xblock_type)
print(scorms)
igobranco commented 4 days ago

Closing this issue, because we aren't using too muck proctoring of SMOWL.