$msg = "";
 if ($idQuestion) {
     $question = $webgdCommunityDao->searchQuestionByCommunityById($idQuestion);
     $question->name = $data->nome;
     $question->enabled = $data->enable;
     $question->startdate = DateTime::createFromFormat('d-m-Y', str_replace("/", "-", $data->from))->getTimestamp();
     $question->enddate = DateTime::createFromFormat('d-m-Y', str_replace("/", "-", $data->to))->getTimestamp();
     $attQuestion = $mform->get_new_filename('attachmentQuestion');
     $random = rand();
     $name = $random . '_' . $attQuestion;
     $pathAttQuestion = "{$CFG->dataroot}/webgd_community/{$name}";
     if ($mform->save_file('attachmentQuestion', $pathAttQuestion, true)) {
         $question->attachmentQuestion = $pathAttQuestion;
     }
     //Deleta todos os videos atuais e insere os novos que sobraram
     $webgdCommunityDao->deleteAskQuestionByCommunity($question->id);
     $correrVideos = 0;
     foreach ($data->video as $video) {
         $perguntaQuestao = new stdClass();
         $perguntaQuestao->name_question = $data->pergunta[$correrVideos];
         $perguntaQuestao->video = $video;
         $perguntaQuestao->question = $question->id;
         $DB->insert_record(TableResouces::$TABLE_PAGE_COMMUNITY_ANSWER_QUESTION, $perguntaQuestao);
         $correrVideos++;
     }
     $msg = "Ocorreu um erro ao editar a enquete";
     if ($DB->update_record(TableResouces::$TABLE_PAGE_COMMUNITY_QUESTION, $question)) {
         $msg = "Enquete editada com sucesso";
     }
 } else {
     $attQuestion = $mform->get_new_filename('attachmentQuestion');