You are here

function qformat_blackboard_6::process_block in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/moodle/question/format/blackboard_6/format.php \qformat_blackboard_6::process_block()
3 calls to qformat_blackboard_6::process_block()
qformat_blackboard_6::create_raw_question in includes/moodle/question/format/blackboard_6/format.php
qformat_blackboard_6::process_choices in includes/moodle/question/format/blackboard_6/format.php
qformat_blackboard_6::process_feedback in includes/moodle/question/format/blackboard_6/format.php

File

includes/moodle/question/format/blackboard_6/format.php, line 377

Class

qformat_blackboard_6

Code

function process_block($cur_block, &$block) {
  global $COURSE, $CFG;
  $cur_type = $cur_block['@']['class'];
  switch ($cur_type) {
    case 'FORMATTED_TEXT_BLOCK':
      $block->text = $this
        ->strip_applet_tags_get_mathml($cur_block['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#']);
      break;
    case 'FILE_BLOCK':

      //revisit this to make sure it is working correctly

      // Commented out ['matapplication']..., etc. because I
      // noticed that when I imported a new Blackboard 6 file
      // and printed out the block, the tree did not extend past ['material'][0]['#'] - CT 8/3/06
      $block->file = $cur_block['#']['material'][0]['#'];

      //['matapplication'][0]['@']['uri'];
      if ($block->file != '') {

        // if we have a file copy it to the course dir and adjust its name to be visible over the web.
        $block->file = $this
          ->copy_file_to_course($block->file);
        $block->file = $CFG->wwwroot . '/file.php/' . $COURSE->id . '/bb_import/' . basename($block->file);
      }
      break;
    case 'Block':
      if (isset($cur_block['#']['material'][0]['#']['mattext'][0]['#'])) {
        $block->text = $cur_block['#']['material'][0]['#']['mattext'][0]['#'];
      }
      else {
        if (isset($cur_block['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#'])) {
          $block->text = $cur_block['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#'];
        }
        else {
          if (isset($cur_block['#']['response_label'])) {

            // this is a response label block
            $sub_blocks = $cur_block['#']['response_label'][0];
            if (!isset($block->ident)) {
              if (isset($sub_blocks['@']['ident'])) {
                $block->ident = $sub_blocks['@']['ident'];
              }
            }
            foreach ($sub_blocks['#']['flow_mat'] as $sub_block) {
              $this
                ->process_block($sub_block, $block);
            }
          }
          else {
            if (isset($cur_block['#']['flow_mat']) || isset($cur_block['#']['flow'])) {
              if (isset($cur_block['#']['flow_mat'])) {
                $sub_blocks = $cur_block['#']['flow_mat'];
              }
              elseif (isset($cur_block['#']['flow'])) {
                $sub_blocks = $cur_block['#']['flow'];
              }
              foreach ($sub_blocks as $sblock) {

                // this will recursively grab the sub blocks which should be of one of the other types
                $this
                  ->process_block($sblock, $block);
              }
            }
          }
        }
      }
      break;
    case 'LINK_BLOCK':

      // not sure how this should be included
      if (!empty($cur_block['#']['material'][0]['#']['mattext'][0]['@']['uri'])) {
        $block->link = $cur_block['#']['material'][0]['#']['mattext'][0]['@']['uri'];
      }
      else {
        $block->link = '';
      }
      break;
  }
  return $block;
}