Fixing copy course due the recent changes in the exercise tool (iid field added) see BT#5638

skala
Julio Montoya 12 years ago
parent 3aa0f0b280
commit 84908ccdcb
  1. 3
      main/coursecopy/classes/CourseBuilder.class.php
  2. 20
      main/coursecopy/classes/CourseRestorer.class.php
  3. 10
      main/coursecopy/classes/CourseSelectForm.class.php
  4. 9
      main/coursecopy/classes/Quiz.class.php
  5. 7
      main/coursecopy/classes/QuizQuestion.class.php
  6. 1
      main/exercice/exercise.class.php
  7. 6
      main/exercice/exercise_submit.php
  8. 2
      main/inc/lib/document.lib.php

@ -480,13 +480,14 @@ class CourseBuilder {
// Building normal tests.
$sql = "SELECT * FROM $table_que WHERE c_id = $course_id ";
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) {
$categories = Testcategory::getCategoryForQuestionWithCategoryData($obj->iid, $course_id, true);
$parent_info = array();
if (isset($obj->parent_id) && !empty($obj->parent_id)) {
$parent_info = (array) Question::read($obj->parent_id, $course_id);
$parent_info = (array)Question::read($obj->parent_id, $course_id);
}
$question = new QuizQuestion($obj->iid, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra, $parent_info, $categories);

@ -41,17 +41,17 @@ class CourseRestorer
/**
* The course-object
*/
var $course;
var $destination_course_info;
public $course;
public $destination_course_info;
/**
* What to do with files with same name (FILE_SKIP, FILE_RENAME or
* FILE_OVERWRITE)
*/
var $file_option;
var $set_tools_invisible_by_default;
var $skip_content;
var $tools_to_restore = array(
public $file_option;
public $set_tools_invisible_by_default;
public $skip_content;
public $tools_to_restore = array(
'announcements',
'attendance',
'course_descriptions',
@ -72,18 +72,18 @@ class CourseRestorer
);
/** Setting per tool */
var $tool_copy_settings = array();
public $tool_copy_settings = array();
/**
* If true adds the text "copy" in the title of an item (only for LPs right now)
*
* */
var $add_text_in_items = false;
public $add_text_in_items = false;
/**
* Create a new CourseRestorer
*/
function __construct($course)
public function __construct($course)
{
$this->course = $course;
$course_info = api_get_course_info($this->course->code);
@ -1576,7 +1576,7 @@ class CourseRestorer
$parent_id = 0;
if (isset($question->parent_info)) {
if (isset($question->parent_info) && !empty($question->parent_info)) {
$question_obj = Question::readByTitle($question->parent_info['question'], $this->destination_course_id);
if ($question_obj) {

@ -360,7 +360,7 @@ class CourseSelectForm
//Create the resource DOCUMENT objects
//Loading the results from the checkboxes of ethe javascript
$resource = $_POST['resource'][RESOURCE_DOCUMENT];
$resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
$course_info = api_get_course_info($course_code);
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
@ -471,9 +471,9 @@ class CourseSelectForm
// Mark folders to import which are not selected by the user to import,
// but in which a document was selected.
$documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null;
if (is_array($resources))
if (!empty($resources) && is_array($resources))
foreach($resources as $id => $obj) {
if ($obj->file_type == 'folder' && ! isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && is_array($documents)) {
if (isset($obj->file_type) && $obj->file_type == 'folder' && !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && is_array($documents)) {
foreach($documents as $id_to_check => $post_value) {
$obj_to_check = $resources[$id_to_check];
$shared_path_part = substr($obj_to_check->path,0,strlen($obj->path));
@ -485,8 +485,8 @@ class CourseSelectForm
}
}
default :
if (is_array($resources)) {
foreach ($resources as $id => $obj) {
if (!empty($resources) && is_array($resources)) {
foreach($resources as $id => $obj) {
$resource_is_used_elsewhere = $course->is_linked_resource($obj);
//var_dump($obj, $resource_is_used_elsewhere);
// check if document is in a quiz (audio/video)

@ -27,7 +27,8 @@ class Quiz extends Resource
*/
public $obj; //question
function Quiz($obj) {
function Quiz($obj)
{
$this->obj = $obj;
$this->obj->quiz_type = $this->obj->type;
parent::Resource($obj->iid, RESOURCE_QUIZ);
@ -36,7 +37,8 @@ class Quiz extends Resource
/**
* Add a question to this Quiz
*/
function add_question($id, $question_order) {
function add_question($id, $question_order)
{
$this->obj->question_ids[] = $id;
$this->obj->question_orders[] = $question_order;
}
@ -44,7 +46,8 @@ class Quiz extends Resource
/**
* Show this question
*/
function show() {
function show()
{
parent::show();
echo $this->obj->title;
}

@ -59,6 +59,7 @@ class QuizQuestion extends Resource
public $picture;
public $extra;
public $categories;
public $parent_info;
/**
* Create a new QuizQuestion
@ -68,7 +69,8 @@ class QuizQuestion extends Resource
* @param int $type
* @param int $position
*/
function QuizQuestion($id, $question, $description, $ponderation, $type, $position, $picture, $level, $extra, $parent_info, $categories) {
function QuizQuestion($id, $question, $description, $ponderation, $type, $position, $picture, $level, $extra, $parent_info, $categories)
{
parent::Resource($id, RESOURCE_QUIZQUESTION);
$this->question = $question;
$this->description = $description;
@ -86,7 +88,8 @@ class QuizQuestion extends Resource
/**
* Add an answer to this QuizQuestion
*/
function add_answer($answer_id, $answer_text, $correct, $comment, $ponderation, $position, $hotspot_coordinates, $hotspot_type) {
function add_answer($answer_id, $answer_text, $correct, $comment, $ponderation, $position, $hotspot_coordinates, $hotspot_type)
{
$answer = array();
$answer['iid'] = $answer_id;
$answer['answer'] = $answer_text;

@ -4589,6 +4589,7 @@ class Exercise
{
$media_questions = array();
$question_list = $this->get_validated_question_list();
if (!empty($question_list)) {
foreach ($question_list as $questionId) {
$objQuestionTmp = Question::read($questionId);

@ -378,7 +378,6 @@ if (api_is_allowed_to_edit(null,true) && isset($_GET['preview']) && $_GET['previ
}
// 1. Loading the $objExercise variable
if (!isset($_SESSION['objExercise']) || $_SESSION['objExercise']->id != $_REQUEST['exerciseId']) {
// Construction of Exercise
$objExercise = new Exercise();
@ -873,7 +872,6 @@ if ($objExercise->type == ONE_PER_PAGE) {
$exercise_result = get_answered_questions_from_attempt($exe_id, $objExercise);
$conditions = array();
$conditions[] = array("class" => 'remind', 'items' => $my_remind_list);
//$conditions[] = array("class" => 'not_answered', 'items' => $exercise_result, 'type' => 'negative');
$conditions[] = array("class" => 'answered', 'items' => $exercise_result);
$link = api_get_self().'?'.$params.'&num=';
echo Display::progress_pagination_bar($questionList, $current_question, $conditions, $link);
@ -1017,8 +1015,8 @@ if ($objExercise->review_answers) {
if (!empty($error)) {
Display :: display_error_message($error, false);
} else {
if (!empty ($exercise_sound)) {
echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . Security::remove_XSS($exercise_sound) . "\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound') . "\" /></a>";
if (!empty($exercise_sound)) {
echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F".Security::remove_XSS($exercise_sound)."\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound') . "\" /></a>";
}
// Get number of hotspot questions for javascript validation
$number_of_hotspot_questions = 0;

@ -2047,7 +2047,7 @@ class DocumentManager
$checked_files_list = array();
$checked_array_list = array();
if (count($files_list) > 0) {
if (!empty($files_list) && count($files_list) > 0) {
foreach ($files_list as $idx => $file) {
if (!empty($file[0])) {
if (!in_array($file[0], $checked_files_list)) {

Loading…
Cancel
Save