-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax_view_get_bookslist_noquiz.php
More file actions
47 lines (36 loc) · 1.65 KB
/
ajax_view_get_bookslist_noquiz.php
File metadata and controls
47 lines (36 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php // $Id:,v 2.0 2012/05/20 16:10:00 Serafim Panov
require_once("../../config.php");
require_once("lib.php");
$id = required_param('id', PARAM_INT);
$publisher = optional_param('publisher', NULL, PARAM_CLEAN);
if (!$cm = get_coursemodule_from_id('reader', $id)) {
print_error('invalidcoursemodule');
}
if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
print_error("coursemisconf");
}
if (!$reader = $DB->get_record('reader', array('id' => $cm->instance))) {
print_error('invalidcoursemodule');
}
require_login($course, true, $cm);
add_to_log($course->id, "reader", "Ajax get list of books", "view.php?id=$id", "$cm->instance");
$booksform = array();
if ($publisher) {
$books = $DB->get_records_sql("SELECT * FROM {reader_noquiz} WHERE publisher= ? ORDER BY name", array($publisher));
foreach ($books as $books_) {
$booksform[$books_->id] = "{$books_->name} ({$books_->level})";
}
}
if ($publisher != "Select Publisher") {
if (count($booksform) > 0) {
echo html_writer::start_tag('select', array('size'=>10, 'name'=>'book', 'id'=>'id_book', 'style'=>'width: 500px;', 'multiple'=>'multiple'));
foreach ($booksform as $booksformkey => $booksformvalue) {
echo html_writer::tag('option', $booksformvalue, array('value'=>$booksformkey));
}
echo html_writer::end_tag('select');
} else {
print_string('nobooksinlist', 'reader');
}
} else {
print_string('pleaseselectpublisher', 'reader');
}