// // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Prints a particular instance of qa. * * @package mod_qa * @copyright 2015 Skylar Kelty <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // Replace qa with the name of your module and remove this line. require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once dirname(__FILE__) . '/lib.php'; $id = required_param('id', PARAM_INT); list($course, $cm) = get_course_and_cm_from_cmid($id, 'qa'); $qa = \mod_qa\qa::from_id($cm->instance); require_login($course, true, $cm); $event = \mod_qa\event\course_module_viewed::create(array('objectid' => $PAGE->cm->instance, 'context' => $PAGE->context)); $event->add_record_snapshot('course', $PAGE->course); $event->add_record_snapshot('qa', $qa->get_data()); $event->trigger(); // Print the page header. $PAGE->set_url('/mod/qa/view.php', array('id' => $cm->id)); $PAGE->set_title(format_string($qa->name)); $PAGE->set_heading(format_string($course->fullname)); $PAGE->requires->css('/mod/qa/styles.css'); $PAGE->requires->js_call_amd('mod_qa/view', 'init', array()); // Output starts here. echo $OUTPUT->header(); echo $OUTPUT->heading($qa->name); // Conditions to show the intro can change to look for own settings or whatever.
// // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Prints a particular instance of qa. * * @package mod_qa * @copyright 2015 Skylar Kelty <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // Replace qa with the name of your module and remove this line. require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once dirname(__FILE__) . '/lib.php'; $qaid = required_param('qaid', PARAM_INT); list($course, $cm) = get_course_and_cm_from_instance($qaid, 'qa'); $qa = \mod_qa\qa::from_id($qaid); require_login($course, true, $cm); require_capability('mod/qa:submit', $PAGE->context); // Print the page header. $PAGE->set_url('/mod/qa/ask.php', array('qaid' => $qaid)); $PAGE->navbar->add(get_string('askquestion', 'mod_qa')); $PAGE->set_title(format_string($qa->name)); $PAGE->set_heading(format_string($course->fullname)); // Form handling. $form = new \mod_qa\forms\post_question($qa); if ($form->is_cancelled()) { redirect(new \moodle_url('/mod/qa/view.php', array('id' => $cm->id))); } if ($data = $form->get_data()) { $question = $qa->post_question($data->name, $data->desc, isset($data->anon) ? $data->anon : 0); $data = $question->get_data();