当前位置: 首页>>代码示例>>PHP>>正文


PHP Exercise::read方法代码示例

本文整理汇总了PHP中Exercise::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Exercise::read方法的具体用法?PHP Exercise::read怎么用?PHP Exercise::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exercise的用法示例。


在下文中一共展示了Exercise::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * constructor of the class
  *
  * @author 	Olivier Brouckaert
  * @param int $questionId that answers belong to
  * @param int $course_id
  */
 public function __construct($questionId, $course_id = null)
 {
     $this->questionId = intval($questionId);
     $this->answer = array();
     $this->correct = array();
     $this->comment = array();
     $this->weighting = array();
     $this->position = array();
     $this->hotspot_coordinates = array();
     $this->hotspot_type = array();
     $this->destination = array();
     // clears $new_* arrays
     $this->cancel();
     if (!empty($course_id)) {
         $courseInfo = api_get_course_info_by_id($course_id);
     } else {
         $courseInfo = api_get_course_info();
     }
     $this->course = $courseInfo;
     $this->course_id = $courseInfo['real_id'];
     // fills arrays
     $objExercise = new Exercise($this->course_id);
     $exerciseId = isset($_REQUEST['exerciseId']) ? $_REQUEST['exerciseId'] : null;
     $objExercise->read($exerciseId);
     if ($objExercise->random_answers == '1') {
         $this->readOrderedBy('rand()', '');
         // randomize answers
     } else {
         $this->read();
         // natural order
     }
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:39,代码来源:answer.class.php

示例2: Exercise

    we delete the objExercise from the session in order to get the latest
    changes in the exercise */
if (api_is_allowed_to_edit(null, true) && isset($_GET['preview']) && $_GET['preview'] == 1) {
    Session::erase('objExercise');
}
// 1. Loading the $objExercise variable
if (!isset($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
    // Construction of Exercise
    $objExercise = new Exercise();
    Session::write('firstTime', true);
    if ($debug) {
        error_log('1. Setting the $objExercise variable');
    }
    unset($_SESSION['questionList']);
    // if the specified exercise doesn't exist or is disabled
    if (!$objExercise->read($exerciseId) || !$objExercise->selectStatus() && !$is_allowedToEdit && $origin != 'learnpath') {
        if ($debug) {
            error_log('1.1. Error while reading the exercise');
        }
        unset($objExercise);
        $error = get_lang('ExerciseNotFound');
    } else {
        // Saves the object into the session
        Session::write('objExercise', $objExercise);
        if ($debug) {
            error_log('1.1. $_SESSION[objExercise] was unset - set now - end');
        }
    }
} else {
    Session::write('firstTime', false);
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:exercise_submit.php

示例3: getNumberOfQuestionsInCategoryForTest

 /**
  * return the number of question of a category id in a test
  * input : test_id, category_id
  * return : integer
  * hubert.borderiou 07-04-2011
  */
 public static function getNumberOfQuestionsInCategoryForTest($exercise_id, $category_id)
 {
     $number_questions_in_category = 0;
     $exercise = new Exercise();
     $exercise->read($exercise_id);
     $question_list = $exercise->getQuestionList();
     // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
     foreach ($question_list as $question_id) {
         $category_in_question = Testcategory::getCategoryForQuestion($question_id);
         if (in_array($category_id, $category_in_question)) {
             $number_questions_in_category++;
         }
     }
     return $number_questions_in_category;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:21,代码来源:testcategory.class.php

示例4: substr

    /**
     * Exports the learning path as a SCORM package. This is the main function that
     * gathers the content, transforms it, writes the imsmanifest.xml file, zips the
     * whole thing and returns the zip.
     *
     * This method needs to be called in PHP5, as it will fail with non-adequate
     * XML package (like the ones for PHP4), and it is *not* a static method, so
     * you need to call it on a learnpath object.
     * @TODO The method might be redefined later on in the scorm class itself to avoid
     * creating a SCORM structure if there is one already. However, if the initial SCORM
     * path has been modified, it should use the generic method here below.
     * @TODO link this function with the export_lp() function in the same class
     * @param	string	Optional name of zip file. If none, title of learnpath is
     * 					domesticated and trailed with ".zip"
     * @return	string	Returns the zip package string, or null if error
     */
    function scorm_export()
    {
        global $_course;
        global $charset;
        if (!class_exists('DomDocument')) {
            error_log('DOM functions not supported for PHP version below 5.0', 0);
            $this->error = 'PHP DOM functions not supported for PHP versions below 5.0';
            return null;
        }
        //remove memory and time limits as much as possible as this might be a long process...
        if (function_exists('ini_set')) {
            $mem = ini_get('memory_limit');
            if (substr($mem, -1, 1) == 'M') {
                $mem_num = substr($mem, 0, -1);
                if ($mem_num < 128) {
                    ini_set('memory_limit', '128M');
                }
            } else {
                ini_set('memory_limit', '128M');
            }
            ini_set('max_execution_time', 600);
            //}else{
            //error_log('Scorm export: could not change memory and time limits',0);
        }
        //Create the zip handler (this will remain available throughout the method)
        $archive_path = api_get_path(SYS_ARCHIVE_PATH);
        $sys_course_path = api_get_path(SYS_COURSE_PATH);
        $temp_dir_short = uniqid();
        $temp_zip_dir = $archive_path . "/" . $temp_dir_short;
        $temp_zip_file = $temp_zip_dir . "/" . md5(time()) . ".zip";
        $zip_folder = new PclZip($temp_zip_file);
        $current_course_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path();
        $root_path = $main_path = api_get_path(SYS_PATH);
        $files_cleanup = array();
        //place to temporarily stash the zipfiles
        //create the temp dir if it doesn't exist
        //or do a cleanup befor creating the zipfile
        if (!is_dir($temp_zip_dir)) {
            mkdir($temp_zip_dir);
        } else {
            //cleanup: check the temp dir for old files and delete them
            $handle = opendir($temp_zip_dir);
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    unlink("{$temp_zip_dir}/{$file}");
                }
            }
            closedir($handle);
        }
        $zip_files = $zip_files_abs = $zip_files_dist = array();
        if (is_dir($current_course_path . '/scorm/' . $this->path) && is_file($current_course_path . '/scorm/' . $this->path . '/imsmanifest.xml')) {
            // remove the possible . at the end of the path
            $dest_path_to_lp = substr($this->path, -1) == '.' ? substr($this->path, 0, -1) : $this->path;
            $dest_path_to_scorm_folder = str_replace('//', '/', $temp_zip_dir . '/scorm/' . $dest_path_to_lp);
            $perm = api_get_setting('permissions_for_new_directories');
            $perm = octdec(!empty($perm) ? $perm : '0770');
            mkdir($dest_path_to_scorm_folder, $perm, true);
            $zip_files_dist = copyr($current_course_path . '/scorm/' . $this->path, $dest_path_to_scorm_folder, array('imsmanifest'), $zip_files);
        }
        //Build a dummy imsmanifest structure. Do not add to the zip yet (we still need it)
        //This structure is developed following regulations for SCORM 1.2 packaging in the SCORM 1.2 Content
        //Aggregation Model official document, secion "2.3 Content Packaging"
        $xmldoc = new DOMDocument('1.0', $this->encoding);
        $root = $xmldoc->createElement('manifest');
        $root->setAttribute('identifier', 'SingleCourseManifest');
        $root->setAttribute('version', '1.1');
        $root->setAttribute('xmlns', 'http://www.imsproject.org/xsd/imscp_rootv1p1p2');
        $root->setAttribute('xmlns:adlcp', 'http://www.adlnet.org/xsd/adlcp_rootv1p2');
        $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        $root->setAttribute('xsi:schemaLocation', 'http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd');
        //Build mandatory sub-root container elements
        $metadata = $xmldoc->createElement('metadata');
        $md_schema = $xmldoc->createElement('schema', 'ADL SCORM');
        $metadata->appendChild($md_schema);
        $md_schemaversion = $xmldoc->createElement('schemaversion', '1.2');
        $metadata->appendChild($md_schemaversion);
        $root->appendChild($metadata);
        $organizations = $xmldoc->createElement('organizations');
        $resources = $xmldoc->createElement('resources');
        //Build the only organization we will use in building our learnpaths
        $organizations->setAttribute('default', 'dokeos_scorm_export');
        $organization = $xmldoc->createElement('organization');
        $organization->setAttribute('identifier', 'dokeos_scorm_export');
        //to set the title of the SCORM entity (=organization), we take the name given
//.........这里部分代码省略.........
开发者ID:Eidn,项目名称:shanghai,代码行数:101,代码来源:learnpath.class.php

示例5: LearnpathList

}
if (empty($course_code)) {
    $course_code = 0;
}
$form->setDefaults(array('course_code' => (string) $course_code));
$course_info = api_get_course_info($course_code);
if (!empty($course_info)) {
    $list = new LearnpathList('', $course_code);
    $lp_list = $list->get_flat_list();
    $_course = $course_info;
    $main_question_list = array();
    foreach ($lp_list as $lp_id => $lp) {
        $exercise_list = ExerciseLib::get_all_exercises_from_lp($lp_id, $course_info['real_id']);
        foreach ($exercise_list as $exercise) {
            $my_exercise = new Exercise();
            $my_exercise->read($exercise['path']);
            $question_list = $my_exercise->selectQuestionList();
            $exercise_stats = get_all_exercise_event_from_lp($exercise['path'], $course_info['real_id'], $session_id);
            foreach ($question_list as $question_id) {
                $question_data = Question::read($question_id);
                $main_question_list[$question_id] = $question_data;
                $quantity_exercises = 0;
                $question_result = 0;
                foreach ($exercise_stats as $stats) {
                    if (!empty($stats['question_list'])) {
                        foreach ($stats['question_list'] as $my_question_stat) {
                            if ($question_id == $my_question_stat['question_id']) {
                                $question_result = $question_result + $my_question_stat['marks'];
                                $quantity_exercises++;
                            }
                        }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:question_course_report.php

示例6: isset

}
if (empty($objExercise)) {
    $objExercise = $_SESSION['objExercise'];
}
if (empty($remind_list)) {
    $remind_list = isset($_REQUEST['remind_list']) ? $_REQUEST['remind_list'] : null;
}
$exe_id = isset($_REQUEST['exe_id']) ? intval($_REQUEST['exe_id']) : 0;
if (empty($objExercise)) {
    // Redirect to the exercise overview
    // Check if the exe_id exists
    $objExercise = new Exercise();
    $exercise_stat_info = $objExercise->getStatTrackExerciseInfoByExeId($exe_id);
    if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) {
        if ($exercise_stat_info['status'] == 'incomplete') {
            $objExercise->read($exercise_stat_info['exe_exo_id']);
        } else {
            header("Location: overview.php?exerciseId=" . $exercise_stat_info['exe_exo_id']);
            exit;
        }
    } else {
        api_not_allowed(true);
    }
}
$gradebook = '';
if (isset($_SESSION['gradebook'])) {
    $gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook == 'view') {
    $interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:exercise_result.php

示例7: getNumberOfQuestionsInCategoryForTest

 /**
  * return the number of question of a category id in a test
  * @param int $exerciseId
  * @param int $categoryId
  *
  * @return integer
  *
  * @author hubert.borderiou 07-04-2011
  */
 public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId)
 {
     $nbCatResult = 0;
     $quiz = new Exercise();
     $quiz->read($exerciseId);
     $tabQuestionList = $quiz->selectQuestionList();
     // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ?
     for ($i = 1; $i <= count($tabQuestionList); $i++) {
         if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) {
             $nbCatResult++;
         }
     }
     return $nbCatResult;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:23,代码来源:TestCategory.php

示例8: show_course_detail

 /**
  * Shows the user detail progress (when clicking in the details link)
  * @param   int     $user_id
  * @param   string  $course_code
  * @param   int     $session_id
  * @return  string  html code
  */
 public static function show_course_detail($user_id, $course_code, $session_id)
 {
     $html = '';
     if (isset($course_code)) {
         $user_id = intval($user_id);
         $session_id = intval($session_id);
         $course = Database::escape_string($course_code);
         $course_info = CourseManager::get_course_information($course);
         $html .= Display::page_subheader($course_info['title']);
         $html .= '<table class="data_table" width="100%">';
         //Course details
         $html .= '
             <tr>
             <th class="head" style="color:#000">' . get_lang('Exercises') . '</th>
             <th class="head" style="color:#000">' . get_lang('Attempts') . '</th>
             <th class="head" style="color:#000">' . get_lang('BestAttempt') . '</th>
             <th class="head" style="color:#000">' . get_lang('Ranking') . '</th>
             <th class="head" style="color:#000">' . get_lang('BestResultInCourse') . '</th>
             <th class="head" style="color:#000">' . get_lang('Statistics') . ' ' . Display::return_icon('info3.gif', get_lang('OnlyBestResultsPerStudent'), array('align' => 'absmiddle', 'hspace' => '3px')) . '</th>
             </tr>';
         if (empty($session_id)) {
             $user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, STUDENT);
         } else {
             $user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, 0);
         }
         // Show exercise results of invisible exercises? see BT#4091
         $exercise_list = ExerciseLib::get_all_exercises($course_info, $session_id, false, null, false, 2);
         $to_graph_exercise_result = array();
         if (!empty($exercise_list)) {
             $score = $weighting = $exe_id = 0;
             foreach ($exercise_list as $exercices) {
                 $exercise_obj = new Exercise($course_info['real_id']);
                 $exercise_obj->read($exercices['id']);
                 $visible_return = $exercise_obj->is_visible();
                 $score = $weighting = $attempts = 0;
                 // Getting count of attempts by user
                 $attempts = Event::count_exercise_attempts_by_user(api_get_user_id(), $exercices['id'], $course_info['real_id'], $session_id);
                 $html .= '<tr class="row_even">';
                 $url = api_get_path(WEB_CODE_PATH) . "exercice/overview.php?cidReq={$course_info['code']}&id_session={$session_id}&exerciseId={$exercices['id']}";
                 if ($visible_return['value'] == true) {
                     $exercices['title'] = Display::url($exercices['title'], $url, array('target' => SESSION_LINK_TARGET));
                 }
                 $html .= Display::tag('td', $exercices['title']);
                 // Exercise configuration show results or show only score
                 if ($exercices['results_disabled'] == 0 || $exercices['results_disabled'] == 2) {
                     //For graphics
                     $best_exercise_stats = Event::get_best_exercise_results_by_user($exercices['id'], $course_info['real_id'], $session_id);
                     $to_graph_exercise_result[$exercices['id']] = array('title' => $exercices['title'], 'data' => $best_exercise_stats);
                     $latest_attempt_url = '';
                     $best_score = $position = $percentage_score_result = '-';
                     $graph = $normal_graph = null;
                     // Getting best results
                     $best_score_data = ExerciseLib::get_best_attempt_in_course($exercices['id'], $course_info['real_id'], $session_id);
                     $best_score = '';
                     if (!empty($best_score_data)) {
                         $best_score = ExerciseLib::show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
                     }
                     if ($attempts > 0) {
                         $exercise_stat = ExerciseLib::get_best_attempt_by_user(api_get_user_id(), $exercices['id'], $course_info['real_id'], $session_id);
                         if (!empty($exercise_stat)) {
                             //Always getting the BEST attempt
                             $score = $exercise_stat['exe_result'];
                             $weighting = $exercise_stat['exe_weighting'];
                             $exe_id = $exercise_stat['exe_id'];
                             $latest_attempt_url .= api_get_path(WEB_CODE_PATH) . 'exercice/result.php?id=' . $exe_id . '&cidReq=' . $course_info['code'] . '&show_headers=1&id_session=' . $session_id;
                             $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
                             $my_score = 0;
                             if (!empty($weighting) && intval($weighting) != 0) {
                                 $my_score = $score / $weighting;
                             }
                             //@todo this function slows the page
                             $position = ExerciseLib::get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);
                             $graph = self::generate_exercise_result_thumbnail_graph($to_graph_exercise_result[$exercices['id']]);
                             $normal_graph = self::generate_exercise_result_graph($to_graph_exercise_result[$exercices['id']]);
                         }
                     }
                     $html .= Display::div($normal_graph, array('id' => 'main_graph_' . $exercices['id'], 'class' => 'dialog', 'style' => 'display:none'));
                     if (empty($graph)) {
                         $graph = '-';
                     } else {
                         $graph = Display::url('<img src="' . $graph . '" >', $normal_graph, array('id' => $exercices['id'], 'class' => 'expand-image'));
                     }
                     $html .= Display::tag('td', $attempts, array('align' => 'center'));
                     $html .= Display::tag('td', $percentage_score_result, array('align' => 'center'));
                     $html .= Display::tag('td', $position, array('align' => 'center'));
                     $html .= Display::tag('td', $best_score, array('align' => 'center'));
                     $html .= Display::tag('td', $graph, array('align' => 'center'));
                     //$html .= Display::tag('td', $latest_attempt_url,       array('align'=>'center', 'width'=>'25'));
                 } else {
                     // Exercise configuration NO results
                     $html .= Display::tag('td', $attempts, array('align' => 'center'));
                     $html .= Display::tag('td', '-', array('align' => 'center'));
                     $html .= Display::tag('td', '-', array('align' => 'center'));
//.........这里部分代码省略.........
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:101,代码来源:tracking.lib.php

示例9: header

}
// no support for hot potatoes
if ($type == LINK_HOTPOTATOES) {
    $doExerciseUrl = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?session_id=' . $session_id . '&cidReq=' . Security::remove_XSS($cidReq);
}
if (isset($_GET['doexercise'])) {
    header('Location: ' . $doExerciseUrl);
    exit;
} else {
    $url = api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?session_id=' . $session_id . '&cidReq=' . Security::remove_XSS($cidReq);
    if (isset($_GET['gradebook'])) {
        $url .= '&gradebook=view&exerciseId=' . intval($_GET['exerciseId']);
        // Check if exercise is inserted inside a LP, if that's the case
        $exerciseId = $_GET['exerciseId'];
        $exercise = new Exercise();
        $exercise->read($exerciseId);
        if (!empty($exercise->id)) {
            if ($exercise->exercise_was_added_in_lp) {
                if (!empty($exercise->lpList)) {
                    $count = count($exercise->lpList);
                    if ($count == 1) {
                        // If the exercise was added once redirect to the LP
                        $firstLp = current($exercise->lpList);
                        if (isset($firstLp['lp_id'])) {
                            $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&lp_id=' . $firstLp['lp_id'] . '&action=view&isStudentView=true';
                        }
                    } else {
                        // If the exercise was added multiple times show the LP list
                        $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=list';
                    }
                }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:exercise_jump.php

示例10: isset

// get index row - i.e. user click to sort $sord = $_GET['sord'];
// get the direction
if (!$sidx) {
    $sidx = 1;
}
//2. Selecting the count FIRST
//@todo rework this
switch ($action) {
    case 'get_user_list_plugin_widescale':
        $count = UserManager::get_user_data(null, null, null, null, true);
        break;
    case 'get_question_list':
        require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php';
        $exerciseId = isset($_REQUEST['exerciseId']) ? $_REQUEST['exerciseId'] : null;
        $exercise = new Exercise(api_get_course_int_id());
        $exercise->read($exerciseId, false);
        $count = $exercise->getQuestionCount();
        break;
    case 'get_group_reporting':
        $course_id = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : null;
        $group_id = isset($_REQUEST['gidReq']) ? $_REQUEST['gidReq'] : null;
        $count = Tracking::get_group_reporting($course_id, $group_id, 'count');
        break;
    case 'get_user_course_report_resumed':
        $count = CourseManager::get_count_user_list_from_course_code(true, 'ruc');
        break;
    case 'get_user_course_report':
        $count = CourseManager::get_count_user_list_from_course_code(false);
        break;
    case 'get_course_exercise_medias':
        $course_id = api_get_course_int_id();
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:model.ajax.php

示例11: export_exercise

/**
 * This function exports the given Chamilo test
 * @param    integer    Test ID
 * @return string     The test itself as an HTML string
 */
function export_exercise($item_id)
{
    global $expdir, $_course, $_configuration, $_SESSION, $_SERVER, $language_interface, $langExerciseNotFound, $langQuestion, $langOk, $origin, $questionNum;
    $exerciseId = $item_id;
    require_once '../exercice/exercise.class.php';
    require_once '../exercice/question.class.php';
    require_once '../exercice/answer.class.php';
    $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
    /* Clears the exercise session */
    if (isset($_SESSION['objExercise'])) {
        Session::erase('objExercise');
    }
    if (isset($_SESSION['objQuestion'])) {
        Session::erase('objQuestion');
    }
    if (isset($_SESSION['objAnswer'])) {
        Session::erase('objAnswer');
    }
    if (isset($_SESSION['questionList'])) {
        Session::erase('questionList');
    }
    if (isset($_SESSION['exerciseResult'])) {
        Session::erase('exerciseResult');
    }
    // If the object is not in the session:
    if (!isset($_SESSION['objExercise'])) {
        // Construction of Exercise.
        $objExercise = new Exercise();
        $sql = "SELECT title,description,sound,type,random,active FROM {$TBL_EXERCISES} WHERE iid='{$exerciseId}'";
        // If the specified exercise doesn't exist or is disabled:
        if (!$objExercise->read($exerciseId) || !$objExercise->selectStatus() && !api_is_allowed_to_edit() && $origin != 'learnpath') {
            die($langExerciseNotFound);
        }
        // Saves the object into the session.
        Session::write('objExercise', $objExercise);
    }
    $exerciseTitle = $objExercise->selectTitle();
    $exerciseDescription = $objExercise->selectDescription();
    $exerciseSound = $objExercise->selectSound();
    $randomQuestions = $objExercise->isRandom();
    $exerciseType = $objExercise->selectType();
    if (!isset($_SESSION['questionList'])) {
        // Selects the list of question ID.
        $questionList = $randomQuestions ? $objExercise->selectRandomList() : $objExercise->selectQuestionList();
        // Saves the question list into the session.
        Session::write('questionList', $questionList);
    }
    $nbrQuestions = sizeof($questionList);
    // If questionNum comes from POST and not from GET:
    if (!$questionNum || $_POST['questionNum']) {
        // Only used for sequential exercises (see $exerciseType).
        if (!$questionNum) {
            $questionNum = 1;
        } else {
            $questionNum++;
        }
    }
    $test .= "<h3>" . $exerciseTitle . "</h3>";
    if (!empty($exerciseSound)) {
        $test .= "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . $exerciseSound . "\"&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9 target=\"_blank\"><img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=" . get_lang("Sound") . "\" /></a>";
    }
    // Writing the .js file with to check the correct answers begin.
    $scriptfilename = "Exercice" . $item_id . ".js";
    $s = "<script type=\"text/javascript\" src='../js/" . $scriptfilename . "'></script>";
    $test .= $s;
    $content = "function evaluate() {\n        alert('Test evaluated.');\n        }\n        ";
    if (!($handle = fopen($expdir . '/js/' . $scriptfilename, 'w'))) {
        echo "Cannot open file ({$scriptfilename})";
    }
    if (fwrite($handle, $content) === false) {
        echo "Cannot write to file ({$filename})";
        exit;
    }
    fclose($handle);
    // Writing the .js file with to check the correct answers end.
    $s = "\n        <p>{$exerciseDescription}</p>\n        <table width='100%' border='0' cellpadding='1' cellspacing='0'>\n         <form method='post' action=''><input type=\"hidden\" name=\"SQMSESSID\" value=\"36812c2dea7d8d6e708d5e6a2f09b0b9\" />\n         <input type='hidden' name='formSent' value='1' />\n         <input type='hidden' name='exerciseType' value='" . $exerciseType . "' />\n         <input type='hidden' name='questionNum' value='" . $questionNum . "' />\n         <input type='hidden' name='nbrQuestions' value='" . $nbrQuestions . "' />\n         <tr>\n          <td>\n          <table width='100%' cellpadding='4' cellspacing='2' border='0'>";
    $exerciseType = 1;
    // So to list all questions in one page.
    $test .= $s;
    $i = 0;
    foreach ($questionList as $questionId) {
        $i++;
        // For sequential exercises.
        if ($exerciseType == 2) {
            // If it is not the right question, goes to the next loop iteration.
            if ($questionNum != $i) {
                continue;
            } else {
                // if the user has already answered this question:
                if (isset($exerciseResult[$questionId])) {
                    // Construction of the Question object.
                    $objQuestionTmp = new Question();
                    // Reads question informations.
                    $objQuestionTmp->read($questionId);
                    $questionName = $objQuestionTmp->selectTitle();
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:learnpath_functions.inc.php

示例12: array

 } else {
     $headers = array(array('name' => get_lang('ExerciseName')), array('name' => get_lang('Status')));
 }
 $header_list = '';
 foreach ($headers as $header) {
     $params = isset($header['params']) ? $header['params'] : null;
     $header_list .= Display::tag('th', $header['name'], $params);
 }
 echo Display::tag('tr', $header_list);
 $autolaunch_setting_on = api_get_course_setting('enable_exercise_auto_launch') == 1;
 $count = 0;
 if (!empty($exercise_list)) {
     foreach ($exercise_list as $row) {
         $my_exercise_id = $row['iid'];
         $exercise_obj = new Exercise();
         $exercise_obj->read($my_exercise_id, false);
         $locked = $exercise_obj->is_gradebook_locked;
         //echo '<div  id="tabs-'.$i.'">';
         $i++;
         // Validation when belongs to a session
         $session_img = api_get_session_image($row['session_id'], $_user['status']);
         $time_limits = false;
         if ($row['start_time'] != '0000-00-00 00:00:00' || $row['end_time'] != '0000-00-00 00:00:00') {
             $time_limits = true;
         }
         if ($time_limits) {
             // check if start time
             $start_time = false;
             if ($row['start_time'] != '0000-00-00 00:00:00') {
                 $start_time = api_strtotime($row['start_time'], 'UTC');
             }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:exercice.php

示例13: build_quizzes

 /**
  * Build the Quizzes
  */
 public function build_quizzes($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array())
 {
     $course_info = api_get_course_info($course_code);
     $table_qui = Database::get_course_table(TABLE_QUIZ_TEST);
     $table_rel = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
     $table_doc = Database::get_course_table(TABLE_DOCUMENT);
     $course_id = $course_info['real_id'];
     if (!empty($course_code) && !empty($session_id)) {
         $session_id = intval($session_id);
         if ($with_base_content) {
             $session_condition = api_get_session_condition($session_id, true, true);
         } else {
             $session_condition = api_get_session_condition($session_id, true);
         }
         $sql = "SELECT * FROM {$table_qui} WHERE c_id = {$course_id} AND active >=0 {$session_condition}";
         //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
     } else {
         $sql = "SELECT * FROM {$table_qui} WHERE c_id = {$course_id} AND active >=0 AND session_id = 0";
         //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
     }
     $db_result = Database::query($sql);
     while ($obj = Database::fetch_object($db_result)) {
         if (strlen($obj->sound) > 0) {
             $sql = "SELECT id FROM {$table_doc} WHERE c_id = {$course_id} AND path = '/audio/" . $obj->sound . "'";
             $res = Database::query($sql);
             $doc = Database::fetch_object($res);
             $obj->sound = $doc->id;
         }
         $exercise_obj = new Exercise($course_id);
         $exercise_obj->read($obj->iid);
         $categories = $exercise_obj->get_categories_with_name_in_exercise();
         $obj->categories = $categories;
         $quiz = new Quiz($obj);
         $sql = 'SELECT * FROM ' . $table_rel . ' WHERE c_id = ' . $course_id . ' AND exercice_id = ' . $obj->iid;
         $db_result2 = Database::query($sql);
         while ($obj2 = Database::fetch_object($db_result2)) {
             $quiz->add_question($obj2->question_id, $obj2->question_order);
         }
         $this->course->add_resource($quiz);
     }
     if (!empty($course_code)) {
         $this->build_quiz_questions($course_code);
     } else {
         $this->build_quiz_questions();
     }
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:49,代码来源:CourseBuilder.class.php

示例14: unlink

    $name = 'qti2_export_' . $qid . '.zip';
    DocumentManager::file_send_for_download($temp_zip_file, true, $name);
    unlink($temp_zip_file);
    unlink($temp_xml_file);
    rmdir($temp_zip_dir);
    //DocumentManager::string_send_for_download($export,true,'qti2export_q'.$_GET['questionId'].'.xml');
    exit;
    //otherwise following clicks may become buggy
}
// Initializes the Exercise object.
if (!is_object($objExercise)) {
    // construction of the Exercise object
    $objExercise = new Exercise();
    // creation of a new exercise if wrong or not specified exercise ID
    if ($exerciseId) {
        $objExercise->read($exerciseId, true);
    }
    // saves the object into the session
    Session::write('objExercise', $objExercise);
}
if ($objExercise->fastEdition) {
    $htmlHeadXtra[] = api_get_jqgrid_js();
}
$nbrQuestions = $objExercise->getQuestionCount();
// Initializes the Question object
if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
    if ($editQuestion || $newQuestion) {
        // reads question data
        if ($editQuestion) {
            // question not found
            if (!($objQuestion = Question::read($editQuestion, null, $objExercise))) {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:admin.php

示例15: get_exercise_result

 /**
  * Returns the exercise result
  * @param 	int		attempt id
  * @return 	float 	exercise result
  */
 public function get_exercise_result($exe_id)
 {
     $result = array();
     $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($exe_id);
     if (!empty($track_exercise_info)) {
         $totalScore = 0;
         $objExercise = new Exercise();
         $objExercise->read($track_exercise_info['exe_exo_id']);
         if (!empty($track_exercise_info['data_tracking'])) {
             $question_list = explode(',', $track_exercise_info['data_tracking']);
         }
         foreach ($question_list as $questionId) {
             $question_result = $objExercise->manage_answer($exe_id, $questionId, '', 'exercise_show', array(), false, true, false, $objExercise->selectPropagateNeg());
             $totalScore += $question_result['score'];
         }
         if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
             $totalScore = 0;
         }
         $result = array('score' => $totalScore, 'weight' => $track_exercise_info['exe_weighting']);
     }
     return $result;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:27,代码来源:exercise.class.php


注:本文中的Exercise::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。