Exemple #1
0
function donwloadmaterials()
{
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once _base_ . '/lib/lib.multimedia.php';
    $lang = DoceboLanguage::createInstance('course', 'lms');
    $id_course = importVar('id_course', true, 0);
    $edition_id = importVar('edition_id', true, 0);
    if ($id_course != 0) {
        $man_course = new DoceboCourse($id_course);
        $file = $man_course->getValue('img_material');
    }
    if ($edition_id != 0) {
        $select_edition = " SELECT img_material ";
        $from_edition = " FROM " . $GLOBALS["prefix_lms"] . "_course_edition";
        $where_edition = " WHERE idCourseEdition = '" . $edition_id . "' ";
        list($file) = sql_fetch_row(sql_query($select_edition . $from_edition . $where_edition));
    }
    require_once _base_ . '/lib/lib.download.php';
    $ext = end(explode('.', $file));
    sendFile('/appLms/' . Get::sett('pathcourse'), $file, $ext);
}
 public function saveTrackStatusChange($idUser, $idCourse, $status)
 {
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     list($prev_status) = sql_fetch_row(sql_query("\r\n\t\tSELECT status\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\tWHERE idUser = '******' AND idCourse = '" . (int) $idCourse . "'"));
     $extra = '';
     if ($prev_status != $status) {
         switch ($status) {
             case _CUS_SUBSCRIBED:
                 //approved subscriptin for example
                 $extra = ", date_inscr = NOW()";
                 break;
             case _CUS_BEGIN:
                 //first access
                 UpdatesLms::resetCache();
                 $extra = ", date_first_access = NOW()";
                 break;
             case _CUS_END:
                 //end course
                 $extra = ", date_complete = NOW()";
                 break;
         }
     }
     if (!sql_query("\r\n\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\tSET status = '" . (int) $status . "' " . $extra . "\r\n\t\tWHERE idUser = '******' AND idCourse = '" . (int) $idCourse . "'")) {
         return false;
     }
     $re = sql_query("\r\n\t\tSELECT when_do\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_statuschangelog\r\n\t\tWHERE status_user = '******' AND\r\n\t\t\tidUser = '******' AND\r\n\t\t\tidCourse = '" . (int) $idCourse . "'");
     if (sql_num_rows($re)) {
         sql_query("\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_statuschangelog\r\n\t\t\tSET when_do = NOW()\r\n\t\t\tWHERE status_user = '******' AND\r\n\t\t\t\tidUser = '******' AND\r\n\t\t\t\tidCourse = '" . (int) $idCourse . "'");
     } else {
         sql_query("\r\n\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_statuschangelog\r\n\t\t\tSET status_user = '******',\r\n\t\t\t\tidUser = '******',\r\n\t\t\t\tidCourse = '" . (int) $idCourse . "',\r\n\t\t\t\twhen_do = NOW()");
     }
     if ($prev_status != $status && $status == _CUS_END) {
         // send alert
         if (!sql_num_rows($re)) {
             /*
             				//add course's competences scores to user
             				require_once($GLOBALS['where_lms'].'/lib/lib.competences.php');
             				$competences_man = new Competences_Manager();
             				$competences_man->AssignCourseCompetencesToUser($idCourse, $idUser);
             */
         }
         require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
         require_once _base_ . '/lib/lib.eventmanager.php';
         $teachers = Man_Course::getIdUserOfLevel($idCourse, '6');
         $cd = new DoceboCourse($idCourse);
         $acl_man =& Docebo::user()->getAclManager();
         $array_subst = array('[user]' => $acl_man->getUserName($idUser), '[course]' => $cd->getValue('name'));
         $msg_composer = new EventMessageComposer();
         $msg_composer->setSubjectLangText('email', '_USER_END_COURSE_SBJ', false);
         $msg_composer->setBodyLangText('email', '_USER_END_COURSE_TEXT', $array_subst);
         $msg_composer->setBodyLangText('sms', '_USER_END_COURSE_TEXT_SMS', $array_subst);
         // send message to the user subscribed
         createNewAlert('UserCourseEnded', 'status', 'modify', '1', 'User end course', $teachers, $msg_composer);
         //add course's competences scores to user
         /*
         require_once($GLOBALS['where_lms'].'/lib/lib.competences.php');
         $competences_man = new Competences_Manager();
         $competences_man->AssignCourseCompetencesToUser($idCourse, $idUser);
         */
         //increment coursecompleted if this course is in a coursepath
         require_once _lms_ . '/lib/lib.coursepath.php';
         $cpmodel = new CoursePath_Manager();
         $cpmodel->assignComplete($idCourse, $idUser);
     }
     return true;
 }
 /**
  * return the list of substitution
  */
 function getSubstitution()
 {
     $subs = array();
     if ($this->id_meta != 0) {
     } else {
         require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
         $acl_manager =& Docebo::user()->getAclManager();
         $man_course = new DoceboCourse($this->id_course);
         $query = "SELECT idUser" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse = '" . $this->id_course . "'" . " AND level = '6'";
         $result = sql_query($query);
         $first = true;
         while (list($id_user) = sql_fetch_row($result)) {
             if ($first) {
                 $subs['[teacher_list]'] = '' . $acl_manager->getUserName($id_user, false);
                 $subs['[teacher_list_inverse]'] = '' . $this->getUserNameInv($id_user, false);
                 $first = false;
             } else {
                 $subs['[teacher_list]'] .= ', ' . $acl_manager->getUserName($id_user, false);
                 $subs['[teacher_list_inverse]'] .= ', ' . $this->getUserNameInv($id_user, false);
             }
         }
         $subs['[course_code]'] = $man_course->getValue('code');
         $subs['[course_name]'] = $man_course->getValue('name');
         $subs['[date_begin]'] = Format::date($man_course->getValue('date_begin'), 'date');
         $subs['[date_end]'] = Format::date($man_course->getValue('date_end'), 'date');
         $subs['[course_description]'] = html_entity_decode(strip_tags($man_course->getValue('description')), ENT_QUOTES, "UTF-8");
         $subs['[medium_time]'] = $man_course->getValue('mediumTime');
         $subs['[course_credits]'] = $man_course->getValue('credits');
         $subs['[ed_date_begin]'] = '';
         $subs['[ed_classroom]'] = '';
         $subs['[cl_date_begin]'] = '';
         $subs['[cl_date_end]'] = '';
         $subs['[cl_classroom]'] = '';
         if ($man_course->getValue('course_edition') == 1) {
             $query = "SELECT date_begin " . "FROM " . $GLOBALS['prefix_lms'] . "_course_editions INNER JOIN " . $GLOBALS['prefix_lms'] . "_course_editions_user ON " . $GLOBALS['prefix_lms'] . "_course_editions_user.id_edition = " . $GLOBALS['prefix_lms'] . "_course_editions.id_edition " . "where " . $GLOBALS['prefix_lms'] . "_course_editions .id_course = " . $this->id_course . " and " . $GLOBALS['prefix_lms'] . "_course_editions_user.id_user = "******"SELECT d.id_date, MIN( dd.date_begin ) AS date_begin, MAX( dd.date_end ) AS date_end, d.name\r\n\t\t\t\t\t\t\t\t\t\t\t\t FROM " . $GLOBALS['prefix_lms'] . "_course_date_day AS dd\r\n\t\t\t\t\t\t\t\t\t\t\t\t JOIN " . $GLOBALS['prefix_lms'] . "_course_date AS d\r\n\t\t\t\t\t\t\t\t\t\t\t\t JOIN " . $GLOBALS['prefix_lms'] . "_classroom AS c\r\n\t\t\t\t\t\t\t\t\t\t\t\t ON ( dd.classroom = c.idClassroom AND d.id_date = dd.id_date )\r\n\t\t\t\t              \t LEFT JOIN " . $GLOBALS['prefix_lms'] . "_course_date_user ON " . $GLOBALS['prefix_lms'] . "_course_date_user.id_date = d.id_date\r\n                \t\t\t\t WHERE d.id_course = " . (int) $this->id_course . "  and " . $GLOBALS['prefix_lms'] . "_course_date_user.id_user="******"\r\n                \t\t\t\t GROUP BY dd.id_date";
             list($id_date, $subs['[cl_date_begin]'], $subs['[cl_date_end]'], $subs['[ed_classroom]']) = sql_fetch_row(sql_query($qtxt));
             $qtxt = "SELECT distinct c.name AS class_name\r\n                             FROM " . $GLOBALS['prefix_lms'] . "_course_date_day AS dd\r\n                             JOIN " . $GLOBALS['prefix_lms'] . "_course_date AS d\r\n                             JOIN " . $GLOBALS['prefix_lms'] . "_classroom AS c\r\n                             ON ( dd.classroom = c.idClassroom AND d.id_date = dd.id_date )\r\n                             LEFT JOIN " . $GLOBALS['prefix_lms'] . "_course_date_user ON " . $GLOBALS['prefix_lms'] . "_course_date_user.id_date = d.id_date\r\n                             WHERE d.id_course = " . (int) $this->id_course . "  and " . $GLOBALS['prefix_lms'] . "_course_date_user.id_user="******"; ";
                 }
                 $subs['[cl_classroom]'] .= $classroom;
                 $num_pv++;
             }
             $subs['[course_description]'] = html_entity_decode(strip_tags($man_course->getValue('description')), ENT_QUOTES, "UTF-8");
             $subs['[cl_date_begin]'] = Format::date($subs['[cl_date_begin]'], 'date');
             $subs['[cl_date_end]'] = Format::date($subs['[cl_date_end]'], 'date');
             $query = "SELECT idUser" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse = '" . $this->id_course . "'" . " AND level = '6'" . " AND idUser IN " . " (" . " SELECT id_user" . " FROM " . $GLOBALS['prefix_lms'] . "_course_date_user" . " WHERE id_date = " . $id_date . " )";
             $result = sql_query($query);
             $first = true;
             while (list($id_user) = sql_fetch_row($result)) {
                 if ($first) {
                     $subs['[teacher_list]'] = '' . $acl_manager->getUserName($id_user, false);
                     $subs['[teacher_list_inverse]'] = '' . $this->getUserNameInv($id_user, false);
                     $first = false;
                 } else {
                     $subs['[teacher_list]'] .= ', ' . $acl_manager->getUserName($id_user, false);
                     $subs['[teacher_list_inverse]'] .= ', ' . $this->getUserNameInv($id_user, false);
                 }
             }
         }
         // end classroom
     }
     return $subs;
 }
     $html .= '</ul>';
     $value = array("next_op" => '', "id" => 'course_materials', "title" => $lang->def('_MATERIALS'), "content" => $html);
     require_once _base_ . '/lib/lib.json.php';
     $json = new Services_JSON();
     $output = $json->encode($value);
     aout($output);
     break;
 case "play_demo":
     require_once $GLOBALS["where_lms"] . "/lib/lib.course.php";
     require_once _base_ . '/lib/lib.multimedia.php';
     $lang =& DoceboLanguage::createInstance('standard', 'framework');
     $lang->setGlobal();
     $lang =& DoceboLanguage::createInstance('course', 'lms');
     $id_course = importVar('id_course', true);
     $course_man = new DoceboCourse($id_course);
     $course_demo = $course_man->getValue('course_demo');
     $ext = end(explode('.', $course_demo));
     $value = array("next_op" => '', "id" => 'course_materials', "title" => $lang->def('_DEMO'), "content" => getEmbedPlay('/appLms/' . Get::sett('pathcourse'), $course_demo, $ext, '450', '450', false, false, '../../' . $GLOBALS['where_files_relative']));
     require_once _base_ . '/lib/lib.json.php';
     $json = new Services_JSON();
     $output = $json->encode($value);
     aout($output);
     break;
 default:
     $lang =& DoceboLanguage::createInstance('standard', 'framework');
     $lang->setGlobal();
     $lang =& DoceboLanguage::createInstance('catalogue', 'framework');
     $value = array("next_op" => 'prova', "id" => 'prova', "title" => 'creazione window', "content" => 'prova di creazione di una window');
     require_once _base_ . '/lib/lib.json.php';
     $json = new Services_JSON();
     $output = $json->encode($value);