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


PHP Result::load方法代码示例

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


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

示例1: UserDataGenerator

 public function UserDataGenerator($userid, $evals = array(), $links = array())
 {
     $this->userid = $userid;
     $evals_filtered = array();
     $result = array();
     foreach ($evals as $eval) {
         $toadd = true;
         $coursecode = $eval->get_course_code();
         if (isset($coursecode)) {
             $result = Result::load(null, $userid, $eval->get_id());
             if (count($result) == 0) {
                 $toadd = false;
             }
         }
         if ($toadd) {
             $evals_filtered_copy = $evals;
         }
     }
     if (count($result) == 0) {
         $evals_filtered = $evals;
     } else {
         $evals_filtered = $evals_filtered_copy;
     }
     $this->items = array_merge($evals_filtered, $links);
     $this->coursecodecache = array();
     $this->categorycache = array();
     $this->scorecache = null;
     $this->avgcache = null;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:29,代码来源:user_data_generator.class.php

示例2: calc_score

 /**
  * Calculate the score of this evaluation
  * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
  * @param string $type (best, average, ranking)
  * @return	array (score, max) if student is given
  * 			array (sum of scores, number of scores) otherwise
  * 			or null if no scores available
  */
 public function calc_score($stud_id = null, $type = null)
 {
     $useSession = true;
     if (isset($stud_id) && empty($type)) {
         $key = 'result_score_student_list_' . api_get_course_int_id() . '_' . api_get_session_id() . '_' . $this->id . '_' . $stud_id;
         $data = Session::read('calc_score');
         $results = isset($data[$key]) ? $data[$key] : null;
         if ($useSession == false) {
             $results = null;
         }
         if (empty($results)) {
             $results = Result::load(null, $stud_id, $this->id);
             Session::write('calc_score', array($key => $results));
         }
         $score = 0;
         /** @var Result $res */
         foreach ($results as $res) {
             $score = $res->get_score();
         }
         return array($score, $this->get_max());
     } else {
         $count = 0;
         $sum = 0;
         $bestResult = 0;
         $weight = 0;
         $sumResult = 0;
         $key = 'result_score_student_list_' . api_get_course_int_id() . '_' . api_get_session_id() . '_' . $this->id;
         $data = Session::read('calc_score');
         $allResults = isset($data[$key]) ? $data[$key] : null;
         if ($useSession == false) {
             $allResults = null;
         }
         if (empty($allResults)) {
             $allResults = Result::load(null, null, $this->id);
             Session::write($key, $allResults);
         }
         $students = array();
         /** @var Result $res */
         foreach ($allResults as $res) {
             $score = $res->get_score();
             if (!empty($score) || $score == '0') {
                 $count++;
                 $sum += $score / $this->get_max();
                 $sumResult += $score;
                 if ($score > $bestResult) {
                     $bestResult = $score;
                 }
                 $weight = $this->get_max();
             }
             $students[$res->get_user_id()] = $score;
         }
         if (empty($count)) {
             return null;
         }
         switch ($type) {
             case 'best':
                 return array($bestResult, $weight);
                 break;
             case 'average':
                 return array($sumResult / $count, $weight);
                 break;
             case 'ranking':
                 $students = array();
                 /** @var Result $res */
                 foreach ($allResults as $res) {
                     $score = $res->get_score();
                     $students[$res->get_user_id()] = $score;
                 }
                 return AbstractLink::getCurrentUserRanking($stud_id, $students);
                 break;
             default:
                 return array($sum, $count);
                 break;
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:84,代码来源:evaluation.class.php

示例3: add_result__log

    /**
     * insert log result
     */
    public function add_result__log($userid, $evaluationid)
    {
        if (isset($userid) && isset($evaluationid)) {
            $tbl_grade_results_log = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_LOG);
            $result = new Result();
            $arr_result = $result->load(null, $userid, $evaluationid);
            $arr = get_object_vars($arr_result[0]);
            $sql = 'INSERT INTO ' . $tbl_grade_results_log . ' (id_result,user_id, evaluation_id,created_at';
            if (isset($arr['score'])) {
                $sql .= ',score';
            }
            $sql .= ') VALUES
					(' . (int) $arr['id'] . ',' . (int) $arr['user_id'] . ', ' . (int) $arr['evaluation'] . ", '" . api_get_utc_datetime() . "'";
            if (isset($arr['score'])) {
                $sql .= ', ' . $arr['score'];
            }
            $sql .= ')';
            Database::query($sql);
        } else {
            die('Error in Result add: required field empty');
        }
    }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:25,代码来源:result.class.php

示例4: calc_score

 /**
  * Calculate the score of this evaluation
  * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
  * @return	array (score, max) if student is given
  * 			array (sum of scores, number of scores) otherwise
  * 			or null if no scores available
  */
 public function calc_score($stud_id = null)
 {
     $results = Result::load(null, $stud_id, $this->id);
     $rescount = 0;
     $sum = 0;
     foreach ($results as $res) {
         $score = $res->get_score();
         if (!empty($score) || $score == '0') {
             $rescount++;
             $sum += $score / $this->get_max();
         }
     }
     if ($rescount == 0) {
         return null;
     } else {
         if (isset($stud_id)) {
             return array($score, $this->get_max());
         } else {
             return array($sum, $rescount);
         }
     }
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:29,代码来源:evaluation.class.php

示例5: header

if (isset($_GET['resultdelete'])) {
    $result = Result::load($_GET['resultdelete']);
    $result[0]->delete();
    header('Location: gradebook_view_result.php?deleteresult=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
    exit;
}
if (isset($_POST['action'])) {
    $number_of_selected_items = count($_POST['id']);
    if ($number_of_selected_items == '0') {
        Display::display_warning_message(get_lang('NoItemsSelected'), false);
    } else {
        switch ($_POST['action']) {
            case 'delete':
                $number_of_deleted_results = 0;
                foreach ($_POST['id'] as $indexstr) {
                    $result = Result::load($indexstr);
                    $result[0]->delete();
                    $number_of_deleted_results++;
                }
                header('Location: gradebook_view_result.php?massdelete=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
                exit;
                break;
        }
    }
}
// TODO - what if selecteval not set ?
$addparams = array('selecteval' => $eval[0]->get_id());
if (isset($_GET['print'])) {
    $datagen = new ResultsDataGenerator($eval[0], $allresults);
    if (api_sort_by_first_name()) {
        $data_array = $datagen->get_data(ResultsDataGenerator::RDG_SORT_FIRSTNAME, 0, null, true);
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:gradebook_view_result.php

示例6: api_block_anonymous_users

api_block_anonymous_users();
GradebookUtils::block_students();
$select_eval = Security::remove_XSS($_GET['selecteval']);
if (empty($select_eval)) {
    api_not_allowed();
}
$resultedit = Result::load(null, null, $select_eval);
$evaluation = Evaluation::load($select_eval);
$evaluation[0]->check_lock_permissions();
$edit_result_form = new EvalForm(EvalForm::TYPE_ALL_RESULTS_EDIT, $evaluation[0], $resultedit, 'edit_result_form', null, api_get_self() . '?&selecteval=' . $select_eval);
$table = $edit_result_form->toHtml();
if ($edit_result_form->validate()) {
    $values = $edit_result_form->exportValues();
    $scores = $values['score'];
    foreach ($scores as $row) {
        $resultedit = Result::load(key($scores));
        $row_value = $row;
        if ($row_value != '') {
            $resultedit[0]->set_score(floatval(number_format($row_value, api_get_setting('gradebook.gradebook_number_decimals'))));
            $resultedit[0]->save();
        }
        next($scores);
    }
    header('Location: gradebook_view_result.php?selecteval=' . $select_eval . '&editallresults=&' . api_get_cidreq());
    exit;
}
$interbreadcrumb[] = array('url' => $_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
$interbreadcrumb[] = array('url' => 'gradebook_view_result.php?selecteval=' . $select_eval . '&' . api_get_cidreq(), 'name' => get_lang('ViewResult'));
Display::display_header(get_lang('EditResult'));
DisplayGradebook::display_header_result($evaluation[0], null, 0, 0);
echo $table;
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:gradebook_edit_result.php

示例7: array

}
$interbreadcrumb[] = array('url' => $_SESSION['gradebook_dest'] . '?selectcat=' . $currentcat[0]->get_id(), 'name' => get_lang('ToolGradebook'));
if (api_is_allowed_to_edit()) {
    $interbreadcrumb[] = array('url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']), 'name' => get_lang('ViewResult'));
}
$displayscore = ScoreDisplay::instance();
Display::display_header(get_lang('EvaluationStatistics'));
DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 0, 'statistics');
//Bad, Regular, Good  - User definitions
$displays = $displayscore->get_custom_score_display_settings();
if (!$displayscore->is_custom() || empty($displays)) {
    if (api_is_platform_admin() || api_is_course_admin()) {
        Display::display_error_message(get_lang('PleaseEnableScoringSystem'), false);
    }
} else {
    $allresults = Result::load(null, null, $eval[0]->get_id());
    $nr_items = array();
    foreach ($displays as $itemsdisplay) {
        $nr_items[$itemsdisplay['display']] = 0;
    }
    $resultcount = 0;
    foreach ($allresults as $result) {
        $score = $result->get_score();
        if (isset($score)) {
            $display = $displayscore->display_score(array($score, $eval[0]->get_max()), SCORE_CUSTOM, SCORE_ONLY_CUSTOM, true);
            $nr_items[$display]++;
            $resultcount++;
        }
    }
    $keys = array_keys($nr_items);
    // find the region with the most scores, this is 100% of the bar
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:gradebook_statistics.php

示例8: overwritescore

 public static function overwritescore($resid, $importscore, $eval_max)
 {
     $result = Result::load($resid);
     if ($importscore > $eval_max) {
         header('Location: gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '&overwritemax=');
         exit;
     }
     $result[0]->set_score($importscore);
     $result[0]->save();
     unset($result);
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:11,代码来源:GradebookUtils.php

示例9: transaction_33

 static function transaction_33($original_data, $web_service_details)
 {
     global $data_list;
     $data = Migration::soap_call($web_service_details, 'notaDetalles', array('uididpersona' => $original_data['item_id'], 'uididprograma' => $original_data['orig_id'], 'intIdSede' => $original_data['branch_id']));
     if ($data['error'] == false) {
         $uidIdPrograma = $original_data['orig_id'];
         $uidIdPersona = $original_data['item_id'];
         $score = $data['name'];
         $session_id = self::get_session_id_by_programa_id($uidIdPrograma, $data_list);
         $user_id = self::get_user_id_by_persona_id($uidIdPersona, $data_list);
         if (empty($user_id)) {
             return array('message' => "User does not exists in DB: {$uidIdPersona}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
         }
         if (empty($session_id)) {
             return array('message' => "Session does not exists in DB: {$uidIdPrograma}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
         }
         $course_list = SessionManager::get_course_list_by_session_id($session_id);
         if (!empty($course_list)) {
             $course_data = current($course_list);
             if (isset($course_data['code'])) {
                 $gradebook = new Gradebook();
                 $gradebook = $gradebook->get_first(array('where' => array('course_code = ? AND session_id = ?' => array($course_data['code'], $session_id))));
                 error_log("Looking gradebook in course code:  {$course_data['code']} - session_id: {$session_id}");
                 if (!empty($gradebook)) {
                     //Check if gradebook exists
                     $eval = new Evaluation();
                     $evals_found = $eval->load(null, null, null, $gradebook['id'], null, null);
                     //Try to create a gradebook evaluation
                     if (empty($evals_found)) {
                         error_log("Trying to create a new evaluation in course code:  {$course_data['code']} - session_id: {$session_id}");
                         $params = array('session_id' => $session_id, 'gradebook_description' => 'Evaluación General', 'gradebook_evaluation_type_id' => 0);
                         self::create_gradebook_evaluation($params);
                         $evals_found = $eval->load(null, null, null, $gradebook['id'], null, null);
                     }
                     if (!empty($evals_found)) {
                         $evaluation = current($evals_found);
                         $eval_id = $evaluation->get_id();
                         error_log("Gradebook exists: {$gradebook['id']} eval_id: {$eval_id}");
                         //Eval found
                         $res = new Result();
                         $check_result = Result::load(null, $user_id, $eval_id);
                         if (!empty($check_result) && isset($check_result[0])) {
                             // Gradebook result found. Updating...
                             $res->set_evaluation_id($eval_id);
                             $res->set_user_id($user_id);
                             $res->set_score($score);
                             $res->set_id($check_result[0]->get_id());
                             $res->save();
                             $eval_result = Result::load(null, $user_id, $eval_id);
                             return array('entity' => 'gradebook_evaluation_result', 'before' => $check_result, 'after' => $eval_result, 'message' => "Gradebook result edited ", 'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL);
                         } else {
                             // Gradebook result not found. Creating...
                             // @todo disable when moving to production
                             $res->set_evaluation_id($eval_id);
                             $res->set_user_id($user_id);
                             //if no scores are given, don't set the score
                             $res->set_score($score);
                             $res->add();
                             $eval_result = Result::load(null, $user_id, $eval_id);
                             //$message = "Gradebook result not modified because gradebook result does not exist for user_id: $user_id - eval_id: $eval_id - gradebook_id: {$gradebook['id']} - course: {$course_data['code']} - session_id: $session_id";
                             return array('entity' => 'gradebook_evaluation_result', 'before' => null, 'after' => $eval_result, 'message' => "Gradebook result added because it did not exist for update", 'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL);
                         }
                     } else {
                         $message = "Evaluation not found in gradebook: {$gradebook['id']} : in course: {$course_data['code']} - session_id: {$session_id}";
                     }
                 } else {
                     $message = "Gradebook does not exists in course: {$course_data['code']} - session_id: {$session_id}";
                 }
             } else {
                 $message = "Something is wrong with the course ";
             }
         } else {
             $message = "NO course found for session id: {$session_id}";
         }
         return array('message' => $message, 'status_id' => self::TRANSACTION_STATUS_FAILED);
     } else {
         return $data;
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:79,代码来源:migration.custom.class.php

示例10: calc_score

 /**
  * Calculate the score of this evaluation
  * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
  * @param string $type (best, average, ranking)
  * @return	array (score, max) if student is given
  * 			array (sum of scores, number of scores) otherwise
  * 			or null if no scores available
  */
 public function calc_score($stud_id = null, $type = null)
 {
     $results = Result::load(null, $stud_id, $this->id);
     $rescount = 0;
     $sum = 0;
     $bestResult = 0;
     $weight = 0;
     $sumResult = 0;
     $students = [];
     /** @var Result $res */
     foreach ($results as $res) {
         $score = $res->get_score();
         if (!empty($score) || $score == '0') {
             $rescount++;
             $sum += $score / $this->get_max();
             $sumResult += $score;
             if ($score > $bestResult) {
                 $bestResult = $score;
             }
             $weight = $this->get_max();
         }
         $students[$res->get_user_id()] = $score;
     }
     if ($rescount == 0) {
         return null;
     } else {
         if (isset($stud_id)) {
             return array($score, $this->get_max());
         } else {
             switch ($type) {
                 case 'best':
                     return array($bestResult, $weight);
                     break;
                 case 'average':
                     return array($sumResult / $rescount, $weight);
                     break;
                 case 'ranking':
                     return AbstractLink::getCurrentUserRanking($stud_id, $students);
                     break;
                 default:
                     return array($sum, $rescount);
                     break;
             }
         }
     }
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:54,代码来源:evaluation.class.php


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