// 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/>.
/**
 * Generate course structure in json and POST to EQUELLA
 */
header('Content-Type:text/html;charset=UTF-8');
require_once '../../config.php';
require_once $CFG->dirroot . '/mod/equella/common/lib.php';
require_once $CFG->dirroot . '/mod/equella/locallib.php';
require_login();
$equellaurl = required_param('equellaurl', PARAM_RAW);
$courseid = required_param('courseid', PARAM_INT);
$sectionid = required_param('sectionid', PARAM_INT);
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout('embedded');
$PAGE->requires->js('/mod/equella/module.js', true);
$params = array('courseid' => $courseid, 'equellaurl' => $equellaurl);
$PAGE->set_url('/mod/equella/redirectselection.php', $params);
echo $OUTPUT->header();
$contents = equella_get_course_contents($courseid, $sectionid);
$json = json_encode($contents);
$formid = 'equellaselectionform';
echo html_writer::start_tag('form', array('method' => 'post', 'id' => $formid, 'action' => $equellaurl));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'structure', 'value' => $json));
echo html_writer::end_tag('form');
$PAGE->requires->js_init_call('M.mod_equella.submitform', array($formid), true);
echo $OUTPUT->footer();
Example #2
0
    }
    // Update 'viewed' state if required by completion system
    $completion = new completion_info($course);
    $completion->set_module_viewed($cm);
    echo '<html><body>';
    echo equella_lti_launch_form($equella->url, $params);
    echo '</body></html>';
} elseif ($action == 'select') {
    $args = new stdClass();
    $args->course = required_param('course', PARAM_INT);
    $args->section = required_param('section', PARAM_INT);
    $course = $DB->get_record('course', array('id' => $args->course), '*', MUST_EXIST);
    $context = context_course::instance($args->course);
    $PAGE->set_context($context);
    require_capability('moodle/course:manageactivities', $context);
    $url = equella_build_integration_url($args, false);
    $extraparams = $url->params();
    if ($CFG->equella_action == EQUELLA_ACTION_STRUCTURED) {
        $contents = equella_get_course_contents($course->id, $args->section);
        $json = json_encode($contents);
        $extraparams['structure'] = $json;
    }
    $equella = new stdClass();
    $equella->id = 0;
    $equella->course = $args->course;
    $equella->url = $CFG->equella_url;
    $params = equella_lti_params($equella, $course, $extraparams);
    echo '<html><body>';
    echo equella_lti_launch_form($equella->url, $params);
    echo '</body></html>';
}