Example #1
0
    /**
     * Defines forms elements
     */
    public function definition() {
        global $CFG, $DB, $USER, $PAGE;
        $PAGE->requires->js('/mod/mapletadp/js/jquery-2.1.4.js');
        $PAGE->requires->js('/mod/mapletadp/js/dependency_assignments.js');

        $mform = $this->_form;


        // Adding the "general" fieldset, where all the common settings are showed.
        $mform->addElement('header', 'general', get_string('general', 'form'));

        // Adding the standard "name" field.
        $mform->addElement('text', 'name', get_string('mapletadpname', 'mapletadp'), array('size' => '64'));
        if (!empty($CFG->formatstringstriptags)) {
            $mform->setType('name', PARAM_TEXT);
        } else {
            $mform->setType('name', PARAM_CLEANHTML);
        }
        $mform->addRule('name', null, 'required', null, 'client');
        $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
        $mform->addHelpButton('name', 'mapletadpname', 'mapletadp');

        // Adding the standard "intro" and "introformat" fields.
        if ($CFG->branch >= 29) {
            $this->standard_intro_elements();
        } else {
            $this->add_intro_editor();
        }

        // Adding the rest of mapletadp settings, spreading all them into this fieldset
        // ... or adding more fieldsets ('header' elements) if needed for better logic.
        $controllerData = new \mod_mapletadp\controller\MapleData($DB, $CFG, $USER);
        $classesListDB = $controllerData->getClassesForForm();
        $classesListZero = array(0 => get_string('choose', 'mapletadp'));
        $classes = array_merge($classesListZero, $classesListDB);
        $select = $mform->addElement('select', 'classId', get_string('className', 'mapletadp'), $classes);
        $mform->addRule('classId', null, 'required', null, 'client');
        $mform->addRule('classId', get_string('selectClass', 'mapletadp'), 'nonzero', null, 'client');
        if (isset($this->current->classid)) {
            $select->setSelected($this->current->classid);
        }
        $assignments = $controllerData->getAllAssignmentsForForm();
        $select2 = $mform->addElement('select', 'assignmentId', get_string('assignmentName', 'mapletadp'), $assignments);
        $mform->addRule('assignmentId', null, 'required', null, 'client');
        $mform->addRule('assignmentId', get_string('selectAssignment', 'mapletadp'), 'nonzero', null, 'client');
        if (isset($this->current->assignmentid)) {
            $select2->setSelected($this->current->assignmentid);
        }
        // Add standard grading elements.
        $this->standard_grading_coursemodule_elements();

        // Add standard elements, common to all modules.
        $this->standard_coursemodule_elements();

        // Add standard buttons, common to all modules.
        $this->add_action_buttons();
    }
Example #2
0
$PAGE->set_title(format_string($mapletadp->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->requires->js('/mod/mapletadp/js/jquery-2.1.4.js');


// Output starts here.
echo $OUTPUT->header();

// Conditions to show the intro can change to look for own settings or whatever.
if ($mapletadp->intro) {
    echo $OUTPUT->box(format_module_intro('mapletadp', $mapletadp, $cm->id), 'generalbox mod_introbox', 'mapletadpintro');
}

if (isset($mapletadp)) {
    $controller = new mod_mapletadp\controller\Mapleta($DB, $CFG, $USER);
    $controllerData = new mod_mapletadp\controller\MapleData($DB, $CFG, $USER);
    $assignment = $controllerData->getAssignments($mapletadp->classid, $mapletadp->assignmentid);
    $launcherModel = new mod_mapletadp\model\Launcher($DB, $CFG);
    //var_dump($assignment);


    echo $OUTPUT->heading($assignment->name);
    echo $launcherModel->startAssignmentForm($assignment, $course->id);
    if ($run) {
        echo "<b>" . get_string('waitplease', 'mapletadp') . "</b>";
        $PAGE->requires->js('/mod/mapletadp/js/start_assignment.js');
    } else {
        $PAGE->requires->js('/mod/mapletadp/js/create_assignment_popup.js');
        echo "<div><table cellspacing='0' class='flexible generaltable generalbox'>";
        echo "<tr><td>".get_string('mode', 'mapletadp')."</td><td> ".get_string('mode'.$assignment->mode, 'mapletadp'). "</td></tr>";
        echo "<tr><td>".get_string('totalpoints', 'mapletadp')."</td><td>". $assignment->totalpoints. "</td></tr>";
<?php
/**
 * obsluhuje ajax pozadavky filtru s cilovymi skupinami
 */
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/lib.php');
require_login();
global $DB, $USER, $CFG;
$controller=new \mod_mapletadp\controller\MapleData($DB, $CFG, $USER);
if(!empty($_GET)){
	// vyfiltrovani uzivatele
	if(!empty($_GET['classID'])){
		$filtered_data=$controller->getAssignmentsForForm($_GET['classID']);
		echo json_encode($filtered_data);
	}
	else{
		echo json_encode(array('none'));
	}
}