Я создаю плагин типа поиска слова в Moodle для своего клиента и пытаюсь использовать этот код в плагине типа деятельности Moodle.
Источник: https://ourcodeworld.com/articles/read/274/how-to-create-a-wordfind-game-soup-of-letters-in-the-browser-easily-using-javascript
, но проблема в том, что здесь показано
"ReferenceError: wordfindgame не определено"
?>
require_once(dirname(__FILE__).'/../../config.php');
global $CFG,$PAGE;
$id = optional_param( 'id', null, PARAM_INT );
if ($id) {
if (!$cm = get_coursemodule_from_id('cryptext', $id)) {
print_error('invalidcoursemodule');
}
if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
print_error('coursemisconf');
}
}
require_login($course, false, $cm);
$PAGE->set_url($CFG->wwwroot.'/mod/cryptext/view.php',array('id' => $cm->id));
$context = context_module::instance($cm->id);
$PAGE->set_title('Cryptext Activity');
$PAGE->set_heading($course->fullname);
$PAGE->set_context($context); //context_system::instance()
//$PAGE->set_context(context_module::instance($id));
$PAGE->set_pagelayout('incourse');
$PAGE->requires->css($CFG->dirroot.'/mod/cryptext/style/wordfind.css');
echo $OUTPUT->header();
<div id="puzzle-container"></div>
<div id="puzzle-words"></div>
<input type="button" id="solveBTN" value="Solve puzzle"/>
<script>
// An array with the words to show
var words = ['cows', 'tracks', 'arrived', 'located', 'sir', 'seat',
'division', 'effect', 'underline', 'view', 'annual',
'anniversary', 'centennial', 'millennium', 'perennial',
'artisan', 'apprentice', 'meteorologist', 'blizzard', 'tornado',
'intensify','speed','count','consonant','someone',
'sail','rolled','bear','wonder','smiled','angle', 'absent',
'decadent', 'excellent', 'frequent', 'impatient', 'cell',
'cytoplasm', 'organelle', 'diffusion', 'osmosis',
'respiration'
];
// Start a basic word game without customization !
var gamePuzzle = wordfindgame.create(words, '#puzzle-container', '#puzzle-words');
$("#solveBTN").click(function(){
// Solve the puzzle !
var result = wordfindgame.solve(gamePuzzle, words);
console.log(result);
});
</script>
<?php
$PAGE->requires->js( new moodle_url($CFG->wwwroot . '/mod/cryptext/javascript/wordfind.js') );
$PAGE->requires->js( new moodle_url($CFG->wwwroot . '/mod/cryptext/javascript/wordfindgame.js') );
echo $OUTPUT->footer();
ReferenceError: wordfindgame не определено [Узнать больше] view.php: 716: 17
Я включил wordfid.js и wordfindgame.js, и я пошел наИсходный код страницы и щелкнул ссылку на файл JS, который показал содержимое файла в браузере.Было бы очень полезно, если бы кто-то мог помочь мне в решении этой проблемы, спасибо заранее.