You are here

function qformat_coursetestmanager::getquestions in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/question/format/coursetestmanager/format.php \qformat_coursetestmanager::getquestions()
1 call to qformat_coursetestmanager::getquestions()
qformat_coursetestmanager::importprocess in includes/moodle/question/format/coursetestmanager/format.php
Process the file This method should not normally be overidden

File

includes/moodle/question/format/coursetestmanager/format.php, line 301

Class

qformat_coursetestmanager

Code

function getquestions($filename, $category, $mdapath = "", $hostname = "") {
  if ($category == "allcategories" or $category == "") {
    $sql = "SELECT * FROM TBQuestions";
  }
  else {
    $sql = "SELECT * FROM TBQuestions where module = '" . $category . "'";
  }
  if (PHP_OS == "WINNT") {
    $ldb =& $this
      ->connect_win($filename);
    $qset = $ldb
      ->Execute("{$sql}");
    if (!$qset->EOF) {
      $records = $qset
        ->GetAssoc(true);
    }
    else {
      $this
        ->err("There were no records in the database.", $dsn);
      $ldb
        ->Close();
      return false;
    }
    $ldb
      ->Close();
  }
  else {

    // if PHP_OS == WINNT
    // we have a linux installation
    $result = $this
      ->query_linux($sql, $filename, $mdapath, $hostname);
    if (count($result) > 0) {

      // get rid of the ID field in the first column.
      for ($i = 0; $i < count($result); $i++) {
        foreach (array_keys($result[$i]) as $j) {
          $records[$i][$j - 1] = $result[$i][$j];
        }
      }
    }
    else {
      $this
        ->err("There were no records in the database.", $dsn);
      $ldb
        ->Close();
      return false;
    }

    // xml test and connect
  }

  // PHP_OS TEST
  return $records;
}