## General developer forum

### Obtain number of activities completed by the user.

Obtain number of activities completed by the user.

Hello, I am making a restriction based on the percentage of activities that the student has done.

Ex: If the student has more than 75% of completed activities, you can see the resource.

The fact is that I have almost completed it but I can not get the number of activities completed by the student. The total number of activities if I have it.
Thank you very much in advance,

Average of ratings: -
Re: Obtain number of activities completed by the user.
$completioninfo = new completion_info($course);
$all = count($completioninfo->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY));
$cnt = 0; foreach ($completioninfo->get_completions($user->id, COMPLETION_CRITERIA_TYPE_ACTIVITY) as$completion) {
if ($completion->is_complete()) {$cnt++;
}
}

Average of ratings: -
Re: Obtain number of activities completed by the user.

Thank you very much, in the end it worked for me inspiring me in that function.

Average of ratings: -