Exemple #1
0
}
$dialogBox = new DialogBox();
/*
 * Execute commands
 */
// use question in exercise
if ($cmd == 'rqUse' && !is_null($quId) && !is_null($exId)) {
    if ($exercise->addQuestion($quId)) {
        // TODO show confirmation and back link
        header('Location: ' . Url::Contextualize('edit_exercise.php?exId=' . $exId));
    }
}
// delete question
if ($cmd == 'delQu' && !is_null($quId)) {
    $question = new Question();
    if ($question->load($quId)) {
        if (!$question->delete()) {
            // TODO show confirmation and list
        }
    }
}
// export question
if ($cmd == 'exExport' && get_conf('enableExerciseExportQTI')) {
    require_once '../export/qti2/qti2_export.php';
    require_once get_path('incRepositorySys') . '/lib/fileManage.lib.php';
    require_once get_path('incRepositorySys') . '/lib/file.lib.php';
    require_once get_path('incRepositorySys') . '/lib/thirdparty/pclzip/pclzip.lib.php';
    $question = new Qti2Question();
    $question->load($quId);
    // contruction of XML flow
    $xml = $question->export();
Exemple #2
0
}
if (isset($_REQUEST['exId']) && is_numeric($_REQUEST['exId'])) {
    $exId = (int) $_REQUEST['exId'];
} else {
    $exId = null;
}
if (isset($_REQUEST['quId']) && is_numeric($_REQUEST['quId'])) {
    $quId = (int) $_REQUEST['quId'];
} else {
    $quId = null;
}
/*
 * Init other vars
 */
$question = new Question();
if (is_null($quId) || !$question->load($quId)) {
    header('Location: ' . Url::Contextualize('../exercise.php'));
    exit;
}
if (!is_null($exId)) {
    $exercise = new Exercise();
    // if exercise cannot be load set exId to null , it probably don't exist
    if (!$exercise->load($exId)) {
        $exId = null;
    }
}
$askDuplicate = false;
// do not duplicate when there is no $exId, it means that we modify the question from pool
// do not duplicate when there is no $quId, it means that question is a new one
// check that question is used in several exercises
if (count_exercise_using_question($quId) > 1 && !is_null($quId) && !is_null($exId)) {
/**
 * @return string csv data or empty string
 */
function export_question_tracking($quId, $exId = '')
{
    $question = new Question();
    if (!$question->load($quId)) {
        return "";
    }
    switch ($question->getType()) {
        case 'TF':
            $csvTrack = new CsvTrackTrueFalse($question, $exId);
            break;
        case 'MCUA':
        case 'MCMA':
            $csvTrack = new CsvTrackMultipleChoice($question, $exId);
            break;
        case 'FIB':
            $csvTrack = new CsvTrackFIB($question, $exId);
            break;
        case 'MATCHING':
            $csvTrack = new CsvTrackMatching($question, $exId);
            break;
        default:
            break;
    }
    if (isset($csvTrack)) {
        $csvTrack->buildRecords();
        return $csvTrack->export();
    } else {
        return "";
    }
}
Exemple #4
0
        }
        unset($questionObj);
    }
} elseif (isset($loadRandomQuestionsList) && is_array($loadRandomQuestionsList)) {
    $questionList = array();
    if (isset($loadRandomQuestionsList['questions']) && is_array($loadRandomQuestionsList['questions'])) {
        $questions = $loadRandomQuestionsList['questions'];
    } elseif (is_array($loadRandomQuestionsList)) {
        $questions = $loadRandomQuestionsList;
    } else {
        $questions = array();
    }
    foreach ($questions as $question) {
        $questionObj = new Question();
        $questionObj->setExerciseId($exId);
        if ($questionObj->load($question['id'])) {
            $_SESSION['serializedQuestionList'][] = serialize($questionObj);
            $questionList[] = $questionObj;
        }
    }
} else {
    $questionList = array();
    foreach ($_SESSION['serializedQuestionList'] as $serializedQuestion) {
        $questionList[] = unserialize($serializedQuestion);
    }
}
$questionCount = count($questionList);
$now = time();
if (!isset($_SESSION['exeStartTime'])) {
    if ($startExercise) {
        $_SESSION['exeStartTime'] = $now;
Exemple #5
0
}
if (isset($_REQUEST['exId']) && is_numeric($_REQUEST['exId'])) {
    $exId = (int) $_REQUEST['exId'];
} else {
    $exId = null;
}
if (isset($_REQUEST['quId']) && is_numeric($_REQUEST['quId'])) {
    $quId = (int) $_REQUEST['quId'];
} else {
    $quId = null;
}
/*
 * Init other vars
 */
$question = new Question();
if (!is_null($quId) && !$question->load($quId)) {
    // question cannot be load, display new question creation form
    $cmd = 'rqEdit';
    $quId = null;
}
if (!is_null($exId)) {
    $exercise = new Exercise();
    // if exercise cannot be load set exId to null , it probably don't exist
    if (!$exercise->load($exId)) {
        $exId = null;
    }
}
$askDuplicate = false;
// quId and exId have been specified and load operations worked
if (!is_null($quId) && !is_null($exId)) {
    // do not duplicate when there is no $exId,
Exemple #6
0
$titleTab['mainTitle'] = $nameTools;
// Command list
$cmdList = array();
$cmdList[] = array('img' => 'back', 'name' => get_lang('Back'), 'url' => claro_htmlspecialchars(Url::Contextualize('./track_exercises.php?exId=' . $exId . $src)));
$out .= claro_html_tool_title($titleTab, null, $cmdList);
// build back link
$backLink = "\n\n" . '<a class="backLink" href="' . claro_htmlspecialchars(Url::Contextualize('./track_exercises.php?exId=' . $exId . $src)) . '">' . get_lang('Back') . '</a>' . "\n\n";
if ($is_allowedToTrack && get_conf('is_trackingEnabled')) {
    $out .= "\n" . '<table width="100%" border="0" cellpadding="1" cellspacing="0" class="claroTable">' . "\n";
    if (count($questionIdsToShow) > 1) {
        $questionIterator = 1;
    }
    foreach ($questionIdsToShow as $questionId) {
        // get infos about the question
        $question = new Question();
        if (!$question->load($questionId)) {
            break;
        }
        // prepare list to display
        if ($question->getType() == 'MCUA' || $question->getType() == 'MCMA') {
            // get the list of all possible answer and the number of times it was choose
            $sql = "SELECT `TEA`.`answer`, COUNT(`TEA`.`answer`) as `nbr`\n                        FROM `" . $tbl_qwz_tracking . "` AS `TE`\n                    LEFT JOIN `" . $tbl_qwz_tracking_questions . "` AS `TED`\n                        ON `TED`.`exercise_track_id` = `TE`.`id`\n                    LEFT JOIN `" . $tbl_qwz_tracking_answers . "` AS `TEA`\n                        ON `TEA`.`details_id` = `TED`.`id`\n                    WHERE `TED`.`question_id` = " . (int) $questionId . "\n                        AND `TE`.`exo_id` = " . (int) $exId . "\n                    GROUP BY `TEA`.`answer`";
            $trackedAnswers = claro_sql_query_fetch_all($sql);
            // we need to know the total number of answer given
            $multipleChoiceTotal = 0;
            $i = 0;
            foreach ($question->answer->answerList as $answer) {
                $results[$i] = $answer;
                $results[$i]['nbr'] = 0;
                foreach ($trackedAnswers as $trackedAnswer) {
                    if ($results[$i]['answer'] == $trackedAnswer['answer']) {