本文整理汇总了PHP中Exercise类的典型用法代码示例。如果您正苦于以下问题:PHP Exercise类的具体用法?PHP Exercise怎么用?PHP Exercise使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Exercise类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getQuestion
/** hack to Just Get A Question from current dmid, using Excercise class
* to do our factorying for us.
* Obviously the factory code needs to be refactored to ElseWhere, but not on Sunday
* :-P
* (Sun 15 Jun 2008)
*/
function getQuestion( $dmid, $questionLanguages, $answerLanguages ) {
if ( !$questionLanguages )
throw new Exception( "Vocview: no question (original) languages provided!" );
if ( !$answerLanguages )
throw new Exception( "Vocview: no answer (translation) languages provided!" );
/* 3 men walked into a bar^wExercise
* fullset, fetcher, and subset
*/
/* our regular fetcher is provided by functions.php
* I suppose if I were tidier, I could use fetchers for
* persistence
*/
$fetcher = new OWFetcher();
/* fullset is a domdocument containing a <collection> of
* empty <defined-meanings/> (just their defined-meaning-id
* attribute is set)
* This format makes sense on some days, it's just
* massive nukular overkill today, specially since
* we only have 1 element :-P
* Still, if Exercise wants this as a dom, we can oblige.
*/
$xmlString = "
<collection>
<defined-meaning defined-meaning-id=\"$dmid\" />
</collection>
";
$xml = simplexml_load_string( $xmlString );
$fullset = dom_import_simplexml( $xml )->ownerDocument;
# et voila.
/* subset is a selection of stuff we are actually
* interested in, from the above, as an array of
* dmid's .... Oh look! We have just one!
*/
$subset = array( $dmid ); # :-P
# (ok, to be honest, it does also get auto-generated
# from the fullset, if we say nothing... but
# then where would the joke be? )
# and we already had the fetcher.
# So the fullset said to the fetcher: let's do this!
$exercise = new Exercise( $fetcher, $fullset, $subset );
$exercise->setQuestionLanguages( $questionLanguages );
$exercise->setAnswerLanguages( $answerLanguages );
# Ok, now let's see. which question did we need?
# (and setting selfcheck to false)
$question = $exercise->getQuestion( $dmid, false );
# Oh REALLY! And we needed to go through all that?
# well, let's return it, before people start asking
# more difficult questions.
return $question;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:66,代码来源:vocview.php
示例2: __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
示例3: exercise_get
public function exercise_get($id = null)
{
$user = new User($this->user_id);
$exercise = new Exercise();
$exercise->where('id', $id);
$exercise->get();
$logs = $exercise->exerciselog;
$logs->get();
$response = array();
foreach ($logs as $log) {
array_push($response, $log->getData());
}
$this->response($response);
}
开发者ID:petersonb,项目名称:ourvigor,代码行数:14,代码来源:exerciselogs.php
示例4: getContent
protected function getContent()
{
$content = '<ol class="breadcrumb">
<li><a href="' . ROOT_DIR . 'admin/courseadmin">' . I18n::t('courseoverview.title') . '</a></li>
<li><a href="' . ROOT_DIR . 'admin/lessonadmin/' . $this->course->getId() . '">' . $this->course->getName(I18n::getLang()) . '</a></li>
<li class="active">' . $this->lesson->getName(I18n::getLang()) . '</li>
</ol>';
$content .= '<form method="post"><input type="hidden" name="action" value="saveExercises" />
<table id="exercise-admin-table" class="table table-hover">
<thead>
<tr>
<th>' . I18n::t('admin.exerciseadmin.question') . '</th>
<th>' . I18n::t('admin.exerciseadmin.answer') . ' (EN)</th>
<th>' . I18n::t('admin.exerciseadmin.answer') . ' (DE)</th>
<th> </th>
</tr>
</thead>
<tbody>';
foreach ((array) Exercise::getMultipleExercises($this->lesson->getId(), 50, 0) as $exercise) {
$content .= '<tr><input type="hidden" name="exercise_id[]" value="' . $exercise->getId() . '" />
<td><input type="text" name="question[]" value="' . $exercise->getQuestion() . '" /></td>
<td><input type="text" name="answer_en[]" value="' . $exercise->getAnswer('en') . '" /></td>
<td><input type="text" name="answer_de[]" value="' . $exercise->getAnswer('de') . '" /></td>
</tr>';
}
$content .= '</tbody>
</table>
<table width="100%">
<tr><td width="50%" align="left"><button id="exercise-add-btn" class="btn btn-default" type="button">' . I18n::t('button.add') . '</button></td>
<td width="50%" align="right"><input type="submit" class="btn btn-default" value="' . I18n::t('button.save') . '" /></td></tr>
</table>
</form>';
return $content;
}
开发者ID:stoeffu,项目名称:hiragana.ch,代码行数:34,代码来源:exerciseadminview.class.php
示例5: checkCode
public function checkCode()
{
Helpers::normalizeCode($this->code);
if (!($this->exercise = Exercise::model()->findByAttributes(array('code' => trim($this->code))))) {
$this->addError('code', Yii::t('swu', 'The code you entered does not exist.'));
}
}
开发者ID:loristissino,项目名称:swu,代码行数:7,代码来源:ExerciseInfoForm.php
示例6: main
function main() {
$collection_id = 376317; # olpc dictionary.... WAY too big
$fetcher = new OWFetcher();
echo "fullset...\n";
$fullSetXML = $fetcher->getFullSetXML_asString( $collection_id );
$fullSet = new DOMDocument();
$success = $fullSet->loadXML( $fullSetXML );
if ( !$success ) {
throw new Exception( "Failed to load category XML from server" );
}
$maxSubSet = dom2set( $fullSet );
# sort($maxSubSet); foreach ($maxSubSet as $dmid) {print "$dmid,";}
# var_dump($fullSet->saveXML());
$exercise = new Exercise( $fetcher, $fullSet, $maxSubSet ); # pwease, not the max!
# $exercise->setLanguages(array("eng","fra","deu"));
$exercise->setQuestionLanguages( array( "deu" ) );
$exercise->setAnswerLanguages( array( "eng" ) );
# $question_dmid=$maxSubSet[array_rand($maxSubSet)];
echo "question...\n";
# $questionNode=$exercise->getQuestionNode($question_dmid);
# dumpNode($questionNode);
$runex = $exercise->randSubExercise( 10 );
dumpExercise( $runex, 5 );
echo "\n\n=== presistence test ===\n\n";
saveExercise( $runex );
$exid = mysql_insert_id();
$loadex = loadExercise( $exid );
$loadex->setFetcher( $fetcher );
dumpExercise( $loadex, 10 );
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:39,代码来源:test.php
示例7: sendCodes
public function sendCodes($controller)
{
if (!($student = Student::model()->findByAttributes(array('email' => $this->email)))) {
return false;
}
$exercises = Exercise::model()->with('assignment')->sortByDuedate()->findAllByAttributes(array('student_id' => $student->id));
foreach ($exercises as $exercise) {
$exercise->link = Yii::app()->controller->createAbsoluteSslUrl('exercise/info', array('k' => $exercise->generateAckKey()));
}
$options = array();
if (Helpers::getYiiParam('addOriginatingIP')) {
$options['originating_IP'] = sprintf('[%s]', Yii::app()->request->userHostAddress);
}
return MailTemplate::model()->mailFromTemplate('send_codes', array($student->email => $student->name), array('student' => $student, 'exercises' => $exercises), $options);
}
开发者ID:loristissino,项目名称:swu,代码行数:15,代码来源:SendcodesForm.php
示例8: checkCode
public function checkCode()
{
if ($this->getError('verifyCode')) {
return;
// we don't provide any information about the code if the captcha is not valid
}
Helpers::normalizeCode($this->code);
if ($this->exercise = Exercise::model()->findByAttributes(array('code' => trim($this->code)))) {
if (!$this->byteacher and $this->exercise->duedate < date('Y-m-d H:m:s', time() - $this->exercise->assignment->grace * 24 * 60 * 60)) {
$this->addError('code', Yii::t('swu', 'The code provided is not valid anymore (time expired on %date%).', array('%date%' => $this->exercise->duedate)));
return;
}
} elseif ($this->code) {
$this->addError('code', Yii::t('swu', 'The code provided is not valid.'));
return;
}
}
开发者ID:loristissino,项目名称:swu,代码行数:17,代码来源:UploadForm.php
示例9: get
public function get($functionName, $linkName, $params = array(), $checkSession = true)
{
$positive = function ($input) {
//$input = $input[count($input)-1];
$result = Model::isEmpty();
$result['content'] = array();
foreach ($input as $inp) {
if ($inp->getNumRows() > 0) {
// extract exercise data from db answer
$res = Exercise::ExtractExercise($inp->getResponse(), false);
$result['content'] = array_merge($result['content'], is_array($res) ? $res : array($res));
$result['status'] = 200;
}
}
return $result;
};
$params = DBJson::mysql_real_escape_string($params);
return $this->_component->call($linkName, $params, '', 200, $positive, array(), 'Model::isProblem', array(), 'Query');
}
开发者ID:sawh,项目名称:ostepu-system,代码行数:19,代码来源:DBExercise.php
示例10: saveExercises
public function saveExercises()
{
$successful = true;
$updateAmount = isset($_POST['exercise_id']) && !empty($_POST['exercise_id']) ? count($_POST['exercise_id']) : 0;
$i = 0;
// update exercises that were present in DB already
while ($i < $updateAmount) {
$id = $this->secureString($_POST['exercise_id'][$i]);
$question = $this->secureString($_POST['question'][$i]);
$answerEN = $this->secureString($_POST['answer_en'][$i]);
$answerDE = $this->secureString($_POST['answer_de'][$i]);
// do not update exercises with empty fields
if (empty($id) || empty($question) || empty($answerEN) || empty($answerDE)) {
$i++;
continue;
}
if (!Exercise::update($id, $question, $answerEN, $answerDE)) {
$successful = false;
}
$i++;
}
// add new exercises to DB
while ($i < count($_POST['question'])) {
$question = $this->secureString($_POST['question'][$i]);
$answerEN = $this->secureString($_POST['answer_en'][$i]);
$answerDE = $this->secureString($_POST['answer_de'][$i]);
// do not add exercises with empty fields
if (empty($question) || empty($answerEN) || empty($answerDE)) {
$i++;
continue;
}
if (!Exercise::createExercise($this->lesson->getId(), $question, $answerEN, $answerDE)) {
$successful = false;
}
$i++;
}
if ($successful) {
$this->getView()->addSuccessMessage('Exercises were successfully saved!');
} else {
$this->getView()->addErrorMessage('There was a problem saving one or more exercises..');
}
$this->defaultAction();
}
开发者ID:stoeffu,项目名称:hiragana.ch,代码行数:43,代码来源:exerciseadmincontroller.class.php
示例11: loadExercise
function loadExercise( $exercise_id ) {
if ( !is_int( $exercise_id ) )
throw new Exception( "persist; loadExercise exercise_id is not an integer" );
global $mysql_info;
DBTools::connect( $mysql_info );
$exercise_id = mysql_real_escape_string( $exercise_id );
$row = DBTools::doQuery( "select * from exercises where id=\"$exercise_id\"" );
$exercise = new Exercise();
$exercise->setId( $exercise_id );
$exercise->loadXML( $row["exercise"] );
$exercise->setQuestionLanguages( explode( ",", $row["questionLanguages"] ) );
$exercise->setAnswerLanguages( explode( ",", $row["answerLanguages"] ) );
return $exercise;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:16,代码来源:persist.php
示例12: evaluate
public function evaluate()
{
if (isset($_POST['answer']) && !empty($_POST['answer'])) {
$input = $this->secureString($_POST['answer']);
$correct = $_SESSION['currentExercise']->getAnswer(I18n::getLang());
// trim whitespaces, remove not relevant characters in order to be more flexible with user input
$removedChars = '/(\\W+)|[0-9]|_/';
$input = trim($input);
$input = preg_replace($removedChars, '', $input);
$correct = trim($correct);
$correct = preg_replace($removedChars, '', $correct);
if (strtolower($input) === strtolower($correct)) {
$updated = Exercise::addCorrectAnswer($_SESSION['user']->getEmail(), $_SESSION['currentExercise']->getId());
if (!$updated) {
$this->getView()->addErrorMessage('Could not update DB.');
}
$this->getView()->addSuccessMessage(I18n::t('exercise.correct'));
} else {
$this->getView()->addErrorMessage(I18n::t('exercise.wrong'));
}
}
$this->defaultAction();
}
开发者ID:stoeffu,项目名称:hiragana.ch,代码行数:23,代码来源:exercisecontroller.class.php
示例13: isset
// general parameters passed via POST/GET
if (empty($origin)) {
$origin = Security::remove_XSS($_REQUEST['origin']);
}
/** @var Exercise $objExercise */
if (empty($objExercise)) {
$objExercise = Session::read('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->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info) && isset($exercise_stat_info['exe_exo_id'])) {
header("Location: overview.php?exerciseId=" . $exercise_stat_info['exe_exo_id']);
exit;
}
api_not_allowed();
}
if (api_is_in_gradebook()) {
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?' . api_get_cidreq(), 'name' => get_lang('ToolGradebook'));
}
$nameTools = get_lang('Exercises');
$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
if ($origin != 'learnpath') {
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:exercise_result.php
示例14: substr
}
if (isset($_REQUEST['quId']) && is_numeric($_REQUEST['quId'])) {
$quId = (int) $_REQUEST['quId'];
} else {
$quId = null;
}
if (isset($_REQUEST['filter'])) {
$filter = $_REQUEST['filter'];
} else {
$filter = 'all';
}
$categoryId = substr($filter, 0, 10) == 'categoryId' && is_numeric(substr($filter, 10)) ? substr($filter, 10) : null;
/*
* Init other vars
*/
$exercise = new Exercise();
if (!is_null($exId)) {
$exercise->load($exId);
}
$dialogBox = new DialogBox();
/*
* Execute commands
*/
// use question in exercise
if ($cmd == 'rqUse' && !is_null($quId) && !is_null($exId)) {
if ($exercise->addQuestion($quId)) {
// TODO show confirmation and back link
header('Location: ' . Url::Contextualize('edit_exercise.php?exId=' . $exId));
}
}
// delete question
开发者ID:rhertzog,项目名称:lcs,代码行数:31,代码来源:question_pool.php
示例15: isset
<?php
/* See license terms in /license.txt */
//require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
$exercise_id = isset($_GET['exerciseId']) && !empty($_GET['exerciseId']) ? intval($_GET['exerciseId']) : 0;
// Access control
api_protect_course_script(true);
if (!api_is_allowed_to_edit()) {
api_not_allowed();
}
$objExercise = new Exercise();
$result = $objExercise->read($exercise_id);
if (!$result) {
api_not_allowed(true);
}
$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
$interbreadcrumb[] = array("url" => "admin.php?exerciseId={$exercise_id}&" . api_get_cidreq(), "name" => $objExercise->name);
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
// The header.
Display::display_header(get_lang('StudentsWhoAreTakingTheExerciseRightNow'));
//jqgrid will use this URL to do the selects
$minutes = 60;
$url = api_get_path(WEB_AJAX_PATH) . 'exercise.ajax.php?a=get_live_stats&exercise_id=' . $objExercise->id . '&minutes=' . $minutes;
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
//Column config
$column_model = array(array('name' => 'firstname', 'index' => 'firstname', 'width' => '100', 'align' => 'left'), array('name' => 'lastname', 'index' => 'lastname', 'width' => '100', 'align' => 'left'), array('name' => 'start_date', 'index' => 'start_date', 'width' => '100', 'align' => 'left'), array('name' => 'question', 'index' => 'count_questions', 'width' => '60', 'align' => 'left', 'sortable' => 'false'), array('name' => 'score', 'index' => 'score', 'width' => '50', 'align' => 'left', 'sortable' => 'false'));
//Autowidth
$extra_params['autowidth'] = 'true';
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:live_stats.php
示例16: scorm_export
//.........这里部分代码省略.........
}
} else {
$organization->appendChild($my_item);
}
$my_file_path = 'link_' . $item->get_id() . '.html';
$sql = 'SELECT url, title FROM ' . Database::get_course_table(TABLE_LINK) . ' WHERE id=' . $item->path;
$rs = Database::query($sql, __FILE__, __LINE__);
if ($link = Database::fetch_array($rs)) {
$url = $link['url'];
$title = stripslashes($link['title']);
$links_to_create[$my_file_path] = array('title' => $title, 'url' => $url);
$my_xml_file_path = api_htmlentities($my_file_path, ENT_QUOTES, $this->encoding);
$my_sub_dir = dirname($my_file_path);
$my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_QUOTES, $this->encoding);
//give a <resource> child to the <resources> element
$my_resource = $xmldoc->createElement('resource');
$my_resource->setAttribute('identifier', 'RESOURCE_' . $item->get_id());
$my_resource->setAttribute('type', 'webcontent');
$my_resource->setAttribute('href', $my_xml_file_path);
//adlcp:scormtype can be either 'sco' or 'asset'
$my_resource->setAttribute('adlcp:scormtype', 'asset');
//xml:base is the base directory to find the files declared in this resource
$my_resource->setAttribute('xml:base', '');
//give a <file> child to the <resource> element
$my_file = $xmldoc->createElement('file');
$my_file->setAttribute('href', $my_xml_file_path);
$my_resource->appendChild($my_file);
$resources->appendChild($my_resource);
}
} elseif ($item->type == TOOL_QUIZ) {
require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php';
$exe_id = $item->path;
//should be using ref when everything will be cleaned up in this regard
$exe = new Exercise();
$exe->read($exe_id);
$my_item = $xmldoc->createElement('item');
$my_item->setAttribute('identifier', 'ITEM_' . $item->get_id());
$my_item->setAttribute('identifierref', 'RESOURCE_' . $item->get_id());
$my_item->setAttribute('isvisible', 'true');
//give a child element <title> to the <item> element
$my_title = $xmldoc->createElement('title', htmlspecialchars($item->get_title(), ENT_QUOTES, $this->encoding));
$my_item->appendChild($my_title);
$my_max_score = $xmldoc->createElement('max_score', $item->get_max());
//$my_item->appendChild($my_max_score);
//give a child element <adlcp:prerequisites> to the <item> element
$my_prereqs = $xmldoc->createElement('adlcp:prerequisites', $item->get_prereq_string());
$my_prereqs->setAttribute('type', 'aicc_script');
$my_item->appendChild($my_prereqs);
//give a child element <adlcp:masteryscore> to the <item> element
$my_masteryscore = $xmldoc->createElement('adlcp:masteryscore', $item->get_mastery_score());
$my_item->appendChild($my_masteryscore);
//attach this item to the organization element or hits parent if there is one
if (!empty($item->parent) && $item->parent != 0) {
$children = $organization->childNodes;
for ($i = 0; $i < $children->length; $i++) {
$item_temp = $children->item($i);
if ($item_temp->nodeName == 'item') {
if ($item_temp->getAttribute('identifier') == 'ITEM_' . $item->parent) {
$item_temp->appendChild($my_item);
}
}
}
} else {
$organization->appendChild($my_item);
}
//include export scripts
开发者ID:Eidn,项目名称:shanghai,代码行数:67,代码来源:learnpath.class.php
示例17: array
$interbreadcrumb[] = array("url" => "admin.php?exerciseId=" . $exercise_id . "&" . api_get_cidreq(), "name" => $objExerciseTmp->name);
}
} else {
$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
$objExerciseTmp = new Exercise();
if ($objExerciseTmp->read($exercise_id)) {
$nameTools = get_lang('Results') . ': ' . $objExerciseTmp->name;
}
}
Display::display_header($nameTools);
// Clean all results for this test before the selected date
if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete_before_date']) && $locked == false) {
// ask for the date
$check = Security::check_token('get');
if ($check) {
$objExerciseTmp = new Exercise();
if ($objExerciseTmp->read($exercise_id)) {
$count = $objExerciseTmp->clean_results(true, $_GET['delete_before_date'] . ' 23:59:59');
Display::display_confirmation_message(sprintf(get_lang('XResultsCleaned'), $count));
}
}
}
// Security token to protect deletion
$token = Security::get_token();
$actions = Display::div($actions, array('class' => 'actions'));
$extra = '<script>
$(document).ready(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: "blind",
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:exercise_report.php
示例18: 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
示例19: getQuestions
//.........这里部分代码省略.........
$inject_where = $conditions['inject_where'];
$inject_extra_fields = $conditions['inject_extra_fields'];
$order = $conditions['order'];
$limit = $conditions['limit'];
if ($get_count == true) {
$select = " SELECT count(*) as total_rows";
} else {
$select = " SELECT s.*, {$inject_extra_fields} {$inject_question_fields} 1 ";
}
$extraCondition = null;
// Used by the question manager
if (!empty($categoryId)) {
$categoryRelQuestionTable = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$extraCondition = " INNER JOIN {$categoryRelQuestionTable} c ON (s.iid = c.question_id)";
$categoryId = intval($categoryId);
$where .= " AND category_id = {$categoryId} ";
}
/*if (!empty($exerciseId)) {
$exerciseRelQuestionTable = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$extraCondition .= " INNER JOIN $exerciseRelQuestionTable e ON (s.iid = e.question_id)";
$exerciseId = intval($exerciseId);
$where .= " AND exercice_id = $exerciseId ";
}*/
// Orphan questions
if ($isOrphanQuestion) {
//$exerciseRelQuestionTable = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
//$extraCondition .= " INNER JOIN $exerciseRelQuestionTable e ON (s.iid = e.question_id)";
$where .= " OR quizexercise.active = -1 OR quiz_rel_question.exercice_id IS NULL";
}
if (!empty($courseId)) {
$courseId = intval($courseId);
$where .= " AND s.c_id = {$courseId} ";
}
if (isset($options['question'])) {
$courseList = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
foreach ($options['question'] as $questionOption) {
if ($questionOption['field'] == 'question_c_id') {
if (isset($questionOption['data'])) {
if (!isset($courseList[$questionOption['data']])) {
return array();
}
}
}
}
}
//var_dump(CourseManager::get_teacher_list_from_course_code())
//var_dump($inject_joins);
$query = " {$select} FROM {$questionTable} s {$inject_joins} {$extraCondition} WHERE 1=1 {$where} {$inject_where} {$order} {$limit}";
//echo $query.'<br />';
//var_dump($extraCondition);
//var_dump($where);
$result = Database::query($query);
$questions = array();
$exerciseList = null;
if (!empty($exerciseId)) {
$exercise = new Exercise();
$exercise->read($exerciseId);
$exerciseList = $exercise->questionList;
}
if (Database::num_rows($result)) {
$questions = Database::store_result($result, 'ASSOC');
if ($get_count) {
return $questions[0]['total_rows'];
}
$previewIcon = Display::return_icon('preview.gif', get_lang('View'), array(), ICON_SIZE_SMALL);
$copyIcon = Display::return_icon('copy.png', get_lang('Copy'), array(), ICON_SIZE_SMALL);
$reuseIcon = Display::return_icon('view_more_stats.gif', get_lang('InsertALinkToThisQuestionInTheExercise'), array(), ICON_SIZE_SMALL);
$editIcon = Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL);
//$deleteIcon = Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL);
//var_dump($exerciseId);
// Including actions
foreach ($questions as &$question) {
$type = self::get_question_type($question['type']);
$question['type'] = get_lang($type[1]);
$question['question_question_type'] = get_lang($type[1]);
if (empty($exerciseId)) {
// View.
$actions = Display::url($previewIcon, $app['url_generator']->generate('admin_questions_show', array('id' => $question['iid'])));
// Edit.
$actions .= Display::url($editIcon, $app['url_generator']->generate('admin_questions_edit', array('id' => $question['iid'])));
} else {
// View.
$actions = Display::url($previewIcon, $app['url_generator']->generate('question_show', array('cidReq' => api_get_course_id(), 'id_session' => api_get_session_id(), 'exerciseId' => $exerciseId, 'id' => $question['iid'])));
if (isset($exerciseList) && !empty($exerciseList) && in_array($question['iid'], $exerciseList)) {
// Copy.
//$actions .= $copyIconDisabled;
} else {
// Copy.
$actions .= Display::url($copyIcon, 'javascript:void(0);', array('onclick' => 'ajaxAction(this);', 'data-url' => $app['url_generator']->generate('exercise_copy_question', array('cidReq' => api_get_course_id(), 'id_session' => api_get_session_id(), 'questionId' => $question['iid'], 'exerciseId' => $exerciseId))));
// Reuse.
$actions .= Display::url($reuseIcon, 'javascript:void(0);', array('onclick' => 'ajaxAction(this);', 'data-url' => $app['url_generator']->generate('exercise_reuse_question', array('cidReq' => api_get_course_id(), 'id_session' => api_get_session_id(), 'questionId' => $question['iid'], 'exerciseId' => $exerciseId))))
|
请发表评论