コード例 #1
0
 /**
  * Test of courses query.
  *
  * @return void
  */
 public function test_coursesquery()
 {
     global $CFG;
     require_once $CFG->dirroot . '/report/ncccscensus/lib.php';
     $data = $this->createdata();
     $results = report_ncccscensus_course_search('noresults', array());
     $this->assertEquals(count($results), 1);
     $this->assertEquals($results[0]['name'], "No matches found for: noresults");
     $results = report_ncccscensus_course_search('course', array());
     $this->assertEquals(4, count($results));
     $results = report_ncccscensus_course_search('course', array(array('id' => $data['category3']->id)));
     $this->assertEquals(2, count($results));
     $courses = array();
     foreach ($results as $course) {
         array_push($courses, $course['name']);
     }
     $this->assertTrue(in_array('Test course 4', $courses));
 }
コード例 #2
0
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Returns list of teachers matching query.
 *
 * @package   report_ncccscensus
 * @author    Remote-Learner.net Inc
 * @copyright 2014 Remote Learner - http://www.remote-learner.net/
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once '../../config.php';
require_once 'lib.php';
require_once $CFG->dirroot . '/lib/coursecatlib.php';
require_login();
$context = context_system::instance();
require_capability('report/ncccscensus:view', $context);
$query = required_param('q', PARAM_RAW);
$callback = required_param('callback', PARAM_RAW);
$categoryquery = json_decode(required_param('c', PARAM_RAW), true);
$categorysql = "";
$time = usertime(time(), get_user_timezone());
$results = report_ncccscensus_course_search($query, $categoryquery);
$json = json_encode($results);
header('Content-Type: application/javascript');
echo "{$callback}({$json})";