Exemple #1
0
 function main()
 {
     $bl = new Backlog();
     echo '<pre>';
     $bl->success('message success 1');
     $bl->debug('message debug 1');
     $bl->failure('message failure 1');
     $bl->success('message success 2');
     $bl->info('message info 1');
     var_dump($bl->size());
     var_dump($bl->_size);
     echo '</pre>';
     echo '<pre>';
     echo $bl->output();
     echo '</pre>';
     echo 'Append';
     echo '<pre>';
     $bl->append($bl);
     echo $bl->output();
     echo '</pre>';
 }
Exemple #2
0
/**
 * parse an xml file to find info
 *
 * @param string $exercisePath
 * @param string $file dirname of question in zip file
 * @param string $questionFile name of xml file in zip file
 * @return array( backlog, boolean )
 */
function parse_file($exercisePath, $file, $questionFile)
{
    global $exercise_info;
    global $element_pile;
    global $non_HTML_tag_to_avoid;
    global $record_item_body;
    global $questionTempDir;
    $questionTempDir = $exercisePath . '/' . $file . '/';
    $questionFilePath = $questionTempDir . $questionFile;
    $backlog = new Backlog();
    if (!($fp = @fopen($questionFilePath, 'r'))) {
        $backlog->failure(get_lang("Error opening question's XML file"));
        return array($backlog, false);
    } else {
        $data = fread($fp, filesize($questionFilePath));
    }
    //parse XML question file
    $record_item_body = false;
    $non_HTML_tag_to_avoid = array("SIMPLECHOICE", "CHOICEINTERACTION", "INLINECHOICEINTERACTION", "INLINECHOICE", "SIMPLEMATCHSET", "SIMPLEASSOCIABLECHOICE", "TEXTENTRYINTERACTION", "FEEDBACKINLINE", "MATCHINTERACTION", "BR", "OBJECT", "PROMPT");
    $inside_non_HTML_tag_to_avoid = 0;
    //this array to detect tag not supported by claroline import in the xml file to warn the user.
    $non_supported_content_in_question = array("GAPMATCHINTERACTION", "EXTENDEDTEXTINTERACTION", "HOTTEXTINTERACTION", "HOTSPOTINTERACTION", "SELECTPOINTINTERACTION", "GRAPHICORDERINTERACTION", "GRAPHICASSOCIATIONINTERACTION", "GRAPHICGAPMATCHINTERACTION", "POSITIONOBJECTINTERACTION", "SLIDERINTERACTION", "DRAWINGINTERACTION", "UPLOADINTERACTION", "RESPONSECONDITION", "RESPONSEIF");
    $question_format_supported = true;
    $xml_parser = xml_parser_create();
    xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, false);
    xml_set_element_handler($xml_parser, 'startElement', 'endElement');
    xml_set_character_data_handler($xml_parser, 'elementData');
    if (!xml_parse($xml_parser, $data, feof($fp))) {
        // if reading of the xml file in not successfull :
        $backlog->failure(get_lang('Error reading XML file') . '(' . $questionFile . ':' . xml_get_current_line_number($xml_parser) . ': ' . xml_error_string(xml_get_error_code($xml_parser)) . ')');
        return array($backlog, false);
    }
    //close file
    fclose($fp);
    if (!$question_format_supported) {
        $backlog->failure(get_lang('Unknown question format in file %file', array('%file' => $questionFile)));
        return array($backlog, false);
    }
    return array($backlog, true);
}
Exemple #3
0
/**
 * Add module in claroline, giving  its path
 *
 * @param string $modulePath
 * @return int module id or false
 * @todo remove the need of the Backlog and use Exceptions instead
 */
function register_module($modulePath)
{
    $backlog = new Backlog();
    if (file_exists($modulePath)) {
        /*$parser = new ModuleManifestParser;
          $module_info = $parser->parse($modulePath.'/manifest.xml');*/
        $module_info = readModuleManifest($modulePath);
        if (false === $module_info) {
            $backlog->failure(get_lang('Cannot parse module manifest'));
            $moduleId = false;
        } elseif (is_array($module_info) && false !== ($moduleId = register_module_core($module_info))) {
            $backlog->failure(get_lang('Module %claroLabel registered', array('%claroLabel' => $module_info['LABEL'])));
            if ('TOOL' == strtoupper($module_info['TYPE'])) {
                if (false !== ($toolId = register_module_tool($moduleId, $module_info))) {
                    $backlog->failure(get_lang('Module %label registered as tool', array('%claroLabel' => $module_info['LABEL'])));
                } else {
                    $backlog->failure(get_lang('Cannot register tool %label', array('%label' => $module_info['LABEL'])));
                }
            } elseif ('APPLET' == strtoupper($module_info['TYPE'])) {
                if (array_key_exists('DEFAULT_DOCK', $module_info) && is_array($module_info['DEFAULT_DOCK'])) {
                    foreach ($module_info['DEFAULT_DOCK'] as $dock) {
                        add_module_in_dock($moduleId, $dock);
                        $backlog->failure(get_lang('Module %label added in dock : %dock', array('%label' => $module_info['LABEL'], '%dock' => $dock)));
                    }
                }
            }
        } else {
            $backlog->failure(get_lang('Cannot register module %label', array('%label' => $module_info['LABEL'])));
        }
    } else {
        $backlog->failure(get_lang('Cannot find module'));
    }
    return $moduleId;
}
Exemple #4
0
/**
 * Remove database for all modules in the given course
 * @param   string courseId
 * @return  array(
 *  boolean success
 *  Backlog log )
 * @author  Frederic Minne <*****@*****.**>
 */
function delete_all_modules_from_course($courseId)
{
    $backlog = new Backlog();
    $success = true;
    if (!($moduleLabelList = get_module_label_list(false))) {
        $success = false;
        $backlog->failure(claro_failure::get_last_failure());
    } else {
        foreach ($moduleLabelList as $moduleLabel) {
            if (!delete_module_in_course($moduleLabel, $courseId)) {
                $backlog->failure(get_lang('delete failed for module %module', array('%module' => $moduleLabel)));
                $success = false;
            } else {
                $backlog->success(get_lang('delete succeeded for module %module', array('%module' => $moduleLabel)));
            }
        }
    }
    return array($success, $backlog);
}