Project

General

Profile

Bug #5695

Can not change the name of a learnpath

Added by Andre Boivin almost 9 years ago. Updated almost 9 years ago.

Status:
Bug resolved
Priority:
Normal
Assignee:
-
Category:
Learning paths / Lecciones
Target version:
Start date:
04/11/2012
Due date:
% Done:

80%

Estimated time:
Spent time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

Can not change the name of a learnpath in version 1.9.4 -nightly-2012-11-02
When I change the name of a learnpath, it does not change the main page of course. This is a recurring problem.


Files

image 1.png (15.6 KB) image 1.png Andre Boivin, 05/11/2012 20:40
image 2.png (9.58 KB) image 2.png Andre Boivin, 05/11/2012 20:40
learnpath.class.php (434 KB) learnpath.class.php Yoselyn Castillo, 08/11/2012 20:38
learnpath.class.php (434 KB) learnpath.class.php Yoselyn Castillo, 12/11/2012 21:15
learnpath.class.php (428 KB) learnpath.class.php Yoselyn Castillo, 21/11/2012 17:54
learnpath.class.php (427 KB) learnpath.class.php Yoselyn Castillo, 28/11/2012 12:58

Associated revisions

Revision 1095a3ae (diff)
Added by Yoselyn Castillo almost 9 years ago

Should fix bug when editing LP see #5695

Revision 166d17c7 (diff)
Added by Julio Montoya almost 9 years ago

Some fixes for latest changes see #5695

Revision 6f49df6e (diff)
Added by Yoselyn Castillo almost 9 years ago

Fixing toggle function see #5695

History

#1

Updated by Yoselyn Castillo almost 9 years ago

Can you specify a little more the problem? I have entered the course "opening course" in stable.chamilo.org and i have changed the name of a learnpath which was previously named LP1 and now it is named LP_1 and it worked fine.

#2

Updated by Andre Boivin almost 9 years ago

see the picture

#3

Updated by Yoselyn Castillo almost 9 years ago

  • Status changed from New to Assigned
  • Assignee changed from Yannick Warnier to Yoselyn Castillo

I will take this...

#4

Updated by Yoselyn Castillo almost 9 years ago

This fix is for making visible only one time the Learnpath in course home when name has been changed.
Now I am working in changing the name appeared in course home when the name of learnpath has been changed

#5

Updated by Julio Montoya almost 9 years ago

Hello Yoselyn, Can you mention where was you fix, in which lines?
only the function "toggle_publish" was changed?

#6

Updated by Julio Montoya almost 9 years ago

The learnpath.class.php has been changed

#7

Updated by Yoselyn Castillo almost 9 years ago

Upload New changes in learnpath.class.php. Fixed

#8

Updated by Andre Boivin almost 9 years ago

  • Status changed from Assigned to Bug resolved

Ok, tout fonctionne normalement.
Merci

#9

Updated by Julio Montoya almost 9 years ago

  • Status changed from Bug resolved to Needs more info
  • Assignee changed from Julio Montoya to Yoselyn Castillo

Hello Yoselyn can you answer my question in # 5?
the learnpath.class.php file has been change since you fix this issue.

#10

Updated by Yoselyn Castillo almost 9 years ago

  • Assignee changed from Yoselyn Castillo to Julio Montoya

Sorry i didn't realize you had answered me...
first:
Lines 36688-3689(sql query in toggle_publish function)
now:
Lines 3999-4006(set_name function)

#11

Updated by Julio Montoya almost 9 years ago

  • Assignee changed from Julio Montoya to Yoselyn Castillo

There was an error in your file: in function set_name line 4015 I fixed it.

$session_id = 
            $link

if (Database::affected_rows()) {
            $session_id = api_get_session_id();
            $session_condition = api_get_session_condition($session_id);
            $tbl_tool = Database :: get_course_table(TABLE_TOOL_LIST);
            $session_id = 
            $link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id.'&id_session='.$session_id;
            $sql = "UPDATE $tbl_tool SET name = '$this->name'
                    WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
            $res = Database::query($sql);
        }

Also in the toggle_publish() function there's a variable that is not used:

$row2 = Database :: fetch_array($result);

     $link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id.'&id_session='.$session_id;
        $sql = "SELECT * FROM $tbl_tool WHERE c_id = ".$course_id." AND link='$link' and image='scormbuilder.gif' and link LIKE '$link%' $session_condition";
        $result = Database::query($sql);
        $num = Database :: num_rows($result);
        $row2 = Database :: fetch_array($result);
        //if ($this->debug > 2) { error_log('New LP - '.$sql.' - '.$num, 0); }
        if (($set_visibility == 'i') && ($num > 0)) {
            $sql = "DELETE FROM $tbl_tool WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
        } elseif (($set_visibility == 'v') && ($num == 0)) {
            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) VALUES
                    ($course_id, '$name','$link','scormbuilder.gif','$v','0','pastillegris.gif',0, $session_id)";
        } elseif (($set_visibility == 'v') && ($num > 0)) {
            $sql = "UPDATE $tbl_tool SET c_id = $course_id, name = '$name', link = '$link', image = 'scormbuilder.gif', visibility = '$v', admin = '0', address = 'pastillegris.gif', added_tool = 0, session_id = $session_id
                    WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
        } else {
            // Parameter and database incompatible, do nothing.
        }
        $result = Database::query($sql);

Code was sent but both function need to be review again, what happen if $sql is empty?

#12

Updated by Yoselyn Castillo almost 9 years ago

  • Status changed from Needs more info to Assigned

The bug is fixed.
Enter in Learning path
Create a new learning path
Toggle publish in course home
See the course home. The new LP is created
Change the name of learnpath
See the course home again. The name of learnpath is correct
Anyway, i review the functions...

#13

Updated by Julio Montoya almost 9 years ago

The bug could be fixed but the code should be improved, by "improved" I mean fixing the suggestions above.

#14

Updated by Yoselyn Castillo almost 9 years ago

Well i have reviewed those functions, and a i have removed unnecessary variable declarations, and i have changed action if sql is empty in toggle_publish.
changed lines: 3682,3694,4007
Thanks for your suggestions. They are always welcomed.

#15

Updated by Julio Montoya almost 9 years ago

  • Assignee changed from Julio Montoya to Yoselyn Castillo

Code was sent, but in toggle_publish()

1. you forgot to secured the $lp_id variable with an intval or Database::escape_string
2. if the query below doesn't have a result what will happen? $name = domesticate($row['name']); will be null ...

$sql = "SELECT * FROM $tbl_lp where c_id = ".$course_id." AND id=$lp_id";
        $result = Database::query($sql);
        $row = Database :: fetch_array($result);
        $name = domesticate($row['name']);
        if ($set_visibility == 'i') {
            $s = $name . " " . get_lang('LearnpathNotPublished');
            $dialogBox = $s;
            $v = 0;
        }
#16

Updated by Yoselyn Castillo almost 9 years ago

Corrections in toggle_publish function

#17

Updated by Julio Montoya almost 9 years ago

  • Status changed from Assigned to Needs more info
  • Assignee deleted (Julio Montoya)

toggle_publish() function updated, code was sent

#18

Updated by Yoselyn Castillo almost 9 years ago

  • Status changed from Needs more info to Bug resolved

It works fine and the code has been improved.

Also available in: Atom PDF