From efa6d5008e7f1c444601e8ac212cf8bd89485c54 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 23 Aug 2013 18:40:29 +0200 Subject: [PATCH] Redo changes after merge. --- main/exercice/exercise.class.php | 50 +++++++++++++++---- main/exercice/exercise_admin.php | 3 +- main/exercice/hotpotatoes.lib.php | 2 +- main/exercice/question.class.php | 10 ++-- .../question_list_pagination_admin.inc.php | 8 +-- 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 58b5fb4bb1..2238ce05ce 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -11,6 +11,8 @@ * Code */ use \ChamiloSession as Session; +use \ChamiloLMS\Transaction\TransactionLog; +use \ChamiloLMS\Transaction\TransactionLogController; // Page options define('ALL_ON_ONE_PAGE', 1); @@ -5867,20 +5869,28 @@ class Exercise //var_dump($categoryList); - $html = '
'; - $html .= '
'; + $html = '
'; + $html .= '
'; $reviewAnswerLabel = null; if ($this->review_answers) { - $reviewAnswerLabel = Display::label(get_lang('ToReview'), 'warning').'
'; + $reviewAnswerLabel = Display::label(sprintf(get_lang('ToReviewZ'),'c'), 'warning').'
'; } $currentAnswerLabel = null; if (!empty($current_question)) { - $currentAnswerLabel = Display::label(get_lang('CurrentQuestion'), 'info'); - } - $html .= Display::label(get_lang('Answered'), 'success').'
'.Display::label(get_lang('Unanswered')).'
'. - $reviewAnswerLabel.$currentAnswerLabel; - $html .= '
'; + $currentAnswerLabel = Display::label(sprintf(get_lang('CurrentQuestionZ'),'d'), 'info'); + } + // Count the number of answered, unanswered and 'for review' questions - see BT#6523 + $numa = count(array_flip(array_merge($exercise_result,$remindList))); + $numu = count($questionListFlatten)-$numa; + $numr = count($remindList); + $html .= Display::label(sprintf(get_lang('AnsweredZ'),'a'), 'success').'
'.Display::label(sprintf(get_lang('UnansweredZ'),'b')).'
'. + $reviewAnswerLabel.$currentAnswerLabel. + '

'. + sprintf(get_lang('AnsweredXYZ'),str_pad($numa,2,'0',STR_PAD_LEFT),'a','c').'
'. + sprintf(get_lang('UnansweredXYZ'),str_pad($numu,2,'0',STR_PAD_LEFT),'b').'
'. + sprintf(get_lang('ToReviewXYZ'),str_pad($numr,2,'0',STR_PAD_LEFT),'c').'
'. + '
'; $conditions = array(); $conditions[] = array("class" => 'answered', 'items' => $exercise_result); @@ -5888,7 +5898,7 @@ class Exercise $link = $url.'&num='; - $html .= '
'; + $html .= '
'; if (!empty($categoryList)) { $html .= $this->progressExercisePaginationBarWithCategories($categoryList, $current_question, $conditions, $link); } else { @@ -6127,8 +6137,8 @@ class Exercise } } $html .= '
'; - $html .= '
'.$categoryName.'
'; - $html .= '
'; + $html .= '
'.$categoryName.'
'; + $html .= '
'; if (!empty($nextValue)) { if ($wasMedia) { @@ -6673,6 +6683,24 @@ class Exercise '', array() ); + + $log_transactions_settings = TransactionLog::getTransactionSettings(); + if (isset($log_transactions_settings['exercise_attempt'])) { + $transaction_controller = new TransactionLogController(); + $transaction = $transaction_controller->loadOne(array( + 'action' => 'exercise_attempt', + 'branch_id' => TransactionLog::BRANCH_LOCAL, + 'item_id' => $exercise_stat_info['exe_id'], + ) + ); + if (!$transaction) { + $transaction_data = array( + 'item_id' => $exercise_stat_info['exe_id'], + ); + $transaction = $transaction_controller->createTransaction('exercise_attempt', $transaction_data); + } + $transaction->save(); + } } // Send notification. diff --git a/main/exercice/exercise_admin.php b/main/exercice/exercise_admin.php index 729083b060..28a2cd18f7 100644 --- a/main/exercice/exercise_admin.php +++ b/main/exercice/exercise_admin.php @@ -232,7 +232,8 @@ function setFocus(){ $(document).ready(function () { setFocus(); }); -window.onload = advanced_parameters; +//Commented only for Minedu (to show all options upfront) +//window.onload=advanced_parameters; '; // INIT EXERCISE diff --git a/main/exercice/hotpotatoes.lib.php b/main/exercice/hotpotatoes.lib.php index 273dd9add2..8cdbd63648 100644 --- a/main/exercice/hotpotatoes.lib.php +++ b/main/exercice/hotpotatoes.lib.php @@ -417,7 +417,7 @@ function HotPotGCt($folder, $flag, $user_id) { while (list($key, $val) = each($filelist)) { if (stristr($val, $user_id.'.t.html')) { if ($flag == 1) { - my_delete($folder.'/'.$val); + FileManager::my_delete($folder.'/'.$val); } else { echo $folder.'/'.$val.'
'; } diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index f57eb47472..9a2734ed84 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1499,8 +1499,8 @@ abstract class Question } // Level (difficulty). - $select_level = Question::get_default_levels(); - $form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level); + /*$select_level = Question::get_default_levels(); + $form->addElement('select', 'questionLevel', get_lang('Difficulty'), $select_level);*/ // Media question. @@ -1664,8 +1664,12 @@ abstract class Question if ($a_type[1] != 'FreeAnswer') { continue; } + } else { + //Skip other question types, just for minedu + if (!in_array($a_type[1],array('MediaQuestion','UniqueAnswer'))) { + continue; + } } - // include the class of the type require_once $a_type[0]; // get the picture of the type and the langvar which describes it diff --git a/main/exercice/question_list_pagination_admin.inc.php b/main/exercice/question_list_pagination_admin.inc.php index c86a1747f5..ee58e95524 100644 --- a/main/exercice/question_list_pagination_admin.inc.php +++ b/main/exercice/question_list_pagination_admin.inc.php @@ -34,8 +34,8 @@ $token = Security::get_token(); $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_question_list&exerciseId='.$exerciseId; //The order is important you need to check the the $column variable in the model.ajax.php file -$columns = array(get_lang('Questions'), get_lang('Type'), get_lang('Category'), get_lang('Difficulty'), get_lang('Score'), get_lang('Actions')); -//$columns = array(get_lang('Questions'), get_lang('Type'), get_lang('Category'), get_lang('Score')); +//$columns = array(get_lang('Questions'), get_lang('Type'), get_lang('Category'), get_lang('Difficulty'), get_lang('Score'), get_lang('Actions')); +$columns = array(get_lang('Questions'), get_lang('Type'), get_lang('Category'), get_lang('Score')); // Adding filtered question extra fields $extraField = new ExtraField('question'); @@ -64,13 +64,13 @@ $column_model = array( 'align' => 'left', 'sortable' => 'false' ), - array( + /*array( 'name' => 'level', 'index' => 'level', 'width' => '50', 'align' => 'left', 'sortable' => 'false' - ), + ),*/ array( 'name' => 'score', 'index' => 'score',