Obtain if feedback exist or no

Re: Obtain if feedback exist or no

by Andreas Grabs -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

Hi Daniel,

you have some typos in your code.Please try this one:

$existFeedback = false;
$feedbackName = 'feedback1'; //"feedback1" is the name of one feedback in my course that exist
$feedbacks = get_all_instances_in_course("feedback",$course);
foreach ($feedbacks as $feedback) {
    if($feedbackName == $feedback->name){
        $existFeedback = true;
    }
}

echo $existFeedback;

To find such typos you should switch on the debugging all the time you try some new code.

Best regards
Andreas