|
@ -16,6 +16,14 @@ |
|
|
// You should have received a copy of the GNU General Public License |
|
|
// You should have received a copy of the GNU General Public License |
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* CrossDB class |
|
|
|
|
|
* |
|
|
|
|
|
* @package mod_game |
|
|
|
|
|
* @copyright 2007 Vasilis Daloukas |
|
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die(); |
|
|
defined('MOODLE_INTERNAL') || die(); |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
@ -28,6 +36,14 @@ defined('MOODLE_INTERNAL') || die(); |
|
|
defined('MOODLE_INTERNAL') || die(); |
|
|
defined('MOODLE_INTERNAL') || die(); |
|
|
|
|
|
|
|
|
class CrossDB extends Cross { |
|
|
class CrossDB extends Cross { |
|
|
|
|
|
/** |
|
|
|
|
|
* Save cross. |
|
|
|
|
|
* |
|
|
|
|
|
* @param stdClass $game |
|
|
|
|
|
* @param array $crossm |
|
|
|
|
|
* @param array $crossd |
|
|
|
|
|
* @param int $id |
|
|
|
|
|
*/ |
|
|
public function savecross( $game, &$crossm, $crossd, $id) { |
|
|
public function savecross( $game, &$crossm, $crossd, $id) { |
|
|
global $DB, $USER; |
|
|
global $DB, $USER; |
|
|
|
|
|
|
|
@ -58,6 +74,11 @@ class CrossDB extends Cross { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Delete records. |
|
|
|
|
|
* |
|
|
|
|
|
* @param int $id |
|
|
|
|
|
*/ |
|
|
public function delete_records( $id) { |
|
|
public function delete_records( $id) { |
|
|
global $DB; |
|
|
global $DB; |
|
|
|
|
|
|
|
@ -70,6 +91,23 @@ class CrossDB extends Cross { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Load cross. |
|
|
|
|
|
* |
|
|
|
|
|
* @param $g |
|
|
|
|
|
* @param boolean $done |
|
|
|
|
|
* @param string $html |
|
|
|
|
|
* @param stdClass $game |
|
|
|
|
|
* @param stdClass $attempt |
|
|
|
|
|
* @param stdClass $crossrec |
|
|
|
|
|
* @param boolean $onlyshow |
|
|
|
|
|
* @param boolean $showsolution |
|
|
|
|
|
* @param finishattempt |
|
|
|
|
|
* @param boolean $htmlsolutions |
|
|
|
|
|
* @param string $language |
|
|
|
|
|
* @param boolean $showstudentguess |
|
|
|
|
|
* @param stdClass $context |
|
|
|
|
|
*/ |
|
|
public function loadcross( $g, &$done, &$html, $game, $attempt, $crossrec, $onlyshow, $showsolution, |
|
|
public function loadcross( $g, &$done, &$html, $game, $attempt, $crossrec, $onlyshow, $showsolution, |
|
|
&$finishattempt, $showhtmlsolutions, &$language, $showstudentguess, $context) { |
|
|
&$finishattempt, $showhtmlsolutions, &$language, $showstudentguess, $context) { |
|
|
global $DB; |
|
|
global $DB; |
|
@ -133,6 +171,19 @@ class CrossDB extends Cross { |
|
|
return $info; |
|
|
return $info; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Compute check. |
|
|
|
|
|
* |
|
|
|
|
|
* @param int $correctletters |
|
|
|
|
|
* @param int $wrongletters |
|
|
|
|
|
* @param $restletters |
|
|
|
|
|
* @param stdClass $game |
|
|
|
|
|
* @param stdClass $attempt |
|
|
|
|
|
* @param boolean $done |
|
|
|
|
|
* @param boolean $onlyshow |
|
|
|
|
|
* @param boolean $showsolution |
|
|
|
|
|
* @param boolean $finishattempt |
|
|
|
|
|
*/ |
|
|
public function game_cross_computecheck( $correctletters, $wrongletters, $restletters, $game, |
|
|
public function game_cross_computecheck( $correctletters, $wrongletters, $restletters, $game, |
|
|
$attempt, &$done, $onlyshow, $showsolution, $finishattempt) { |
|
|
$attempt, &$done, $onlyshow, $showsolution, $finishattempt) { |
|
|
|
|
|
|
|
@ -189,7 +240,20 @@ class CrossDB extends Cross { |
|
|
return $ret; |
|
|
return $ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Rec is a record of cross_questions. |
|
|
/** |
|
|
|
|
|
* Update cross questions. |
|
|
|
|
|
* |
|
|
|
|
|
* @param stdClass $rec (is a record of cross_questions). |
|
|
|
|
|
* @param $g |
|
|
|
|
|
* @param $pos |
|
|
|
|
|
* @param int $correctletters |
|
|
|
|
|
* @param int $wrongletters |
|
|
|
|
|
* @param int $restletters |
|
|
|
|
|
* @param stdClass $game |
|
|
|
|
|
* @param stdClass $attempt |
|
|
|
|
|
* @param stdClass $crossrec |
|
|
|
|
|
* @param boolean loadfromdb |
|
|
|
|
|
*/ |
|
|
public function updatecrossquestions( &$rec, &$g, &$pos, &$correctletters, &$wrongletters, |
|
|
public function updatecrossquestions( &$rec, &$g, &$pos, &$correctletters, &$wrongletters, |
|
|
&$restletters, $game, $attempt, $crossrec, $loadfromdb) { |
|
|
&$restletters, $game, $attempt, $crossrec, $loadfromdb) { |
|
|
|
|
|
|
|
|