コード例 #1
0
                    </div>
	             </form>
            </div>
            <?php 
            }
            echo $OUTPUT->box_end();
        }
        // End if (!$completedresults.
        $fs = get_file_storage();
        // Delete the PDF forms if forcepdfnew and if there are no scanned pages yet.
        if ($forcepdfnew) {
            if ($hasscannedpages) {
                print_error('Some answer forms have already been analysed', "createquiz.php?q={$offlinequiz->id}&amp;mode=createpdfs&amp;sesskey=" . sesskey());
            } else {
                // Redmine 2750: Always delete templates as well.
                offlinequiz_delete_template_usages($offlinequiz);
                $offlinequiz = offlinequiz_delete_pdf_forms($offlinequiz);
                $doctype = 'PDF';
                if ($offlinequiz->fileformat == OFFLINEQUIZ_DOCX_FORMAT) {
                    $doctype = 'DOCX';
                }
                $params = array('context' => $context, 'other' => array('offlinequizid' => $offlinequiz->id, 'reportname' => $mode, 'doctype' => $doctype));
                $event = \mod_offlinequiz\event\docs_deleted::create($params);
                $event->trigger();
            }
        }
        // Options for the popup_action.
        $options = array();
        $options['height'] = 1200;
        // Optional.
        $options['width'] = 1170;
コード例 #2
0
/**
 * Given an ID of an instance of this module,
 * this function will permanently delete the instance
 * and any data that depends on it.
 *
 * @param int $id Id of the module instance
 * @return boolean Success/Failure
 */
function offlinequiz_delete_instance($id)
{
    global $DB, $CFG;
    require_once $CFG->dirroot . '/mod/offlinequiz/locallib.php';
    require_once $CFG->dirroot . '/calendar/lib.php';
    if (!($offlinequiz = $DB->get_record('offlinequiz', array('id' => $id)))) {
        return false;
    }
    if (!($cm = get_coursemodule_from_instance("offlinequiz", $offlinequiz->id, $offlinequiz->course))) {
        return false;
    }
    $context = context_module::instance($cm->id);
    // Delete any dependent records here.
    if ($results = $DB->get_records("offlinequiz_results", array('offlinequizid' => $offlinequiz->id))) {
        foreach ($results as $result) {
            offlinequiz_delete_result($result->id, $context);
        }
    }
    if ($scannedpages = $DB->get_records('offlinequiz_scanned_pages', array('offlinequizid' => $offlinequiz->id))) {
        foreach ($scannedpages as $page) {
            offlinequiz_delete_scanned_page($page, $context);
        }
    }
    if ($scannedppages = $DB->get_records('offlinequiz_scanned_p_pages', array('offlinequizid' => $offlinequiz->id))) {
        foreach ($scannedppages as $page) {
            offlinequiz_delete_scanned_p_page($page, $context);
        }
    }
    if ($events = $DB->get_records('event', array('modulename' => 'offlinequiz', 'instance' => $offlinequiz->id))) {
        foreach ($events as $event) {
            $event = calendar_event::load($event);
            $event->delete();
        }
    }
    if ($plists = $DB->get_records('offlinequiz_p_lists', array('offlinequizid' => $offlinequiz->id))) {
        foreach ($plists as $plist) {
            $DB->delete_records('offlinequiz_participants', array('listid' => $plist->id));
            $DB->delete_records('offlinequiz_p_lists', array('id' => $plist->id));
        }
    }
    // Remove the grade item.
    offlinequiz_grade_item_delete($offlinequiz);
    // Delete template question usages of offlinequiz groups.
    offlinequiz_delete_template_usages($offlinequiz);
    // All the tables with no dependencies...
    $tablestopurge = array('offlinequiz_groups' => 'offlinequizid', 'offlinequiz' => 'id');
    foreach ($tablestopurge as $table => $keyfield) {
        if (!$DB->delete_records($table, array($keyfield => $offlinequiz->id))) {
            $result = false;
        }
    }
    return true;
}
コード例 #3
0
 * @package       mod
 * @subpackage    offlinequiz
 * @author        Juergen Zimmer <*****@*****.**>
 * @copyright     2015 Academic Moodle Cooperation {@link http://www.academic-moodle-cooperation.org}
 * @since         Moodle 2.8
 * @license       http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once __DIR__ . '/../../config.php';
require_once $CFG->dirroot . '/mod/offlinequiz/locallib.php';
require_once $CFG->dirroot . '/mod/offlinequiz/offlinequiz.class.php';
$cmid = required_param('cmid', PARAM_INT);
$offlinequizid = required_param('offlinequizid', PARAM_INT);
$offlinegroupid = required_param('offlinegroupid', PARAM_INT);
$slotnumber = required_param('slot', PARAM_INT);
$repagtype = required_param('repag', PARAM_INT);
require_sesskey();
$offlinequizobj = offlinequiz::create($offlinequizid, $offlinegroupid);
$group = $DB->get_record('offlinequiz_groups', array('id' => $offlinegroupid));
require_login($offlinequizobj->get_course(), false, $offlinequizobj->get_cm());
require_capability('mod/offlinequiz:manage', $offlinequizobj->get_context());
if (offlinequiz_has_scanned_pages($offlinequizid)) {
    $reportlink = offlinequiz_attempt_summary_link_to_reports($offlinequizobj->get_offlinequiz(), $offlinequizobj->get_cm(), $offlinequizobj->get_context());
    throw new \moodle_exception('cannoteditafterattempts', 'offlinequiz', new moodle_url('/mod/offlinequiz/edit.php', array('cmid' => $cmid)), $reportlink);
}
$slotnumber++;
$repage = new \mod_offlinequiz\repaginate($offlinequizid, $offlinegroupid);
$repage->repaginate_slots($slotnumber, $repagtype);
offlinequiz_delete_template_usages($offlinequizobj->get_offlinequiz());
$structure = $offlinequizobj->get_structure();
$slots = $structure->refresh_page_numbers_and_update_db($structure->get_offlinequiz());
redirect(new moodle_url('edit.php', array('cmid' => $offlinequizobj->get_cmid(), 'groupnumber' => $group->number)));