} echo $msg; break; case "create_course": if (!confirm_sesskey()) { throw new moodle_exception('invalidsesskey', 'error'); } if (has_capability('moodle/course:create', context_system::instance())) { $tiicoursename = optional_param('tii_course_name', get_string('defaultcoursetiititle', 'turnitintooltwo'), PARAM_TEXT); $coursecategory = optional_param('course_category', 0, PARAM_INT); $tiicourseid = optional_param('tii_course_id', 0, PARAM_INT); $coursename = urldecode(optional_param('course_name', '', PARAM_TEXT)); if (empty($coursename)) { $coursename = get_string('defaultcoursetiititle', 'turnitintooltwo') . " (" . $tiicourseid . ")"; } $course = turnitintooltwo_assignment::create_moodle_course($tiicourseid, urldecode($tiicoursename), $coursename, $coursecategory); $newcourse = array('courseid' => $course->id, 'coursename' => $course->fullname); echo json_encode($newcourse); } else { throw new moodle_exception('nopermissions', 'error', '', get_string('course:create', 'role')); } break; case "link_course": if (!confirm_sesskey()) { throw new moodle_exception('invalidsesskey', 'error'); } if (has_capability('moodle/course:update', context_system::instance())) { $tiicoursename = optional_param('tii_course_name', get_string('defaultcoursetiititle', 'turnitintooltwo'), PARAM_TEXT); $tiicourseid = optional_param('tii_course_id', 0, PARAM_INT); $coursetolink = optional_param('course_to_link', 0, PARAM_INT); $turnitincourse = new stdClass();