</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;
        // Optional.
Пример #2
0
/**
 * Deletes the question usages by activity for an offlinequiz. This function must not be
 * called if the offline quiz has attempts or scanned pages
 *
 * @param object $offlinequiz
 */
function offlinequiz_delete_template_usages($offlinequiz, $deletefiles = true)
{
    global $CFG, $DB, $OUTPUT;
    if ($groups = $DB->get_records('offlinequiz_groups', array('offlinequizid' => $offlinequiz->id), 'number', '*', 0, $offlinequiz->numgroups)) {
        foreach ($groups as $group) {
            if ($group->templateusageid) {
                question_engine::delete_questions_usage_by_activity($group->templateusageid);
                $group->templateusageid = 0;
                $DB->set_field('offlinequiz_groups', 'templateusageid', 0, array('id' => $group->id));
            }
        }
    }
    // Also delete the PDF forms if they have been created.
    if ($deletefiles) {
        return offlinequiz_delete_pdf_forms($offlinequiz);
    } else {
        return $offlinequiz;
    }
}