skala
Julio Montoya 14 years ago
commit e4917b85fa
  1. 7
      main/exercice/admin.php
  2. 3
      main/exercice/exercise_report.php
  3. 147
      main/exercice/question_list_admin.inc.php
  4. 61
      main/exercice/question_pool.php

@ -52,7 +52,7 @@ require_once 'question.class.php';
require_once 'answer.class.php';
// Name of the language file that needs to be included
$language_file='exercice';
$language_file = 'exercice';
require_once '../inc/global.inc.php';
require_once 'exercise.lib.php';
@ -489,8 +489,7 @@ else {
// If we are in question_poolbut not in an test, go back to question create in pool
echo '<div class="actions">';
echo '<a href="question_pool.php">'.Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').'</a>';
echo '</div>';
echo '</div>';
}
if (isset($_GET['message'])) {
@ -522,4 +521,4 @@ if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspot
api_session_register('objExercise');
api_session_register('objQuestion');
api_session_register('objAnswer');
Display::display_footer();
Display::display_footer();

@ -336,9 +336,6 @@ $tpl->assign('content', $content);
$tpl->display_one_col_template();
*/
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results&exerciseId='.$exercise_id;
//$activeurl = '?sidx=session_active';

@ -146,36 +146,35 @@ unset($_SESSION['less_answer']);
$inATest = isset($exerciseId) && $exerciseId > 0;
if (!$inATest) {
echo "<p class='warning-message'>".get_lang("ChoiceQuestionType")."</p>";
}
else {
echo '<div id="question_list">';
} else {
echo '<div id="question_list">';
if ($nbrQuestions) {
$my_exercise = new Exercise();
//forces the query to the database
$my_exercise->read($_GET['exerciseId']);
$questionList=$my_exercise->selectQuestionList();
// -----------------------
// Style for columns
// -----------------------
$styleQuestion = "width:50%; float:left;";
$styleType = "width:4%; float:left; padding-top:4px; text-align:center;";
$styleCat = "width:22%; float:left; padding-top:8px; text-align:center;";
$styleLevel = "width:6%; float:left; padding-top:8px; text-align:center;";
$styleScore = "width:4%; float:left; padding-top:8px; text-align:center;";
$styleAction = "width:10%; float:left; padding-top:8px;";
// -------------
// Title line
// -------------
echo "<div>";
echo "<div style='font-weight:bold; width:50%; float:left; padding:10px 0px; text-align:center;'><span style='padding-left:50px;'>&nbsp;</span>".get_lang('Questions')."</div>";
echo "<div style='font-weight:bold; width:4%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Type')."</div>";
echo "<div style='font-weight:bold; width:22%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Category')."</div>";
echo "<div style='font-weight:bold; width:6%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Difficulty')."</div>";
echo "<div style='font-weight:bold; width:4%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Score')."</div>";
echo "</div>";
echo "<div style='clear:both'>&nbsp;</div>";
// -------------
if (is_array($questionList)) {
$my_exercise = new Exercise();
//forces the query to the database
$my_exercise->read($_GET['exerciseId']);
$questionList=$my_exercise->selectQuestionList();
// Style for columns
$styleQuestion = "width:50%; float:left;";
$styleType = "width:4%; float:left; padding-top:4px; text-align:center;";
$styleCat = "width:22%; float:left; padding-top:8px; text-align:center;";
$styleLevel = "width:6%; float:left; padding-top:8px; text-align:center;";
$styleScore = "width:4%; float:left; padding-top:8px; text-align:center;";
$styleAction = "width:10%; float:left; padding-top:8px;";
// Title line
echo "<div>";
echo "<div style='font-weight:bold; width:50%; float:left; padding:10px 0px; text-align:center;'><span style='padding-left:50px;'>&nbsp;</span>".get_lang('Questions')."</div>";
echo "<div style='font-weight:bold; width:4%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Type')."</div>";
echo "<div style='font-weight:bold; width:22%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Category')."</div>";
echo "<div style='font-weight:bold; width:6%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Difficulty')."</div>";
echo "<div style='font-weight:bold; width:4%; float:left; padding:10px 0px; text-align:center;'>".get_lang('Score')."</div>";
echo "</div>";
echo "<div style='clear:both'>&nbsp;</div>";
if (is_array($questionList)) {
foreach($questionList as $id) {
//To avoid warning messages
if (!is_numeric($id)) {
@ -195,67 +194,65 @@ else {
$delete_link = Display::tag('div',$delete_link, array('style'=>'float:left; padding:0px; margin:0px'));
$actions = Display::tag('div',$edit_link.$clone_link.$delete_link, array('class'=>'edition','style'=>'width:100px; right:10px; margin-top: 0px; position: absolute; top: 10%;'));
$title = Security::remove_XSS($objQuestionTmp->selectTitle());
$move = Display::return_icon('move.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
// ---------------------
// Question name
// ---------------------
$title = Security::remove_XSS($objQuestionTmp->selectTitle());
$move = Display::return_icon('move.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
// Question name
$questionName = Display::tag('div', '<a href="#" title = "'.$title.'">'.$move.' '.cut($title, 60).'</a>', array('style'=>$styleQuestion));
// ---------------------
// Question type
// ---------------------
$tabQuestionList = Question::get_types_information();
list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();
$questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), 32), array('style'=>$styleType));
// ---------------------
// Question category
// ---------------------
$txtQuestionCat = Security::remove_XSS(Testcategory::getCategoryNameForQuestion($objQuestionTmp->id));
if (empty($txtQuestionCat)) {
$txtQuestionCat = "-";
}
$questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;" title="'.$txtQuestionCat.'">'.cut($txtQuestionCat, 55).'</a>', array('style'=>$styleCat));
// ---------------------
// Question level
// ---------------------
$txtQuestionLevel = $objQuestionTmp->level;
if (empty($objQuestionTmp->level)) {
$txtQuestionLevel = '-';
}
$questionLevel = Display::tag('div', $txtQuestionLevel, array('style'=>$styleLevel));
// ---------------------
// Question score
// ---------------------
$questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style'=>$styleScore));
// ---------------------
echo '<div id="question_id_list_'.$id.'" >';
echo '<div class="header_operations">';
echo $questionName;
echo $questionType;
echo $questionCategory;
echo $questionLevel;
echo $questionScore;
echo $actions;
echo '</div>';
echo '<div class="question-list-description-block">';
echo '<p>';
//echo get_lang($question_class.$label);
echo get_lang($question_class);
echo '<br />';
//echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
echo '<br />';
showQuestion($id, false, '', '',false, true);
echo '</p>';
echo '</div>';
echo '</div>';
unset($objQuestionTmp);
}
echo '</div>';
if (empty($objQuestionTmp->level)) {
$txtQuestionLevel = '-';
}
$questionLevel = Display::tag('div', $txtQuestionLevel, array('style'=>$styleLevel));
// Question score
$questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style'=>$styleScore));
echo '<div id="question_id_list_'.$id.'" >';
echo '<div class="header_operations">';
echo $questionName;
echo $questionType;
echo $questionCategory;
echo $questionLevel;
echo $questionScore;
echo $actions;
echo '</div>';
echo '<div class="question-list-description-block">';
echo '<p>';
//echo get_lang($question_class.$label);
echo get_lang($question_class);
echo '<br />';
//echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
echo '<br />';
showQuestion($id, false, '', '',false, true);
echo '</p>';
echo '</div>';
echo '</div>';
unset($objQuestionTmp);
}
}
}
if(!$nbrQuestions) {
echo Display::display_warning_message(get_lang('NoQuestion'));
}
echo '</div>';
}
echo '</div>'; //question list div
}

@ -1,6 +1,4 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -10,13 +8,13 @@
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya adding support to query all questions from all session, courses, exercises
* Modify by hubert borderiou 2011-10-21 Question's category
* @author Modify by hubert borderiou 2011-10-21 Question's category
*/
/**
* Code
*/
// name of the language file that needs to be included
$language_file='exercice';
$language_file = 'exercice';
require_once 'exercise.class.php';
require_once 'question.class.php';
@ -89,31 +87,31 @@ $displayMessage = ""; // messag to be displayed if actions succesfull
if ($is_allowedToEdit) {
//Duplicating a Question
if (!isset($_POST['recup']) && $copy_question != 0 && isset($fromExercise)) {
$origin_course_id = intval($_GET['course_id']);
$origin_course_info = api_get_course_info_by_id($origin_course_id);
$current_course = api_get_course_info();
$old_question_id = $copy_question;
//Reading the source question
$origin_course_id = intval($_GET['course_id']);
$origin_course_info = api_get_course_info_by_id($origin_course_id);
$current_course = api_get_course_info();
$old_question_id = $copy_question;
//Reading the source question
$old_question_obj = Question::read($old_question_id, $origin_course_id);
if ($old_question_obj) {
$old_question_obj->updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy'));
//Duplicating the source question, in the current course
//Duplicating the source question, in the current course
$new_id = $old_question_obj->duplicate($current_course);
//Reading new question
//Reading new question
$new_question_obj = Question::read($new_id);
$new_question_obj->addToList($fromExercise);
//Reading Answers obj of the current course
//Reading Answers obj of the current course
$new_answer_obj = new Answer($old_question_id, $origin_course_id);
$new_answer_obj->read();
//Duplicating the Answers in the current course
//Duplicating the Answers in the current course
$new_answer_obj->duplicate($new_id, $current_course);
// destruction of the Question object
unset($new_question_obj);
unset($old_question_obj);
if (!$objExcercise instanceOf Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
if (!$objExcercise instanceOf Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
api_session_register('objExercise');
}
$displayMessage = get_lang('ItemAdded');
@ -124,15 +122,13 @@ if ($is_allowedToEdit) {
if ($delete) {
// construction of the Question object
// if the question exists
if($objQuestionTmp = Question::read($delete))
{
if($objQuestionTmp = Question::read($delete)) {
// deletes the question from all exercises
$objQuestionTmp->delete();
}
// destruction of the Question object
unset($objQuestionTmp);
}
elseif($recup && $fromExercise) {
} elseif($recup && $fromExercise) {
// gets an existing question and copies it into a new exercise
$objQuestionTmp = Question :: read($recup);
// if the question exists
@ -287,9 +283,7 @@ if (isset($type)) {
}
echo '<input type="hidden" name="fromExercise" value="'.$fromExercise.'">';
// ----------------------------------------------------
// Session list, if sessions are used.
// ----------------------------------------------------
$session_list = SessionManager::get_sessions_by_coach(api_get_user_id());
$tabAttrParam = array('class'=>'chzn-select', 'onchange'=>'submit_form(this)'); // when sessions are used
$labelFormRow = get_lang('Session');
@ -304,9 +298,7 @@ foreach($session_list as $item) {
$select_session_html = Display::select('session_id', $session_select_list, $session_id, $tabAttrParam);
echo Display::form_row($labelFormRow, $select_session_html); // hub 13-10-2011
// -----------------------------------------------------------------------------
// Course list, get course list of session, or for course where user is admin
// -----------------------------------------------------------------------------
if (!empty($session_id) && $session_id != '-1') {
$course_list = SessionManager::get_course_list_by_session_id($session_id);
} else {
@ -323,7 +315,7 @@ foreach ($course_list as $item) {
$select_course_html = Display::select('selected_course', $course_select_list, $selected_course, array('class'=>'chzn-select','onchange'=>'mark_course_id_changed(); submit_form(this);'));
echo Display::form_row(get_lang('Course'), $select_course_html);
$db_name = "";
if (empty($selected_course) || $selected_course == '-1') {
$course_info = api_get_course_info();
reset_menu_exo_lvl_type(); // no course selected, reset menu test / difficult<EFBFBD> / type de reponse // hub 13-10-2011
@ -374,15 +366,14 @@ if ($exercice_id_changed == 1) {
$select_exercise_html = Display::select('exerciseId', $my_exercise_list, $exerciseId, array('class'=>'chzn-select','onchange'=>'mark_exercice_id_changed(); submit_form(this);'), false);
echo Display::form_row(get_lang('Exercise'), $select_exercise_html);
//
// Difficulty list (only from 0 to 5)
//
$select_difficulty_html = Display::select('exerciseLevel', array(-1 => get_lang('All'), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5), $exerciseLevel, array('class'=>'chzn-select', 'onchange'=>'submit_form(this);'), false);
echo Display::form_row(get_lang('Difficulty'), $select_difficulty_html);
//
// Answer type
//
$question_list = Question::get_types_information();
$new_question_list = array();
$new_question_list['-1'] = get_lang('All');
@ -416,9 +407,9 @@ echo "<input type='hidden' id='exercice_id_changed' name='exercice_id_changed' v
<?php
echo '<input type="hidden" name="course_id" value="'.$selected_course.'">';
//
// if we have selected an exercise in the list-box 'Filter'
//
if ($exerciseId > 0) {
$where = '';
$from = '';
@ -565,7 +556,7 @@ else {
}
$nbrQuestions = count($main_question_list);
//
// build the line of the array to display questions
// Actions are different if you launch the question_pool page
// They are different too if you have displayed questions from your course
@ -654,9 +645,7 @@ Display::display_footer();
// =========================================================================
// Some functions here, just for question_pool to ease the code
// =========================================================================
/*
Put the menu entry for level and type to default "Choice"
@ -771,7 +760,6 @@ function get_action_icon_for_question($in_action, $from_exercice, $in_questionid
return $res;
}
//
// return the icon for the question type
// hubert.borderiou 13-10-2011
function get_question_type_for_question($in_selectedcourse, $in_questionid) {
@ -782,7 +770,6 @@ function get_question_type_for_question($in_selectedcourse, $in_questionid) {
return $questionType;
}
//
// return the name of the category for the question in a course
// hubert.borderiou 13-10-2011
function get_question_categorie_for_question($in_courseid, $in_questionid) {

Loading…
Cancel
Save