diff --git a/bookquiz/importodt.php b/bookquiz/importodt.php deleted file mode 100755 index 28f3e72..0000000 --- a/bookquiz/importodt.php +++ /dev/null @@ -1,749 +0,0 @@ -. - -/** - * This is a very rough importer for odt - * - * The script supports book - * Is based on class office from http://www.phpclasses.org/browse/package/2586.html - * - * @version $Id: importodt.php,v 1.5 2012/07/25 11:16:04 bdaloukas Exp $ - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * @package game - **/ - -require_once("../../../config.php"); -require_once( "../header.php"); -require_once("../locallib.php"); - -$subchapter = optional_param('subchapter', '', PARAM_ALPHA); -$overwrite = optional_param('overwrite', 0, PARAM_INT); -$attempt = game_getattempt( $game, $detail); -$bookid = $game->bookid; -if ($bookid == 0) { - print_error( get_string( 'bookquiz_not_select_book', 'game')); -} - -if ($form = data_submitted()) { - // Filename. - if (empty($_FILES['newfile'])) { - // File was just uploaded. - notify(get_string("uploadproblem") ); - } - - if ((!is_uploaded_file($_FILES['newfile']['tmp_name']) or $_FILES['newfile']['size'] == 0)) { - notify(get_string("uploadnofilefound") ); - } else { - // Valid file is found. - if (readdata( $course->id, 'game', $dirtemp, $rlevels, $rtitles, $rtexts, $dirfordelete)) { - // First try to reall all of the data in. - if ($overwrite) { - game_bookquiz_deletebook( $course->id, $bookid); - } - // Parse all the html files into objects. - $pageobjects = extract_data( $course->id, 'book', $bookid, $dirtemp, $subchapter, $rlevels, $rtitles, $rtexts); - clean_temp( $dirfordelete); // All done with files so dump em. - - // Function to preps the data to be sent to DB. - $objects = game_bookquiz_create_objects( $pageobjects, $bookid); - - if (!game_bookquiz_save_objects( $objects)) { - // Sends it to DB. - print_error('could not save'); - } - } else { - print_error('could not get data'); - } - - print_continue("{$CFG->wwwroot}/mod/game/view.php?id=$cm->id"); - echo $OUTPUT->footer($course); - exit; - } -} - -// Print upload form. - - print_heading_with_help( get_string( "bookquiz_import_odt", "game"), "importodt", "game"); - - echo $OUTPUT->box_start('center'); -?> -
- box_end(); - - echo $OUTPUT->footer($course); - -// START OF FUNCTIONS. - -// The rbasedir variable contains the directory where the temp files are. -// At the end the directory must be deleted. -function readdata( $courseid, $modname, &$rbasedir, &$rlevels, &$rtitles, &$rtexts, &$dirfordelete) { - // This function expects a odt file to be uploaded. Then it parses the content.xml to determine. - // Then copies the images. - global $CFG; - - // Create a random upload directory in temp. - $newdir = $CFG->dataroot."/temp/$modname"; - if (!file_exists( $newdir)) { - mkdir( $newdir); - } - - $i = 1; - srand((double)microtime() * 1000000); - while (true) { - $rbasedir = "$modname/$i-".rand(0, 10000); - $newdir = $CFG->dataroot.'/temp/'.$rbasedir; - if (!file_exists( $newdir)) { - mkdir( $newdir); - $newdir .= '/'; - break; - } - $i++; - } - $dirfordelete = $rbasedir; - $rbasedir .= '/'; - - $zipfile = $_FILES["newfile"]["name"]; - $tempzipfile = $_FILES["newfile"]["tmp_name"]; - - // Creates our directory. - $pathparts = pathinfo($zipfile); - // Takes off the extension. - $dirname = substr($zipfile, 0, strpos($zipfile, '.'.$pathparts['extension'])); - if (!file_exists($newdir.$dirname)) { - mkdir($newdir.$dirname); - } - - // Move our uploaded file to temp/game. - move_uploaded_file( $tempzipfile, $newdir.$zipfile); - - // If the file ends with .lnk then use .odt instead. - if (substr( $zipfile, -4) == ".lnk") { - $zipfile = substr( $zipfile, 0, -4).".odt"; - } - - // Unzip it! - unzip_file ( $newdir.$zipfile, $newdir.$dirname, false); - - $rbasedir .= $dirname; // Update the base. - $newdir .= $dirname; - - // This is the file where we get the names of the files for the slides (in the correct order too). - $content = $newdir.'/content.xml'; - $data = file_get_contents( $content); - - $content = $newdir.'/styles.xml'; - if (file_exists( $content)) { - $datastyle = file_get_contents( $content); - } else { - $datastyle = ''; - } - - oo_game_convert_ver2( $data, $datastyle, $rlevels, $rtitles, $rtexts); - - return true; -} - -function oo_game_convert_ver2( $data, $datastyle, &$rlevels, &$rtitles, &$rtexts) { - $rlevels = array(); - $rtitles = array(); - $rtexts = array(); - - // We have tables, encode it here so all'.$content.'
'; - - $chapter->content = addslashes( $content); - - $chapters[] = $chapter; - } - - return $chapters; -} - -// Save the chapter objects to the database. -function game_bookquiz_save_objects($chapters) { - global $DB; - - // Nothing fancy, just save them all in order. - foreach ($chapters as $chapter) { - if (!$newid = $DB->insert_record('book_chapters', $chapter)) { - print_error('Could not insert to table book_chapters'); - } - } - - return true; -} - -// Splits the data to. -function game_bookquiz_splitsections($data, &$positions, &$inputs, &$titles, &$titleframes, &$texts) { - preg_match_all('#'.game_bookquiz_convert_text( $text, $styles).'
'; - $data = str_replace( $originals[ $i], $new, $data); - } - } - - // Repairs text:span text:style-name. - preg_match_all( '#', $table);
- }
-
- // Maybe there are a lot of pictures inside a table.
- preg_match_all('#xlink:href="Pictures/([a-z.A-Z_0-9]*)"#es', $table, $repl);
- foreach ($repl[ 1] as $picture) {
- $table = str_replace(' |
tags around each element and strip out \n which I have found to be uneccessary. - foreach ($pageobject->contents as $content) { - $content = str_replace("\n", '', $content); - $content = str_replace("\r", '', $content); - $content = str_replace(' ', '', $content); // Puts in returns? - $content = '
'.$content.'
'; - $page->contents .= addslashes($content); - } - return $page; -} - -// Save the chapter objects to the database. -function book_save_objects($chapters, $bookid, $pageid='0') { - global $DB; - - // Nothing fancy, just save them all in order. - foreach ($chapters as $chapter) { - if (!$chapter->id = $DB->insert_record('book_chapters', $chapter)) { - print_error('Could not update your book'); - } - } - return true; -} diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php index 3ba2ef7..57fb2b9 100644 --- a/classes/event/course_module_instance_list_viewed.php +++ b/classes/event/course_module_instance_list_viewed.php @@ -36,18 +36,5 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { - /** - * Create the event from course record. - * - * @param \stdClass $course - * @return course_module_instance_list_viewed - */ - public static function create_from_course(\stdClass $course) { - $params = array( - 'context' => \context_course::instance($course->id) - ); - $event = \mod_game\event\course_module_instance_list_viewed::create( $params); - $event->add_record_snapshot('course', $course); - return $event; - } + // No code required here as the parent class handles it all. } diff --git a/lib.php b/lib.php index 38ee320..c7a6054 100755 --- a/lib.php +++ b/lib.php @@ -539,7 +539,9 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course $groupjoin = ""; } - if (!$attempts = $DB->get_records_sql("SELECT qa.*, qa.gameid, q.grade, u.lastname,u.firstname, firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.lastnamephonetic, u.picture + if (!$attempts = $DB->get_records_sql("SELECT qa.*, qa.gameid, q.grade, u.lastname,". + " u.firstname, firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename,". + " u.lastnamephonetic, u.picture FROM {game_attempts} qa JOIN {game} q ON q.id = qa.gameid JOIN {user} u ON u.id = qa.userid @@ -604,7 +606,7 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course $tmpactivity->user->alternatename = $attempt->alternatename; $tmpactivity->user->middlename = $attempt->middlename; $tmpactivity->user->firstnamephonetic = $attempt->firstnamephonetic; - $tmpactivity->user->lastnamephonetic = $attempt->lastnamephonetic; + $tmpactivity->user->lastnamephonetic = $attempt->lastnamephonetic; $tmpactivity->user->picture = $attempt->picture; $tmpactivity->user->imagealt = $attempt->imagealt; $tmpactivity->user->email = $attempt->email; @@ -619,7 +621,6 @@ function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames echo '"; - //print_user_picture($activity->user->userid, $courseid, $activity->user->picture); echo $OUTPUT->user_picture($activity->user, array('courseid' => $courseid)); echo " | ";
@@ -636,7 +637,8 @@ function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames
echo get_string("attempt", "game")." {$activity->content->attempt}: ";
$grades = "({$activity->content->sumgrades} / {$activity->content->maxgrade})";
- echo "wwwroot}/mod/game/review.php?attempt={$activity->content->attemptid}&q={$activity->gameid}\">$grades";
+ echo "wwwroot}/mod/game/review.php".
+ "?attempt={$activity->content->attemptid}&q={$activity->gameid}\">$grades";
echo '';
echo ' ';
diff --git a/locallib.php b/locallib.php
index f734401..b37fc8c 100755
--- a/locallib.php
+++ b/locallib.php
@@ -1489,7 +1489,7 @@ function game_grade_responses( $question, $responses, $maxgrade, &$answertext, &
return $answer->fraction * $maxgrade;
} else {
$name = "resp{$question->id}_";
- if( !isset( $responses->$name)) {
+ if (!isset( $responses->$name)) {
$answered = false;
return 0; // Not answered this question.
}
@@ -1818,14 +1818,27 @@ function game_get_string_lang( $identifier, $module, $lang) {
$langfile = "{$CFG->dirroot}/mod/game/lang/$lang/game.php";
- if ($result = get_string_from_file( $identifier, $langfile, "\$ret")) {
- eval($result);
- if ($ret != '') {
- return $ret;
+ $result = get_string_from_file( $identifier, $langfile, "\$ret");
+ if ($result != '') {
+ $pos = strpos( $result, '=');
+ if ($pos > 0) {
+ $result = substr( $result, $pos + 1);
+ $pos = strpos( $result, "'");
+ if ($pos > 0) {
+ $result = substr( $result, $pos + 1);
+ $pos = strpos( $result, "'");
+ if ($pos > 0) {
+ $result = substr( $result, 0, $pos);
+ }
+ }
}
}
- return get_string( $identifier, $module);
+ if ($result != '') {
+ return $result;
+ } else {
+ return get_string( $identifier, $module);
+ }
}
function get_string_from_file($identifier, $langfile, $destination) {
diff --git a/millionaire/play.php b/millionaire/play.php
index 401c61d..d0825a3 100755
--- a/millionaire/play.php
+++ b/millionaire/play.php
@@ -172,7 +172,7 @@ function game_millionaire_showgrid( $game, $millionaire, $id, $query, $aanswer,
$styletext = "style='$stylequestion'";
}
- $aval = array( 100, 200, 300, 400, 500, 1000, 1500, 2000, 4000, 5000, 10000, 20000, 40000, 80000, 150000);
+ $aval = array( 100, 200, 300, 400, 500, 1000, 1500, 2000, 4000, 5000, 10000, 20000, 40000, 80000, 150000);
for ($i = 15; $i >= 1; $i--) {
$btr = false;
diff --git a/pagelib.php b/pagelib.php
index c379428..90b93f9 100755
--- a/pagelib.php
+++ b/pagelib.php
@@ -21,8 +21,6 @@ define('PAGE_GAME_VIEW', 'mod-game-view');
page_map_class( PAGE_GAME_VIEW, 'page_game');
-$DEFINEDPAGES = array( PAGE_GAME_VIEW);
-
/**
* Class that models the behavior of a game
*
diff --git a/showanswers.php b/showanswers.php
index 6c6cf55..eb33ee6 100755
--- a/showanswers.php
+++ b/showanswers.php
@@ -307,7 +307,6 @@ function game_showanswers_question_select( $game, $table, $select, $fields, $ord
foreach ($recs as $rec) {
if ($i++ > 0) {
echo ' '; - if ($rec->fraction == 1) { echo " $rec->answer"; if ($rec->feedback == '') { diff --git a/showattempts.php b/showattempts.php index a425c84..223ce4e 100755 --- a/showattempts.php +++ b/showattempts.php @@ -73,7 +73,7 @@ function game_showusers($game) { function onselectuser() { var groupid = document.getElementById('menugroup').value; - window.location.href = "" + document.getElementById('menuuser').value + '&groupid=' + groupid; + window.location.href = "" + document.getElementById('menuuser').value + '&groupid='+groupid; } dobject($thevalue, $thehtmlflag); } else { $theoutput[$theindex] = ($thehtmlflag ? preg_replace('|<|s', '<', var_export($thevalue, true)) : var_export($thevalue, true)); @@ -244,9 +244,9 @@ class sdd { foreach ($theclassvars[$theclass] as $thevariable => $value) { if (array_key_exists($thevariable, $theobjectvars)) { if (is_array($theobjectvars[$thevariable])) { - $theoutput[$theclass][] = $thevariable . " = " . sdd::darray($theobjectvars[$thevariable], $thehtmlflag); + $theoutput[$theclass][] = $thevariable . " = " .$this->darray($theobjectvars[$thevariable], $thehtmlflag); } else if (is_object($theobjectvars[$thevariable])) { - $theoutput[$theclass][] = $thevariable . " = " . sdd::dobject($theobjectvars[$thevariable], $thehtmlflag); + $theoutput[$theclass][] = $thevariable . " = ".$this->dobject($theobjectvars[$thevariable], $thehtmlflag); } else { $theotput[$theclass][] = $thevariable . " = " . ($thehtmlflag ? preg_replace('|<|s', '<', var_export( diff --git a/sudoku/sdd/class.logfile.php b/sudoku/sdd/class.logfile.php index 0735376..32ed65e 100755 --- a/sudoku/sdd/class.logfile.php +++ b/sudoku/sdd/class.logfile.php @@ -47,7 +47,7 @@ class logfile extends SDD { * @access public */ - public function logfile($thefilename) { + public function init($thefilename) { if (file_exists($thefilename)) { $this->m_handle = fopen($thefilename, 'a'); } else { |