can't update activity_completion

can't update activity_completion

by 仲威 蘇 -
Number of replies: 2

hi,I create a custom completion rules, and i want try set completion function,

So,I put this code in view.php

$completion = new completion_info($course);
$completion->update_state($cm, COMPLETION_COMPLETE);

but, it's doesn't work,did I miss something?

Average of ratings: -
In reply to 仲威 蘇

Re: can't update activity_completion

by Benjamin Ellis -
Picture of Particularly helpful Moodlers
Do both the course and the module have completion criteria?
In reply to Benjamin Ellis

回應: Re: can't update activity_completion

by 仲威 蘇 -
there is i add code

in the mod_from_php

public function add_completion_rules() {
    $mform =& $this->_form;
    $mform->addElement('checkbox', 'completionvideoview', '', get_string('completionvideoview', 'streamming'));
     // Enable this completion rule by default.
    $mform->setDefault('completionvideoview', 1);
    return array('completionvideoview');
}
public function completion_rule_enabled($data) {
    return !empty($data['completionvideoview']);
}

and i add this in lib.php

function streamming_supports($feature) {
    switch($feature) {
        case FEATURE_COMPLETION_HAS_RULES: return true;
        default: return null;
    }
}

and i want to try force activity completion using api

i add this code in view.php

$completion = new completion_info($course);
$completion->update_state($cm, COMPLETION_COMPLETE);

but it's does not work

can you help me how to fix this, did i missing something?