Esempio n. 1
0
 function JQ_FinishQuiz_nojs()
 {
     global $JLMS_DB, $my, $Itemid, $option, $Itemid;
     $ret_str = '';
     $quiz_id = intval(mosGetParam($_REQUEST, 'quiz', 0));
     $id = intval(mosGetParam($_REQUEST, 'id', 0));
     $query = "SELECT * FROM #__lms_quiz_t_quiz WHERE c_id = '" . $quiz_id . "'";
     $JLMS_DB->SetQuery($query);
     $quiz = $JLMS_DB->LoadObjectList();
     if (count($quiz)) {
         $quiz = $quiz[0];
     } else {
         return $ret_str;
     }
     $quiz_params = new JLMSParameters($quiz->params);
     $inside_lp = intval(mosGetParam($_REQUEST, 'inside_lp', 0));
     $QA = new JLMS_quiz_API($quiz_id, $inside_lp);
     if (!$QA->quiz_valid()) {
         return '';
     }
     //		$toolbar_no_a = $QA->quiz_Get_NoAtToolbar();
     $stu_quiz_id = intval(mosGetParam($_REQUEST, 'stu_quiz_id', 0));
     $user_unique_id = strval(mosGetParam($_REQUEST, 'user_unique_id', ''));
     $QA->set('stu_quiz_id', $stu_quiz_id);
     $QA->set('user_unique_id', $user_unique_id);
     $QA->quiz_ProcessStartData();
     if ($QA->start_valid() && $quiz_id) {
         // temporary fo compatibility
         // (25 April 2007 commented) $quiz = $QA->quiz_data;
         //print_r($stu_quiz_id);
         $query = "SELECT SUM(c_score) FROM #__lms_quiz_r_student_question WHERE c_stu_quiz_id = '" . $stu_quiz_id . "'";
         $JLMS_DB->SetQuery($query);
         $user_score = $JLMS_DB->LoadResult();
         if (!$user_score) {
             $user_score = 0;
         }
         /*$query = "SELECT SUM(c_point) FROM #__lms_quiz_t_question WHERE c_quiz_id = '".$quiz_id."'";
         		$JLMS_DB->SetQuery( $query );
         		$max_score = $JLMS_DB->LoadResult();*/
         $max_score = $QA->quiz_Get_MaxScore();
         $nugno_score = $QA->get_qvar('c_passing_score', 0) * $max_score / 100;
         $user_passed = 0;
         if ($user_score >= $nugno_score) {
             $user_passed = 1;
         }
         $user_time = 0;
         $quiz_time1 = time() - date('Z');
         $query = "SELECT c_date_time FROM #__lms_quiz_r_student_quiz WHERE c_id = '" . $stu_quiz_id . "'";
         $JLMS_DB->SetQuery($query);
         $quiz_time2 = $JLMS_DB->LoadResult();
         $quiz_time2a = strtotime($quiz_time2);
         $user_time = $quiz_time1 - $quiz_time2a;
         $query = "UPDATE #__lms_quiz_r_student_quiz SET c_total_score = '" . $user_score . "', c_passed = '" . $user_passed . "', c_total_time = '" . $user_time . "'" . "\n WHERE c_id = '" . $stu_quiz_id . "' and c_quiz_id = '" . $quiz_id . "' and c_student_id = '" . $my->id . "'";
         $JLMS_DB->SetQuery($query);
         $JLMS_DB->query();
         // update lms results
         $lms_course = $QA->get_qvar('course_id', 0);
         $lms_quiz = $quiz_id;
         $lms_user = $my->id;
         $lms_score = $user_score;
         $lms_time = $user_time;
         $lms_date = date('Y-m-d H:i:s', time() - date('Z'));
         $lms_passed = $user_passed;
         global $JLMS_CONFIG;
         if ($lms_course && $JLMS_CONFIG->get('course_id') == $lms_course) {
             $course_params = $JLMS_CONFIG->get('course_params');
             $params = new JLMSParameters($course_params);
             $do_insert_new_res = false;
             if ($params->get('track_type', 0) == 1) {
                 $query = "SELECT * FROM #__lms_quiz_results WHERE course_id = '" . $lms_course . "' AND quiz_id = '" . $lms_quiz . "' AND user_id = '" . $lms_user . "'";
                 $JLMS_DB->SetQuery($query);
                 $old_user_results = $JLMS_DB->LoadObject();
                 if (is_object($old_user_results)) {
                     if (!$lms_passed && !$old_user_results->user_passed && $lms_score > $old_user_results->user_score) {
                         $do_insert_new_res = true;
                     } elseif ($lms_passed && !$old_user_results->user_passed) {
                         $do_insert_new_res = true;
                     } elseif ($lms_passed && $old_user_results->user_passed && $lms_score > $old_user_results->user_score) {
                         $do_insert_new_res = true;
                     } elseif ($lms_passed && $old_user_results->user_passed && $lms_score == $old_user_results->user_score && $lms_time < $old_user_results->user_time) {
                         $do_insert_new_res = true;
                     }
                 } else {
                     $do_insert_new_res = true;
                 }
             } else {
                 $do_insert_new_res = true;
             }
             if ($do_insert_new_res) {
                 $query = "DELETE FROM #__lms_quiz_results WHERE course_id = '" . $lms_course . "' AND quiz_id = '" . $lms_quiz . "' AND user_id = '" . $lms_user . "'";
                 $JLMS_DB->SetQuery($query);
                 $JLMS_DB->query();
                 $query = "INSERT INTO #__lms_quiz_results (course_id, quiz_id, user_id, user_score, quiz_max_score, user_time, quiz_date, user_passed)" . "\n VALUES ('" . $lms_course . "', '" . $lms_quiz . "', '" . $lms_user . "', '" . $lms_score . "', " . intval($max_score) . ", '" . $lms_time . "', '" . $lms_date . "', '" . $lms_passed . "')";
                 $JLMS_DB->SetQuery($query);
                 $JLMS_DB->query();
                 if ($lms_passed) {
                     $db =& JFactory::getDbo();
                     $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
                     //*** send email notifications
                     $JLMS_CONFIG =& JLMSFactory::getConfig();
                     $Itemid = $JLMS_CONFIG->get('Itemid');
                     $e_course = new stdClass();
                     $e_course->course_alias = '';
                     $e_course->course_name = '';
                     $query = "SELECT course_name, name_alias FROM #__lms_courses WHERE id = '" . $lms_course . "'";
                     $db->setQuery($query);
                     $e_course = $db->loadObject();
                     $query = "SELECT c_title FROM #__lms_quiz_t_quiz WHERE c_id = '" . $lms_quiz . "'";
                     $db->setQuery($query);
                     $e_quiz_name = $db->loadResult();
                     $e_user = new stdClass();
                     $e_user->name = '';
                     $e_user->email = '';
                     $e_user->username = '';
                     $query = "SELECT email, name, username FROM #__users WHERE id = '" . $lms_user . "'";
                     $db->setQuery($query);
                     $e_user = $db->loadObject();
                     $e_params['user_id'] = $lms_user;
                     $e_params['course_id'] = $lms_course;
                     $e_params['markers']['{email}'] = $e_user->email;
                     $e_params['markers']['{name}'] = $e_user->name;
                     $e_params['markers']['{username}'] = $e_user->username;
                     $e_params['markers']['{coursename}'] = $e_course->course_name;
                     $e_params['markers']['{quizname}'] = $e_quiz_name;
                     $e_params['markers']['{courselink}'] = JLMSEmailRoute("index.php?option=com_joomla_lms&Itemid={$Itemid}&task=details_course&id={$lms_course}");
                     $e_params['markers_nohtml']['{courselink}'] = $e_params['markers']['{courselink}'];
                     $e_params['markers']['{courselink}'] = '<a href="' . $e_params['markers']['{courselink}'] . '">' . $e_params['markers']['{courselink}'] . '</a>';
                     $e_params['markers']['{lmslink}'] = JLMSEmailRoute("index.php?option=com_joomla_lms&Itemid={$Itemid}");
                     $e_params['markers_nohtml']['{lmslink}'] = $e_params['markers']['{lmslink}'];
                     $e_params['markers']['{lmslink}'] = '<a href="' . $e_params['markers']['{lmslink}'] . '">' . $e_params['markers']['{lmslink}'] . '</a>';
                     $e_params['action_name'] = 'OnQuizCompletion';
                     $_JLMS_PLUGINS->loadBotGroup('emails');
                     $plugin_result_array = $_JLMS_PLUGINS->trigger('OnQuizCompletion', array(&$e_params));
                     //*** end of emails
                 }
             }
         }
         // end of lms results section
     }
     //redirect
     JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quiz_action&id={$id}&quiz={$quiz_id}&stu_quiz_id={$stu_quiz_id}&user_unique_id={$user_unique_id}&atask=review_stop"));
 }
