dokeos-course_home
[ class tree: dokeos-course_home ] [ index: dokeos-course_home ] [ all elements ]

Source for file activity.php

Documentation is available at activity.php

  1. <?php // $Id: activity.php,v 1.5 2006/08/10 14:34:54 pcool Exp $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004-2005 Dokeos S.A.
  7.     Copyright (c) 2003 Ghent University
  8.     Copyright (c) 2001 Universite Catholique de Louvain
  9.     Copyright (c) various contributors
  10.  
  11.     For a full list of contributors, see "credits.txt".
  12.     The full license can be read in "license.txt".
  13.  
  14.     This program is free software; you can redistribute it and/or
  15.     modify it under the terms of the GNU General Public License
  16.     as published by the Free Software Foundation; either version 2
  17.     of the License, or (at your option) any later version.
  18.  
  19.     See the GNU General Public License for more details.
  20.  
  21.     Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  22.     Mail: info@dokeos.com
  23. ==============================================================================
  24. */
  25. /**
  26. ==============================================================================
  27. *         HOME PAGE FOR EACH COURSE
  28. *
  29. *    This page, included in every course's index.php is the home
  30. *    page. To make administration simple, the teacher edits his
  31. *    course from the home page. Only the login detects that the
  32. *    visitor is allowed to activate, deactivate home page links,
  33. *    access to the teachers tools (statistics, edit forums...).
  34. *
  35. *    @package dokeos.course_home
  36. ==============================================================================
  37. */
  38.  
  39.  
  40.  
  41. /*
  42. ==============================================================================
  43.         FUNCTIONS
  44. ==============================================================================
  45. */
  46.  
  47. /**
  48.  * Displays the tools of a certain category.
  49.  *
  50.  * @return void 
  51.  * @param string $course_tool_category    contains the category of tools to display:
  52.  *  "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform"
  53.  */
  54.  
  55. function show_tools_category($course_tool_category)
  56. {
  57.     $web_code_path api_get_path(WEB_CODE_PATH);
  58.     $course_tool_table Database::get_course_table(TABLE_TOOL_LIST);
  59.     $is_allowed_to_edit api_is_allowed_to_edit();
  60.     $is_platform_admin api_is_platform_admin();
  61.  
  62.     switch ($course_tool_category)
  63.     {
  64.         case TOOL_STUDENT_VIEW:
  65.                 $result api_sql_query("SELECT * FROM $course_tool_table WHERE visibility = '1' AND (category = 'authoring' OR category = 'interaction') ORDER BY id",__FILE__,__LINE__);
  66.                 $colLink ="##003399";
  67.                 break;
  68.  
  69.         case TOOL_AUTHORING:
  70.  
  71.                 $result api_sql_query("SELECT * FROM $course_tool_table WHERE category = 'authoring' ORDER BY id",__FILE__,__LINE__);
  72.                 $colLink ="##003399";
  73.                 break;
  74.  
  75.         case TOOL_INTERACTION:
  76.  
  77.                 $result api_sql_query("SELECT * FROM $course_tool_table WHERE category = 'interaction' ORDER BY id",__FILE__,__LINE__);
  78.                 $colLink ="##003399";
  79.                 break;
  80.  
  81.         case TOOL_ADMIN_VISIBLE:
  82.  
  83.                 $result api_sql_query("SELECT * FROM $course_tool_table WHERE category = 'admin' AND visibility ='1' ORDER BY id",__FILE__,__LINE__);
  84.                 $colLink ="##003399";
  85.                 break;
  86.  
  87.         case TOOL_ADMIN_PLATEFORM:
  88.  
  89.                 $result api_sql_query("SELECT * FROM $course_tool_table WHERE category = 'admin' ORDER BY id",__FILE__,__LINE__);
  90.                 $colLink ="##003399";
  91.                 break;
  92.         
  93.  
  94.     }
  95.  
  96.     while ($temp_row Database::fetch_array($result))
  97.     {
  98.         $all_tools_list[]=$temp_row;
  99.     }
  100.     
  101.     if(api_is_course_coach())
  102.     {
  103.         $result api_sql_query("SELECT * FROM $course_tool_table WHERE name='tracking'",__FILE__,__LINE__);
  104.         $all_tools_list[]=Database :: fetch_array($result);
  105.     }
  106.  
  107.     $i=0;
  108.     // grabbing all the links that have the property on_homepage set to 1
  109.     $course_link_table Database::get_course_table(TABLE_LINK);
  110.     $course_item_property_table Database::get_course_table(TABLE_ITEM_PROPERTY);
  111.  
  112.     switch ($course_tool_category)
  113.     {
  114.             case TOOL_AUTHORING:
  115.             $sql_links="SELECT tl.*, tip.visibility
  116.                     FROM $course_link_table tl
  117.                     LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  118.                         WHERE tl.on_homepage='1'";
  119.  
  120.             break;
  121.  
  122.             case TOOL_INTERACTION:
  123.             $sql_links null;
  124.             /*
  125.             $sql_links="SELECT tl.*, tip.visibility
  126.                 FROM $course_link_table tl
  127.                 LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  128.                         WHERE tl.on_homepage='1' ";
  129.             */
  130.             break;
  131.  
  132.             case TOOL_STUDENT_VIEW:
  133.                 $sql_links="SELECT tl.*, tip.visibility
  134.                 FROM $course_link_table tl
  135.                 LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  136.                         WHERE tl.on_homepage='1'";
  137.             break;
  138.  
  139.             case TOOL_ADMIN:
  140.                 $sql_links="SELECT tl.*, tip.visibility
  141.                 FROM $course_link_table tl
  142.                 LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  143.                         WHERE tl.on_homepage='1'";
  144.             break;
  145.  
  146.         default:
  147.             $sql_links null;
  148.             break;
  149.     }
  150.  
  151.     //edit by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs
  152.     if($sql_links != null)
  153.     {
  154.         $result_links api_sql_query($sql_links,__FILE__,__LINE__);
  155.         $properties array();
  156.         while($links_row Database::fetch_array($result_links))
  157.         {
  158.             unset($properties);
  159.  
  160.             $properties['name'$links_row['title'];
  161.             $properties['link'$links_row['url'];
  162.             $properties['visibility'$links_row['visibility'];
  163.             $properties['image'($links_row['visibility']== '0'"file_html.gif" "file_html.gif";
  164.             $properties['adminlink'api_get_path(WEB_CODE_PATH"link/link.php?action=editlink&id=".$links_row['id'];
  165.  
  166.             $tmp_all_tools_list[$properties;
  167.         }
  168.     }
  169.  
  170.     if(isset($tmp_all_tools_list))
  171.     {
  172.         foreach($tmp_all_tools_list as $toolsRow)
  173.         {
  174.  
  175.             if($toolsRow['image'== 'blog.gif')
  176.             {
  177.                 // Init
  178.                 $tbl_blogs_rel_user Database::get_course_table(TABLE_BLOGS_REL_USER);
  179.  
  180.                 // Get blog id
  181.                 $blog_id substr($toolsRow['link']strrpos($toolsRow['link']'='1strlen($toolsRow['link']));
  182.  
  183.                 // Get blog members
  184.                 if($is_platform_admin)
  185.                 {
  186.                     $sql_blogs "
  187.                         SELECT *
  188.                         FROM " $tbl_blogs_rel_user " `blogs_rel_user`
  189.                         WHERE `blog_id` = " $blog_id;
  190.                 }
  191.                 else
  192.                 {
  193.                     $sql_blogs "
  194.                         SELECT *
  195.                         FROM " $tbl_blogs_rel_user " `blogs_rel_user`
  196.                         WHERE
  197.                             `blog_id` = " $blog_id " AND
  198.                             `user_id` = " api_get_user_id();
  199.                 }
  200.  
  201.                 $result_blogs api_sql_query($sql_blogs__FILE____LINE__);
  202.  
  203.                 if(Database::num_rows($result_blogs0)
  204.                     $all_tools_list[$toolsRow;
  205.             }
  206.             else
  207.                 $all_tools_list[$toolsRow;
  208.         }
  209.     }
  210.  
  211.     if(isset($all_tools_list))
  212.     {
  213.         $lnk '';
  214.         foreach($all_tools_list as $toolsRow)
  215.         {
  216.             if(!($i%2))
  217.                 {echo    "<tr valign=\"top\">\n";}
  218.  
  219.             // This part displays the links to hide or remove a tool.
  220.             // These links are only visible by the course manager.
  221.             unset($lnk);
  222.             echo '<td width="50%">' "\n";
  223.             if($is_allowed_to_edit)
  224.             {
  225.                 if($toolsRow['visibility'== '1' && $toolsRow['admin'!='1')
  226.                 {
  227.  
  228.                     $link['name''<img src="'.api_get_path(WEB_CODE_PATH).'img/visible.gif" align="absmiddle" alt="'.get_lang("Deactivate").'"/>';
  229.  
  230.                     $link['cmd'"hide=yes";
  231.                     $lnk[$link;
  232.                 }
  233.  
  234.                 if($toolsRow['visibility'== '0' && $toolsRow['admin'!='1')
  235.                 {
  236.                     $link['name''<img src="'.api_get_path(WEB_CODE_PATH).'img/invisible.gif" align="absmiddle" alt="'.get_lang("Activate").'"/>';
  237.                     $link['cmd'"restore=yes";
  238.                     $lnk[$link;
  239.                 }
  240.  
  241.                 if(!empty($toolsRow['adminlink']))
  242.                 {
  243.                     echo    '<a href="'.$toolsRow['adminlink'].'"><img src="'.api_get_path(WEB_CODE_PATH).'img/edit.gif" align="absmiddle" alt="'.get_lang("Edit").'"/></a>';
  244.                 }
  245.  
  246.             }
  247.             
  248.             // Both checks are necessary as is_platform_admin doesn't take student view into account
  249.             if$is_platform_admin && $is_allowed_to_edit
  250.             {
  251.                  if($toolsRow['admin'!='1')
  252.                 {
  253.                     $link['cmd'"hide=yes";
  254.  
  255.                 }
  256.  
  257.             }
  258.  
  259.             if(isset($lnk&& is_array($lnk))
  260.             {
  261.                 foreach($lnk as $this_link)
  262.                 {
  263.                     if(empty($toolsRow['adminlink']))
  264.                     {
  265.                             echo "<a href=\"" .api_get_self()"?".api_get_cidreq()."&amp;id=" $toolsRow["id""&amp;" $this_link['cmd'"\">" .    $this_link['name'"</a>";
  266.                     }
  267.                 }
  268.             }
  269.             elseecho '&nbsp;&nbsp;&nbsp;&nbsp;';}
  270.  
  271.             // NOTE : table contains only the image file name, not full path
  272.             if(!stristr($toolsRow['link']'http://'&& !stristr($toolsRow['link']'https://'&& !stristr($toolsRow['link'],'ftp://'))
  273.                 $toolsRow['link'$web_code_path $toolsRow['link'];
  274.  
  275.             if($toolsRow['visibility'== '0' && $toolsRow['admin'!= '1')
  276.             {
  277.                   $class="class=\"invisible\"";
  278.                   $info pathinfo($toolsRow['image']);
  279.                   $basename basename ($toolsRow['image'],'.'.$info['extension'])// $file is set to "index"
  280.                 $toolsRow['image'$basename.'_na.'.$info['extension'];
  281.             }
  282.              else
  283.                 $class='';
  284.  
  285.             $qm_or_amp ((strpos($toolsRow['link']'?'=== FALSE'?' '&amp;');
  286.             //If it's a link, we don't add the cidReq
  287.             if($toolsRow['image'== 'file_html.gif' || $toolsRow['image'== 'file_html_na.gif'){
  288.                 $toolsRow['link'$toolsRow['link'].$qm_or_amp;
  289.             }
  290.             else{
  291.                 $toolsRow['link'$toolsRow['link'].$qm_or_amp.api_get_cidreq();
  292.             }
  293.                 if(strpos($toolsRow['name'],'visio_')!==false){
  294.                     echo "\t" ' &nbsp <a ' $class ' href="#" onclick="window.open(\'' htmlspecialchars($toolsRow['link']'\',\'window_visio\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' $toolsRow['target''">&nbsp;&nbsp;';
  295.                 }
  296.                 else {
  297.                     echo "\t" ' &nbsp <a ' $class ' href="' htmlspecialchars($toolsRow['link']'" target="' $toolsRow['target''">&nbsp;&nbsp;';
  298.                 }
  299.                     echo '<img src="' $web_code_path 'img/' $toolsRow['image''" align="absmiddle" border="0" alt="' $toolsRow['image''" /> &nbsp;&nbsp;';
  300.                     
  301.                     echo ($toolsRow['image'== 'file_html_na.gif' || $toolsRow['image'== 'file_html.gif' || $toolsRow['image'== 'scormbuilder.gif' || $toolsRow['image'== 'scormbuilder_na.gif' || $toolsRow['image'== 'blog.gif' || $toolsRow['image'== 'blog_na.gif' || $toolsRow['image'== 'external.gif' || $toolsRow['image'== 'external_na.gif''  '.stripslashes($toolsRow['name']'  '.get_lang(ucfirst($toolsRow['name']));
  302.                 echo "\t" '</a>';
  303.                 echo '</td>';
  304.             if($i%2)
  305.             {
  306.                 echo "</tr>";
  307.             }
  308.  
  309.             $i++;
  310.         }
  311.     }
  312.  
  313.     if($i%2)
  314.     {
  315.         echo    "<td width=\"50%\">&nbsp;</td>\n",
  316.                 "</tr>\n";
  317.     }
  318.  
  319. }
  320.  
  321. //End of functions show tools
  322.  
  323. /*
  324. ==============================================================================
  325.         MAIN CODE
  326. ==============================================================================
  327. */
  328. /*
  329. -----------------------------------------------------------
  330.     Work with data post askable by admin of course (franglais, clean this)
  331. -----------------------------------------------------------
  332. */
  333. {
  334.      /*
  335.     -----------------------------------------------------------
  336.         HIDE
  337.     -----------------------------------------------------------
  338.     */
  339.     if(!empty($_GET['hide'])) // visibility 1 -> 0
  340.     {
  341.         api_sql_query("UPDATE $tool_table SET visibility=0 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
  342.         Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
  343.     }
  344.  
  345.   /*
  346.     -----------------------------------------------------------
  347.         REACTIVATE
  348.     -----------------------------------------------------------
  349.     */
  350.     elseif(!empty($_GET['restore'])) // visibility 0,2 -> 1
  351.     {
  352.         api_sql_query("UPDATE $tool_table SET visibility=1 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
  353.         Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
  354.     }
  355. }
  356.  
  357. // work with data post askable by admin of course
  358.  
  359. {
  360.     // Show message to confirm that a tools must be hide from available tools
  361.     // visibility 0,1->2
  362.     if(!empty($_GET['askDelete']))
  363.     {
  364.         ?>
  365.             <div id="toolhide">
  366.             <?php echo get_lang("DelLk")?>
  367.             <br />&nbsp;&nbsp;&nbsp;
  368.             <a href="<?php echo api_get_self()?>"><?php echo get_lang("No")?></a>&nbsp;|&nbsp;
  369.             <a href="<?php echo api_get_self()?>?delete=yes&id=<?php echo $_GET["id"]?>"><?php echo get_lang("Yes")?></a>
  370.             </div>
  371.         <?php
  372.     }
  373.  
  374.     /*
  375.      * Process hiding a tools from available tools.
  376.      */
  377.  
  378.     elseif(isset($_GET["delete"]&& $_GET["delete"])
  379.     {
  380.         api_sql_query("DELETE FROM $tool_table WHERE id='$id' AND added_tool=1",__FILE__,__LINE__);
  381.     }
  382. }
  383.  
  384.  
  385.  
  386. /*
  387. ==============================================================================
  388.         COURSE ADMIN ONLY VIEW
  389. ==============================================================================
  390. */
  391.  
  392. // start of tools for CourseAdmins (teachers/tutors)
  393. {
  394.     ?>
  395.     <div class="courseadminview">
  396.         <span class="viewcaption"><?php echo get_lang("Authoring"?></span>
  397.         <table width="100%">
  398.             <?php show_tools_category(TOOL_AUTHORING);?>
  399.         </table>
  400.     </div>
  401.     <div class="courseadminview">
  402.         <span class="viewcaption"><?php echo get_lang("Interaction"?></span>
  403.         <table width="100%">
  404.             <?php show_tools_category(TOOL_INTERACTION)?>
  405.         </table>
  406.     </div>
  407.     <div class="courseadminview">
  408.         <span class="viewcaption"><?php echo get_lang("Administration"?></span>
  409.         <table width="100%">
  410.             <?php show_tools_category(TOOL_ADMIN_PLATEFORM)?>
  411.         </table>
  412.     </div>
  413.     <?php
  414. }
  415.  
  416. /*
  417. ==============================================================================
  418.         TOOLS AUTHORING
  419. ==============================================================================
  420. */
  421. else{
  422. ?>
  423.     <div class="Authoringview">
  424.  
  425.         <table width="100%">
  426.             <?php show_tools_category(TOOL_STUDENT_VIEW)?>
  427.         </table>
  428.     </div>
  429. <?php
  430. }
  431. ?>

Documentation generated on Thu, 12 Jun 2008 12:53:24 -0500 by phpDocumentor 1.4.1