⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 format.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
                        // Doesn't apply since the user responds with text input                        break;                    case 'Multiple Choice':                        $mc_choices = $pblock['#']['response_lid'][0]['#']['render_choice'][0]['#']['flow_label'];                            foreach($mc_choices as $mc_choice) {                            $choices = NULL;                            $choices = $this->process_block($mc_choice, $choices);                            $block->choices[] = $choices;                                     }                        break;                    case 'Short Response':                        // do nothing?                        break;                    case 'Fill in the Blank':                        // do nothing?                        break;                    case 'Fill in the Blank Plus':                        // do nothing?                        break;                                      case 'Numeric':                        // do nothing?                        break;                                                 default:                        $bb_choices = $pblock['#']['response_lid'][0]['#']['render_choice'][0]['#']['flow_label'][0]['#']['response_label'];                        $choices = array();                        $this->process_choices($bb_choices, $choices);                        $block->choices = $choices;                }                break;            case 'RIGHT_MATCH_BLOCK':                $matching_answerset = $pblock['#']['flow'];                $answerset = array();                foreach($matching_answerset as $answer) {                    // $answerset[] = $this->process_block($answer, $bb_answer);                    $bb_answer = null;                    $bb_answer->text = $answer['#']['flow'][0]['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#'];                    $answerset[] = $bb_answer;                }                $block->matching_answerset = $answerset;                break;            default:                print "UNHANDLED PRESENTATION BLOCK";                break;        }        $question->{$block->type} = $block;    }        // determine response processing     // there is a section called 'outcomes' that I don't know what to do with    $resprocessing = $quest['#']['resprocessing'];    $respconditions = $resprocessing[0]['#']['respcondition'];    $responses = array();    if ($question->qtype == 'Matching') {        $this->process_matching_responses($respconditions, $responses);    }    else {        $this->process_responses($respconditions, $responses);    }    $question->responses = $responses;    $feedbackset = $quest['#']['itemfeedback'];    $feedbacks = array();    $this->process_feedback($feedbackset, $feedbacks);    $question->feedback = $feedbacks;    return $question;}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;}function process_choices($bb_choices, &$choices) {    foreach($bb_choices as $choice) {            if (isset($choice['@']['ident'])) {            $cur_choice = $choice['@']['ident'];        }        else { //for multiple answer            $cur_choice = $choice['#']['response_label'][0];//['@']['ident'];        }        if (isset($choice['#']['flow_mat'][0])) { //for multiple answer            $cur_block = $choice['#']['flow_mat'][0];            // Reset $cur_choice to NULL because process_block is expecting an object            // for the second argument and not a string, which is what is was set as            // originally - CT 8/7/06            $cur_choice = null;             $this->process_block($cur_block, $cur_choice);        }        elseif (isset($choice['#']['response_label'])) {            // Reset $cur_choice to NULL because process_block is expecting an object            // for the second argument and not a string, which is what is was set as            // originally - CT 8/7/06            $cur_choice = null;             $this->process_block($choice, $cur_choice);        }        $choices[] = $cur_choice;    }    }function process_matching_responses($bb_responses, &$responses) {    foreach($bb_responses as $bb_response) {        $response = NULL;        if (isset($bb_response['#']['conditionvar'][0]['#']['varequal'])) {            $response->correct = $bb_response['#']['conditionvar'][0]['#']['varequal'][0]['#'];            $response->ident = $bb_response['#']['conditionvar'][0]['#']['varequal'][0]['@']['respident'];        }        else {            $response->correct =  'Broken Question?';            $response->ident = 'Broken Question?';        }        $response->feedback = $bb_response['#']['displayfeedback'][0]['@']['linkrefid'];        $responses[] = $response;    }}function process_responses($bb_responses, &$responses) {    foreach($bb_responses as $bb_response) {        //Added this line to instantiate $response.        // Without instantiating the $response variable, the same object        // gets added to the array        $response = null;        if (isset($bb_response['@']['title'])) {                $response->title = $bb_response['@']['title'];                }            else {                $reponse->title = $bb_response['#']['displayfeedback'][0]['@']['linkrefid'];            }            $reponse->ident = array();            if (isset($bb_response['#']['conditionvar'][0]['#'])){//['varequal'][0]['#'])) {                $response->ident[0] = $bb_response['#']['conditionvar'][0]['#'];//['varequal'][0]['#'];                }            else if (isset($bb_response['#']['conditionvar'][0]['#']['other'][0]['#'])) {                $response->ident[0] = $bb_response['#']['conditionvar'][0]['#']['other'][0]['#'];              }                        if (isset($bb_response['#']['conditionvar'][0]['#']['and'])){//[0]['#'])) {                $responseset = $bb_response['#']['conditionvar'][0]['#']['and'];//[0]['#']['varequal'];                foreach($responseset as $rs) {                    $response->ident[] = $rs['#'];                    if(!isset($response->feedback) and isset( $rs['@'] ) ) {                        $response->feedback = $rs['@']['respident'];                    }                    }            }            else {                $response->feedback = $bb_response['#']['displayfeedback'][0]['@']['linkrefid'];               }            // determine what point value to give response            if (isset($bb_response['#']['setvar'])) {                switch ($bb_response['#']['setvar'][0]['#']) {                    case "SCORE.max":                        $response->fraction = 1;                        break;                    default:                        // I have only seen this being 0 or unset                          // there are probably fractional values of SCORE.max, but I'm not sure what they look like                        $response->fraction = 0;                        break;                }            }            else {               // just going to assume this is the case this is probably not correct.               $response->fraction = 0;            }                        $responses[] = $response;        }}function process_feedback($feedbackset, &$feedbacks) {    foreach($feedbackset as $bb_feedback) {        // Added line $feedback=null so that $feedback does not get reused in the loop        // and added the the $feedbacks[] array multiple times        $feedback = null;          $feedback->ident = $bb_feedback['@']['ident'];        if (isset($bb_feedback['#']['flow_mat'][0])) {            $this->process_block($bb_feedback['#']['flow_mat'][0], $feedback);        }        elseif (isset($bb_feedback['#']['solution'][0]['#']['solutionmaterial'][0]['#']['flow_mat'][0])) {            $this->process_block($bb_feedback['#']['solution'][0]['#']['solutionmaterial'][0]['#']['flow_mat'][0], $feedback);        }        $feedbacks[] = $feedback;    }}/** * Create common parts of question */function process_common( $quest ) {    $question = $this->defaultquestion();    $question->questiontext = addslashes($quest->QUESTION_BLOCK->text);    $question->name = shorten_text( $quest->id, 250 );    return $question;}//----------------------------------------// Process True / False Questions//----------------------------------------function process_tf($quest, &$questions) {    $question = $this->process_common( $quest );    $question->qtype = TRUEFALSE;    $question->single = 1; // Only one answer is allowed    // 0th [response] is the correct answer.    $responses = $quest->responses;    $correctresponse = $responses[0]->ident[0]['varequal'][0]['#'];    if ($correctresponse != 'false') {        $correct = true;        }    else {        $correct = false;       }        foreach($quest->feedback as $fb) {        $fback->{$fb->ident} = $fb->text;       }        if ($correct) {  // true is correct        $question->answer = 1;        $question->feedbacktrue = addslashes($fback->correct);        $question->feedbackfalse = addslashes($fback->incorrect);    } else {  // false is correct        $question->answer = 0;        $question->feedbacktrue = addslashes($fback->incorrect);        $question->feedbackfalse = addslashes($fback->correct);    }    $question->correctanswer = $question->answer;    $questions[] = $question;}//----------------------------------------// Process Fill in the Blank//----------------------------------------function process_fblank($quest, &$questions) {    $question = $this->process_common( $quest );    $question->qtype = SHORTANSWER;    $question->single = 1;    $answers = array();    $fractions = array();    $feedbacks = array();        // extract the feedback    $feedback = array();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -