user = $user;
}
public function getSpellingWord() {
$difficulty = $this->difficulty();
$question = e107::getDb()->retrieve("SELECT `word`,`usage`, IFNULL(`cnt`,'0') AS Ncnt FROM
(SELECT `word`,`usage` FROM e107.e107_tk_wordList WHERE `year` <= '".ceil($difficulty)."' AND `usage` != '') AS wList LEFT JOIN
(SELECT `answer`,COUNT(`answer`)AS `cnt` FROM e107.e107_tkReport
WHERE `answereddatestamp` > unix_timestamp((NOW()) - INTERVAL 1 MONTH) AND `username` = '".$this->user."'
AND `subject` = 'spelling' GROUP BY `answer` ORDER BY COUNT(`answer`)) AS Ans
ON wList.`word` = Ans.`answer` ORDER BY IFNULL(`cnt`,'0'), RAND() LIMIT 1;");
$questionHtml = $this->spellingHtml($question);
e107::getDb()->insert('tkLastQuestion', ['user'=>$this->user,'LastQuestionHtml'=>base64_encode($questionHtml)]);
e107::getRender()->tablerender('Spelling', $questionHtml);
}
/**
* Create a spelling form using the supplied question.
* And write it into "$this->returnQuestion".
*
* @param array() $data Question data to be used.
*/
private function spellingHtml($data) {
$tp = e107::getParser();
$frm = e107::getForm();
$fString = $frm->open('questionForm', 'post', '', ['autocomplete' => 'off', 'class' => 'formclass']);
$fString .= $frm->label('