function JLMS_saveDropBox($option)
{
    $JLMS_CONFIG =& JLMSFactory::getConfig();
    $Itemid = $JLMS_CONFIG->get('Itemid');
    $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
    $db =& JFactory::getDbo();
    $user = JLMSFactory::getUser();
    $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0));
    //	if ($user->get('id') && $course_id && JLMS_GetUserType($user->get('id'), $course_id) ) {
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($user->get('id') && $course_id && $JLMS_ACL->CheckPermissions('dropbox', 'view')) {
        $recv_id = intval(mosGetParam($_REQUEST, 'recv_id', 0));
        $recv_id = mosGetParam($_POST, 'recv_id', array(0));
        if (!is_array($recv_id)) {
            $recv_id = array(0);
        }
        if (isset($recv_id[0]) && !$recv_id[0] || !count($recv_id)) {
            //fix one user (ticket  [QDHZ-1096])
            $msg = _JLMS_DROP_ERROR_NO_SEND_TO;
            JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}"), $msg);
        }
        //convert array of receiver's to numeric values
        $i = 0;
        while ($i < count($recv_id)) {
            $recv_id[$i] = intval($recv_id[$i]);
            $i++;
        }
        $recv_ids = implode(',', $recv_id);
        $do_continue = false;
        /*
        New permissions (Max)
        */
        $query = "SELECT count(user_id) FROM #__lms_user_courses" . "\n WHERE course_id = '" . $course_id . "' AND user_id IN ( {$recv_ids} )";
        $db->setQuery($query);
        $count_users = $db->LoadResult();
        if ($JLMS_ACL->CheckPermissions('dropbox', 'send_to_teachers')) {
            if ($count_users) {
                $do_continue = true;
            } else {
                $query = "SELECT count(c.user_id) FROM #__lms_users_in_groups as c" . "\n WHERE c.course_id = '" . $course_id . "' AND c.user_id IN ( {$recv_ids} )";
                $db->setQuery($query);
                $count_users = $db->LoadResult();
                if ($count_users) {
                    $do_continue = true;
                }
            }
        }
        if ($JLMS_ACL->CheckPermissions('dropbox', 'send_to_learners')) {
            if ($count_users) {
                $do_continue = true;
            }
        }
        /*
        Old part
        */
        /*
        if (JLMS_GetUserType($user->get('id'), $course_id) == 1) {
        	$query = "SELECT count(user_id) FROM #__lms_user_courses"
        	. "\n WHERE course_id = '".$course_id."' AND (role_id = 1 OR role_id = 4) AND user_id IN ( $recv_ids )";
        	$db->setQuery($query);
        	$count_users = $db->LoadResult();
        	
        	if ($count_users) {
        		$do_continue = true;
        	} else {
        		$query = "SELECT count(c.user_id) FROM #__lms_users_in_groups as c"
        		. "\n WHERE c.course_id = '".$course_id."' AND c.user_id IN ( $recv_ids )";
        		$db->setQuery($query);
        		$count_users = $db->LoadResult();
        		if ($count_users) {
        			$do_continue = true;
        		}
        	}
        } elseif (JLMS_GetUserType($user->get('id'), $course_id) == 2) {
        	$query = "SELECT count(user_id) FROM #__lms_user_courses"
        	. "\n WHERE course_id = '".$course_id."' AND (role_id = 1 OR role_id = 4) AND user_id IN ( $recv_ids )";
        	$db->setQuery($query);
        	$count_users = $db->LoadResult();
        	if ($count_users) {
        		$do_continue = true;
        	}
        }
        */
        // (TIPS)
        // sender: teacher - RECEIVER must be teacher of this course or student of this course
        // sender: student - RECEIVER must be teacher of this course
        $flag = false;
        if ($do_continue) {
            if ($_FILES['userfile']['name'] == '') {
                $file_id = 0;
                $flag = true;
            } else {
                $file_id = JLMS_uploadFile($course_id);
                if ($file_id) {
                    $flag = true;
                }
            }
            $_POST['drp_type'] = 1;
            if (intval(mosGetParam($_REQUEST, 'file_id', 0))) {
                $file_id = intval(mosGetParam($_REQUEST, 'file_id', 0));
                $_POST['drp_type'] = 2;
            }
            if ($flag) {
                $row = new mos_Joomla_LMS_DropBox($db);
                if (!$row->bind($_POST)) {
                    echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
                    exit;
                }
                $row->file_id = $file_id;
                $row->owner_id = $user->get('id');
                $row->drp_mark = 1;
                /*$query = "SELECT file_name FROM #__lms_files WHERE id = '".$file_id."'";
                				$db->SetQuery( $query );
                
                				$row->drp_name = $db->LoadResult();*/
                //$row->drp_name = strval(mosGetParam($_FILES['userfile'], 'name', 'dropbox_file'));
                if ($file_id > 0) {
                    if ($row->drp_type == 1) {
                        $drp_name = isset($_FILES['userfile']['name']) ? strval($_FILES['userfile']['name']) : 'dropbox_file';
                    } else {
                        if ($row->drp_type == 2) {
                            $drp_name = strval(mosGetParam($_REQUEST, 'dropbox_name', 'dropbox_file_(' . time() . ')'));
                        }
                    }
                } else {
                    $drp_name = mosGetParam($_REQUEST, 'dropbox_name');
                }
                $drp_name = get_magic_quotes_gpc() ? stripslashes($drp_name) : $drp_name;
                $row->drp_name = ampReplace(strip_tags($drp_name));
                $row->drp_description = strval(JLMS_getParam_LowFilter($_POST, 'drp_description', ''));
                //$row->drp_description = JLMS_ProcessText_LowFilter($row->drp_description);
                //				if (JLMS_GetUserType($user->get('id'), $course_id ) == 1) {
                if ($JLMS_ACL->CheckPermissions('dropbox', 'mark_as_corrected')) {
                    $drp_corr = intval(mosGetParam($_REQUEST, 'drp_corrected', 0));
                    if ($drp_corr != 1) {
                        $drp_corr = 0;
                    }
                    $row->drp_corrected = $drp_corr;
                } else {
                    $row->drp_corrected = 0;
                }
                $row->drp_time = date('Y-m-d H:i:s');
                //Replace old function JLMS_GetUserType //tmp
                $users_teachers = array();
                $users_learners = array();
                if ($JLMS_ACL->CheckPermissions('dropbox', 'send_to_teachers')) {
                    $query = "SELECT a.* FROM #__users as a, #__lms_user_courses as c" . "\n WHERE a.id = c.user_id AND c.course_id = '" . $course_id . "' AND a.id <> '" . $user->id . "'" . "\n ORDER BY a.username";
                    $db->SetQuery($query);
                    $users_teachers = $db->LoadObjectList();
                    $i = 0;
                    while ($i < count($users_teachers)) {
                        $users_teachers[$i]->username = _JLMS_ROLE_TEACHER . ' - ' . $users_teachers[$i]->name . ' (' . $users_teachers[$i]->username . ')';
                        $i++;
                    }
                }
                if ($JLMS_ACL->CheckPermissions('dropbox', 'send_to_learners')) {
                    $users_learners = JLMS_getCourseStudentsList($course_id);
                }
                $tmp = array();
                foreach ($users_teachers as $n => $ut) {
                    $tmp[$n] = $ut->id;
                }
                if (count($tmp)) {
                    $users_teachers = $tmp;
                }
                $tmp = array();
                foreach ($users_learners as $n => $ul) {
                    $tmp[$n] = $ul->id;
                }
                if (count($tmp)) {
                    $users_learners = $tmp;
                }
                //Replace old function JLMS_GetUserType //tmp
                foreach ($recv_id as $recv) {
                    $check_recv = false;
                    //Replace old function JLMS_GetUserType //tmp
                    if ($JLMS_ACL->CheckPermissions('dropbox', 'send_to_teachers') && in_array($recv, $users_teachers)) {
                        $check_recv = true;
                    }
                    if ($JLMS_ACL->CheckPermissions('dropbox', 'send_to_learners') && in_array($recv, $users_learners)) {
                        $check_recv = true;
                    }
                    //Replace old function JLMS_GetUserType //tmp
                    //					if ($recv && ($recv != $user->get('id')) && ((JLMS_GetUserType($user->get('id'), $course_id) == 1 && JLMS_GetUserType($recv, $course_id)) || ((JLMS_GetUserType($user->get('id'), $course_id) == 2) && (JLMS_GetUserType($recv, $course_id, true) == 1))) || ((JLMS_GetUserType($user->get('id'), $course_id) == 2) && (JLMS_GetUserType($recv, $course_id, true) == 2)) ) { //old
                    if ($recv && $recv != $user->get('id') && $check_recv) {
                        $row->id = 0;
                        $row->recv_id = $recv;
                        if (!$row->check()) {
                            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
                            exit;
                        }
                        if (!$row->store()) {
                            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
                            exit;
                        }
                        //*** send email notification
                        $e_course = new stdClass();
                        $e_course->course_alias = '';
                        $e_course->course_name = '';
                        $query = "SELECT course_name, name_alias FROM #__lms_courses WHERE id = '" . $course_id . "'";
                        $db->setQuery($query);
                        $e_course = $db->loadObject();
                        $e_user = new stdClass();
                        $e_user->name = '';
                        $e_user->email = '';
                        $e_user->username = '';
                        $query = "SELECT email, name, username FROM #__users WHERE id = '" . $recv . "'";
                        $db->setQuery($query);
                        $e_user = $db->loadObject();
                        $e_params['user_id'] = $recv;
                        $e_params['course_id'] = $course_id;
                        $e_params['markers']['{email}'] = $e_user->email;
                        $e_params['markers']['{name}'] = $e_user->name;
                        $e_params['markers']['{username}'] = $e_user->username;
                        $e_params['markers']['{coursename}'] = $e_course->course_name;
                        //( $e_course->course_alias )?$e_course->course_alias:$e_course->course_name;
                        $e_params['markers']['{filename}'] = $row->drp_name;
                        $e_params['markers']['{courselink}'] = JLMSEmailRoute("index.php?option=com_joomla_lms&Itemid={$Itemid}&task=details_course&id={$course_id}");
                        $e_params['markers_nohtml']['{courselink}'] = $e_params['markers']['{courselink}'];
                        $e_params['markers']['{courselink}'] = '<a href="' . $e_params['markers']['{courselink}'] . '">' . $e_params['markers']['{courselink}'] . '</a>';
                        $e_params['markers']['{lmslink}'] = JLMSEmailRoute("index.php?option=com_joomla_lms&Itemid={$Itemid}");
                        $e_params['markers_nohtml']['{lmslink}'] = $e_params['markers']['{lmslink}'];
                        $e_params['markers']['{lmslink}'] = '<a href="' . $e_params['markers']['{lmslink}'] . '">' . $e_params['markers']['{lmslink}'] . '</a>';
                        $e_params['action_name'] = 'OnNewDropboxFile';
                        $_JLMS_PLUGINS->loadBotGroup('emails');
                        $plugin_result_array = $_JLMS_PLUGINS->trigger('OnNewDropboxFile', array(&$e_params));
                        //*** end of emails
                    }
                }
                JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}"));
            } else {
                mosErrorAlert("Upload of " . $userfile_name . " failed");
            }
        } else {
            JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}"));
        }
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}"));
    }
}
Esempio n. 3
0
function JLMS_tchangeHW($course_id, $option)
{
    $JLMS_CONFIG =& JLMSFactory::getConfig();
    $Itemid = $JLMS_CONFIG->get('Itemid');
    $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
    $db =& JFactory::getDbo();
    $user_id = intval(mosGetParam($_REQUEST, 'user_id', 0));
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($course_id && $user_id && $JLMS_ACL->CheckPermissions('homework', 'manage')) {
        $state = intval(mosGetParam($_REQUEST, 'state', 0));
        if ($state != 1) {
            $state = 0;
        }
        //$state = 1;
        $cid = mosGetParam($_REQUEST, 'cid', array(0));
        $cid2 = intval(mosGetParam($_REQUEST, 'cid2', 0));
        if ($cid2) {
            $cid = array();
            $cid[] = $cid2;
        }
        if (!is_array($cid)) {
            $cid = array(0);
        }
        if (!is_array($cid) || count($cid) < 1) {
            $action = 1 ? 'Publish' : 'Unpublish';
            echo "<script> alert('Select an item to {$action}'); window.history.go(-1);</script>\n";
            exit;
        }
        $cid1 = array();
        $cid1[] = $cid[0];
        $cids = implode(',', $cid1);
        //$now = date( 'Y-m-d', time() );
        //check rights to change id's
        $query = "SELECT id FROM #__lms_homework WHERE course_id = '" . $course_id . "'" . "\n AND id IN ( {$cids} )";
        $db->SetQuery($query);
        $cid = $db->LoadResultArray();
        if (!is_array($cid)) {
            $cid = array(0);
        }
        $cids = implode(',', $cid);
        $query = "SELECT hw_id FROM #__lms_homework_results WHERE course_id = '" . $course_id . "' AND user_id = '" . $user_id . "' AND hw_id IN ( {$cids} )";
        $db->SetQuery($query);
        $pre_cids = $db->LoadResultArray();
        if (!count($pre_cids)) {
            $pre_cids = array(0);
        }
        $upd_cid = array_intersect($cid, $pre_cids);
        $ins_cid = array_diff($cid, $pre_cids);
        $now = date('Y-m-d H:i:s');
        if (!$state) {
            $now = '';
        }
        $hw_id_notify = 0;
        if (count($upd_cid)) {
            $cids = implode(',', $upd_cid);
            if (isset($upd_cid[0]) && $upd_cid[0]) {
                $hw_id_notify = $upd_cid[0];
            }
            $query = "UPDATE #__lms_homework_results" . "\n SET hw_status = {$state}, hw_date = '" . $now . "'" . "\n WHERE hw_id IN ( {$cids} ) AND course_id = {$course_id} AND user_id = '" . $user_id . "'";
            $db->setQuery($query);
            if (!$db->query()) {
                echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
        }
        if (count($ins_cid)) {
            if (isset($ins_cid[0]) && $ins_cid[0]) {
                $hw_id_notify = $ins_cid[0];
            }
            $query = "INSERT INTO #__lms_homework_results (course_id, user_id, hw_id, hw_status, hw_date) VALUES ";
            $t = 0;
            foreach ($ins_cid as $ins_id) {
                $query .= "\n ({$course_id}, " . $user_id . ", " . $ins_id . ", {$state}, '" . $now . "')" . ($t < count($ins_cid) - 1 ? ',' : '');
                $t++;
            }
            $db->setQuery($query);
            if (!$db->query()) {
                echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
        }
        if ($state && $hw_id_notify) {
            //*** email notification about new homework submission
            $e_course = new stdClass();
            $e_course->course_alias = '';
            $e_course->course_name = '';
            $query = "SELECT course_name, name_alias FROM #__lms_courses WHERE id = '" . $course_id . "'";
            $db->setQuery($query);
            $e_course = $db->loadObject();
            $query = "SELECT hw_name FROM #__lms_homework WHERE id = '" . $hw_id_notify . "'";
            $db->setQuery($query);
            $e_hw_name = $db->loadResult();
            $e_user = new stdClass();
            $e_user->name = '';
            $e_user->email = '';
            $e_user->username = '';
            $query = "SELECT email, name, username FROM #__users WHERE id = '" . $user_id . "'";
            $db->setQuery($query);
            $e_user = $db->loadObject();
            $e_params['user_id'] = $user_id;
            $e_params['course_id'] = $course_id;
            $e_params['markers']['{email}'] = $e_user->email;
            $e_params['markers']['{name}'] = $e_user->name;
            $e_params['markers']['{username}'] = $e_user->username;
            $e_params['markers']['{coursename}'] = $e_course->course_name;
            //( $e_course->course_alias )?$e_course->course_alias:$e_course->course_name;
            $e_params['markers']['{homeworkname}'] = $e_hw_name;
            $e_params['markers']['{courselink}'] = JLMSEmailRoute("index.php?option=com_joomla_lms&Itemid={$Itemid}&task=details_course&id={$course_id}");
            $e_params['markers_nohtml']['{courselink}'] = $e_params['markers']['{courselink}'];
            $e_params['markers']['{courselink}'] = '<a href="' . $e_params['markers']['{courselink}'] . '">' . $e_params['markers']['{courselink}'] . '</a>';
            $e_params['markers']['{lmslink}'] = 'OnCSVImportUser';
            $e_params['markers']['{lmslink}'] = JLMSEmailRoute("index.php?option=com_joomla_lms&Itemid={$Itemid}");
            $e_params['markers_nohtml']['{lmslink}'] = $e_params['markers']['{lmslink}'];
            $e_params['markers']['{lmslink}'] = '<a href="' . $e_params['markers']['{lmslink}'] . '">' . $e_params['markers']['{lmslink}'] . '</a>';
            $e_params['action_name'] = 'OnHomeworkReview';
            $_JLMS_PLUGINS->loadBotGroup('emails');
            $plugin_result_array = $_JLMS_PLUGINS->trigger('OnHomeworkReview', array(&$e_params));
            //*** end of emails
        }
    }
    JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=hw_stats&course_id={$course_id}&id={$cid[0]}"));
}