[svn r13105] Allowed distinction between visibility on the course homepage and visibility in the tool page

Now inserting and updating learnpaths in item_property (and using visibility settings from there)
skala
Yannick Warnier 18 years ago
parent 9b96fc43f2
commit a0ddabe12f
  1. 22
      main/newscorm/learnpath.class.php
  2. 9
      main/newscorm/learnpathList.class.php
  3. 15
      main/newscorm/lp_controller.php
  4. 26
      main/newscorm/lp_list.php

@ -603,7 +603,7 @@ class learnpath {
$id = Database::get_last_insert_id();
if($id>0){
//insert into item_property
api_item_property_update(api_get_course_info($course),TOOL_LEARNPATH,$id,'LearnpathAdded',api_get_user_id());
api_item_property_update(api_get_course_info(),TOOL_LEARNPATH,$id,'LearnpathAdded',api_get_user_id());
return $id;
}
break;
@ -2836,9 +2836,27 @@ class learnpath {
* @param string New visibility
*/
function toggle_visibility($lp_id,$set_visibility='v')
function toggle_visibility($lp_id,$set_visibility=1)
{
//if($this->debug>0){error_log('New LP - In learnpath::toggle_visibility()',0);}
$action = 'visible';
if($set_visibility != 1)
{
$action = 'invisible';
}
return api_item_property_update(api_get_course_info(),TOOL_LEARNPATH,$lp_id,$action,api_get_user_id());
}
/**
* Publishes a learnpath. This basically means show or hide the learnpath
* on the course homepage
* Can be used as abstract
* @param integer Learnpath ID
* @param string New visibility
*/
function toggle_publish($lp_id,$set_visibility='v')
{
//if($this->debug>0){error_log('New LP - In learnpath::toggle_publish()',0);}
$tbl_lp = Database::get_course_table('lp');
$sql="SELECT * FROM $tbl_lp where id=$lp_id";
$result=api_sql_query($sql,__FILE__,__LINE__);

@ -40,6 +40,8 @@ class learnpathList {
$names = array();
while ($row = Database::fetch_array($res))
{
//check if published
$pub = '';
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
//use domesticate here instead of mysql_real_escape_string because
//it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility())
@ -51,10 +53,12 @@ class learnpathList {
$res2 = api_sql_query($sql2,__FILE__,__LINE__);
if(Database::num_rows($res2)>0){
$row2 = Database::fetch_array($res2);
$vis = $row2['visibility'];
$pub = $row2['visibility'];
}else{
$vis = 'i';
$pub = 'i';
}
//check if visible
$vis = api_get_item_visibility(api_get_course_info($course_code),'learnpath',$row['id']);
$this->list[$row['id']] = array(
'lp_type' => $row['lp_type'],
@ -68,6 +72,7 @@ class learnpathList {
'lp_encoding' => $row['default_encoding'],
'lp_progress' => $row['progress'],
'lp_visibility' => $vis,
'lp_published' => $pub,
'lp_prevent_reinit' => $row['prevent_reinit'],
'lp_scorm_debug' => $row['debug'],
);

@ -471,14 +471,25 @@ switch($_REQUEST['action'])
require('lp_list.php');
}
break;
case 'toggle_visible': //change lp visibility
case 'toggle_visible': //change lp visibility (inside lp tool)
if(!api_is_allowed_to_edit()){
api_not_allowed(true);
}
if($debug>0) error_log('New LP - visibility action triggered',0);
if(!$lp_found){ error_log('New LP - No learnpath given for visibility',0); require('lp_list.php'); }
else{
learnpath::toggle_visibility($_REQUEST['lp_id'],$_REQUEST['new_status']);
require('lp_list.php');
}
break;
case 'toggle_publish': //change lp published status (visibility on homepage)
if(!api_is_allowed_to_edit()){
api_not_allowed(true);
}
if($debug>0) error_log('New LP - publish action triggered',0);
if(!$lp_found){ error_log('New LP - No learnpath given for publish',0); require('lp_list.php'); }
else{
learnpath::toggle_visibility($_REQUEST['lp_id'],$_REQUEST['new_status']);
learnpath::toggle_publish($_REQUEST['lp_id'],$_REQUEST['new_status']);
require('lp_list.php');
}
break;

@ -173,7 +173,7 @@ if (is_array($flat_list))
$counter = 0;
foreach ($flat_list as $id => $details)
{
if(!$is_allowed_to_edit && $details['lp_visibility'] == "i")
if(!$is_allowed_to_edit && $details['lp_visibility'] == 0)
{
// This is a student and this path is invisible, skip
continue;
@ -245,20 +245,36 @@ if (is_array($flat_list))
/* VISIBILITY COMMAND */
if ($details['lp_visibility'] == "i")
if ($details['lp_published'] == "i")
{
$dsp_visible = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=v\">" .
$dsp_publish = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=v\">" .
"<img src=\"../img/invisible_LP_list.gif\" border=\"0\" title=\"".get_lang('_publish')."\" />" .
"</a>" .
"";
}
else
{
$dsp_visible = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=i'>" .
$dsp_publish = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=i'>" .
"<img src=\"../img/visible_LP_list.gif\" border=\"0\" title=\"".get_lang('_no_publish')."\" />" .
"</a>".
"";
}
/* VISIBILITY COMMAND */
if ($details['lp_visibility'] == 0)
{
$dsp_visible = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=1\">" .
"<img src=\"../img/invisible.gif\" border=\"0\" title=\"".get_lang('Show')."\" />" .
"</a>" .
"";
}
else
{
$dsp_visible = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=0'>" .
"<img src=\"../img/visible.gif\" border=\"0\" title=\"".get_lang('Hide')."\" />" .
"</a>".
"";
}
/* Default view mode settings (fullscreen/embedded) */
if($details['lp_view_mode'] == 'fullscreen'){
$dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
@ -309,7 +325,7 @@ if (is_array($flat_list))
}
} // end if($is_allowedToEdit)
//echo $dsp_line.$dsp_desc.$dsp_export.$dsp_edit.$dsp_delete.$dsp_visible;
echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_reinit.$dsp_default_view.$dsp_force_commit.$dsp_debug.$dsp_delete;
echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_publish.$dsp_reinit.$dsp_default_view.$dsp_force_commit.$dsp_debug.$dsp_delete;
//echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_reinit.$dsp_force_commit.$dsp_delete;
echo "</tr>\n";

Loading…
Cancel
Save