General developer forum

Activity data not deleting from module plugin table

 
Picture of Zuheb Zub
Activity data not deleting from module plugin table
 

I am new to moodle plugin development, am creating new activity plugin (mod), when i am deleting the modlule from course section data from table is not deleting. 

this is the delete module instance function. 

function newmodule_delete_instance($id) {

global $DB;

$newmodule= $DB->get_record('table1', array('id' => $id), '*', MUST_EXIST);

    if (!$newmodule) {

        return false;

    }

    // Delete any dependent records here.

    $DB->delete_records('table1', array('id' => $newmodule->id));

    $DB->delete_records('table2', array('labid' => $newmodule->id));

    newmodule_grade_item_delete($newmodule);

    return true;

}


I tried with moodles default activity modules there also data is not deleting from tables. i tried URL, Folder activity modules, after deleting from course section data is not deleting from db table.


Regards

Zub




 
Average of ratings: -
Picture of Andreas Grabs
Re: Activity data not deleting from module plugin table
Core developersParticularly helpful MoodlersPlugin developersTranslators

Hi Zub,

you have to run the cron at least once after deleting an activity.

Andreas

 
Average of ratings: Useful (1)
Picture of Zuheb Zub
Re: Activity data not deleting from module plugin table
 

Hello Andreas 

Thank you for your reply, may i know which cron to run, i have no idea about crons in moodle. i am new to moodle.

Zub

 
Average of ratings: -
Picture of Andreas Grabs
Re: Activity data not deleting from module plugin table
Core developersParticularly helpful MoodlersPlugin developersTranslators

Hi,

just the regular cron which you also need if you want to send forum email for example.
Take a look at: https://docs.moodle.org/34/en/Cron

Best regards
Andreas


 
Average of ratings: Useful (1)