function JLMS_save_notice($option) { global $JLMS_CONFIG, $my, $JLMS_DB, $Itemid, $task; $ntask = strval(mosGetParam($_REQUEST, 'ntask', '')); $doc_id = intval(mosGetParam($_REQUEST, 'doc_id', 0)); $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0)); $v_id = intval(mosGetParam($_REQUEST, 'v_id', 0)); $notice = strval(JLMS_getParam_LowFilter($_REQUEST, 'p_notice', '')); $notice = JLMS_ProcessText_LowFilter($notice); if ($ntask == 'save_notice') { $notice = str_replace("\n", "<br />", $notice); } if (!$course_id) { $ntask = 'new_notice_no_ajax'; } if ($course_id && $ntask == 'new_notice_no_ajax') { $ntask = 'details_course'; } if (!$v_id) { $query = "INSERT INTO #__lms_page_notices(id,usr_id,course_id,task,doc_id,notice,data)"; $query .= " VALUES(''," . $my->id . "," . $course_id . "," . $JLMS_DB->quote($ntask) . "," . $doc_id . "," . $JLMS_DB->quote($notice) . ",'" . date("Y-m-d H:i:s") . "')"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); /*$query = "SELECT COUNT(*) FROM #__lms_page_notices WHERE usr_id=".$my->id." AND course_id=$course_id AND task='".$ntask."' AND doc_id=$doc_id"; $JLMS_DB->setQuery($query); $JLMS_DB->loadResult();*/ if ($task == 'save_notice_no_ajax') { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=view_all_notices")); } else { $query = "SELECT * FROM #__lms_page_notices WHERE usr_id=" . $my->id . " AND course_id={$course_id} AND task=" . $JLMS_DB->quote($ntask) . " AND doc_id={$doc_id} ORDER BY data desc"; $JLMS_DB->setQuery($query); $notices = $JLMS_DB->loadObjectList(); FLMS_page_notice::new_notice($option, $notices, $ntask, $doc_id, $course_id); } } else { $query = "UPDATE #__lms_page_notices SET notice=" . $JLMS_DB->quote($notice) . "" . (isset($course_id) ? "\n, course_id = '" . $course_id . "'" : '') . ($ntask != '' ? "\n, task = '" . $ntask . "'" : '') . "\n WHERE id=" . $v_id . " AND usr_id = " . $my->id; $JLMS_DB->setQuery($query); $JLMS_DB->query(); if ($task == 'save_notice_no_ajax') { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=view_all_notices")); } else { $query = "SELECT * FROM #__lms_page_notices WHERE usr_id=" . $my->id . " AND course_id={$course_id} AND task=" . $JLMS_DB->quote($ntask) . " AND doc_id={$doc_id} ORDER BY data desc"; $JLMS_DB->setQuery($query); $notices = $JLMS_DB->loadObjectList(); FLMS_page_notice::new_notice($option, $notices, $ntask, $doc_id, $course_id); } } }
function JLMS_saveLink($option) { global $my, $JLMS_DB, $Itemid, $JLMS_CONFIG; $JLMS_ACL =& JLMSFactory::getACL(); $course_id = $JLMS_CONFIG->get('course_id'); $id = intval(mosGetParam($_REQUEST, 'id', 0)); if ($JLMS_ACL->CheckPermissions('links', 'manage') && ($id && JLMS_GetLinkCourse($id) == $course_id || !$id)) { $row = new mos_Joomla_LMS_Link($JLMS_DB); if (!$row->bind($_POST)) { echo "<script> alert('" . addslashes($row->getError()) . "'); window.history.go(-1); </script>\n"; exit; } $params = ''; $params_p = mosGetParam($_POST, 'params', ''); if (is_array($params_p)) { $txt = array(); foreach ($params_p as $k => $v) { $txt[] = "{$k}={$v}"; } $params = implode("\n", $txt); } $row->params = $params; //$row->link_name = strval(mosGetParam($_POST, 'link_name', '')); $row->link_href = strval(mosGetParam($_POST, 'link_href', '')); $days = intval(mosGetParam($_POST, 'days', '')); $hours = intval(mosGetParam($_POST, 'hours', '')); $mins = intval(mosGetParam($_POST, 'mins', '')); if ($row->is_time_related) { $row->show_period = JLMS_HTML::_('showperiod.getminsvalue', $days, $hours, $mins); } if (!$id) { $row->owner_id = $my->id; } else { unset($row->owner_id); if ($JLMS_ACL->CheckPermissions('links', 'only_own_items') && JLMS_GetLinkOwner($id) != $my->id) { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=links&id={$course_id}")); } elseif ($JLMS_ACL->CheckPermissions('links', 'only_own_role') && $JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($JLMS_DB, JLMS_GetLinkOwner($id))) { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=links&id={$course_id}")); } } $row->link_name = strval(JLMS_getParam_LowFilter($_POST, 'link_name', '')); $row->link_name = JLMS_Process_ContentNames($row->link_name); // 26.02.2007 (Media content integration) $row->link_description = strval(JLMS_getParam_LowFilter($_POST, 'link_description', '')); $row->link_description = JLMS_ProcessText_LowFilter($row->link_description); //$iFilter = new JLMS_InputFilter(null,null,1,1); //$row->link_description = $iFilter->process( $row->link_description ); $row->link_type = intval(mosGetParam($_REQUEST, 'link_type', 0)); if (!$JLMS_ACL->CheckPermissions('links', 'publish')) { $row->published = 0; } if (!$JLMS_ACL->CheckPermissions('links', 'order')) { $row->ordering = 0; } if (!$row->check()) { echo "<script> alert('" . addslashes($row->getError()) . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . addslashes($row->getError()) . "'); window.history.go(-1); </script>\n"; exit; } } JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=links&id={$course_id}")); }
function saveTopic($course_id) { global $option, $Itemid, $JLMS_DB, $JLMS_CONFIG; $usertype = $JLMS_CONFIG->get('current_usertype', 0); if ($course_id == $JLMS_CONFIG->get('course_id') && $usertype == 1) { $topic_description = strval(JLMS_getParam_LowFilter($_POST, 'description', '')); $topic_description = JLMS_ProcessText_LowFilter($topic_description); $topic_name_post = isset($_REQUEST['name']) ? strval($_REQUEST['name']) : ''; $topic_name_post = get_magic_quotes_gpc() ? stripslashes($topic_name_post) : $topic_name_post; $topic_name_post = ampReplace(strip_tags($topic_name_post)); $row = new JLMS_Topic($JLMS_DB); $row->bind($_POST); $row->name = $topic_name_post; $row->description = $topic_description; $row->start_date = mosGetParam($_REQUEST, 'start_date', '0000-00-00'); $row->start_date = JLMS_dateToDB($row->start_date); $row->end_date = mosGetParam($_REQUEST, 'end_date', '0000-00-00'); $row->end_date = JLMS_dateToDB($row->end_date); $days = intval(mosGetParam($_POST, 'days', '')); $hours = intval(mosGetParam($_POST, 'hours', '')); $mins = intval(mosGetParam($_POST, 'mins', '')); if ($row->is_time_related) { $row->show_period = JLMS_HTML::_('showperiod.getminsvalue', $days, $hours, $mins); } //----> ordering implementation if (mosGetParam($_POST, 'weekly', 0)) { //----> 06.12.2007 - DEN - 14.12.2007 - Replaced by TPETb $number = intval(mosGetParam($_POST, 'number', 0)); if ($number > 50) { $number = 50; } //<---- if ($number <= 0) { $number = 1; } //fool-check } else { $number = 1; //fool-check } $ordering = $row->ordering; //moveup topics with higher ordering $query = "UPDATE #__lms_topics SET ordering=ordering+{$number} WHERE course_id={$course_id} AND ordering>={$ordering}"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); //<---- if (mosGetParam($_POST, 'weekly', 0)) { $fix = 2 - $JLMS_CONFIG->get('date_format_fdow', 1); $first_date = strtotime($row->start_date); $first_day = date("w", $first_date); $next_date = date("Y-m-d", mktime(0, 0, 0, date("m", $first_date), date("d", $first_date) + 7 - 1 - $first_day + $fix, date("Y", $first_date))); $row->publish_end = 1; $row->end_date = $next_date; if (empty($_POST['name'])) { $date_1 = intval(strftime("%d", $first_date)) . ' ' . month_lang(strftime("%m", $first_date), 0, 2); $date_2 = intval(strftime("%d", strtotime($next_date))) . ' ' . month_lang(strftime("%m", strtotime($next_date)), 0, 2); $name = $date_1 . ' - ' . $date_2; $row->name = $name; } else { $row->name = $topic_name_post; } } $row->store(); if (mosGetParam($_POST, 'weekly', 0)) { for ($i = 2; $i <= $number; $i++) { $row = new JLMS_Topic($JLMS_DB); $first_date = strtotime($next_date); $row->start_date = date("Y-m-d", mktime(0, 0, 0, date("m", $first_date), date("d", $first_date) + 1, date("Y", $first_date))); $next_date = date("Y-m-d", mktime(0, 0, 0, date("m", $first_date), date("d", $first_date) + 7, date("Y", $first_date))); $row->course_id = $course_id; $row->published = 1; $row->publish_start = 1; $row->publish_end = 1; $row->end_date = $next_date; if (empty($_POST['name_' . $i])) { $date_1 = intval(strftime("%d", strtotime($row->start_date))) . ' ' . month_lang(strftime("%B", strtotime($row->start_date)), 0, 2); $date_2 = intval(strftime("%d", strtotime($row->end_date))) . ' ' . month_lang(strftime("%B", strtotime($row->end_date)), 0, 2); $name = $date_1 . ' - ' . $date_2; $row->name = $name; } else { $row->name = isset($_POST['name_' . $i]) ? strval($_POST['name_' . $i]) : ''; $row->name = get_magic_quotes_gpc() ? stripslashes($row->name) : $row->name; $row->name = ampReplace(strip_tags($row->name)); } $row->description = $topic_description; $ordering++; $row->ordering = $ordering; $row->store(); } } fixTopicOrder($course_id); if ($_POST['id']) { $msg = _JLMS_TOPIC_T_EDITED; } else { $msg = _JLMS_TOPIC_T_CREATED; } if (mosGetParam($_POST, 'weekly', 0)) { $msg = _JLMS_TOPIC_T_SERIES_CREATED; } } else { $msg = ''; //_JLMS_TOPIC_HACK; } JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=details_course&id={$course_id}#topic_{$row->id}"), $msg); }
function JQ_saveQuestion($option, $page, $id, $gqp = false) { global $JLMS_DB, $Itemid, $JLMS_CONFIG; if ($gqp) { //NEW version multicat $tmp_level = array(); $last_catid = 0; $i = 0; foreach ($_REQUEST as $key => $item) { if (preg_match('#level_id_(\\d+)#', $key, $result)) { if ($item) { $tmp_level[$i] = $result; $last_catid = $item; $i++; } } } $_POST['c_qcat'] = $last_catid; //NEW version multicat } $row = new mos_JoomQuiz_Question($JLMS_DB); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $is_new = false; if (!$row->c_id) { $is_new = true; } $is_pool = false; if ($row->c_quiz_id == -1) { $row->c_quiz_id = 0; $is_pool = true; } $JLMS_ACL =& JLMSFactory::getACL(); if (!$JLMS_ACL->CheckPermissions('quizzes', 'manage')) { if ($JLMS_ACL->CheckPermissions('quizzes', 'manage_pool')) { if (!$is_pool) { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&id={$course_id}&page=quizzes")); } else { if (!$is_new) { $query = "SELECT c_quiz_id FROM #__lms_quiz_t_question WHERE c_id = {$row->c_id}"; $JLMS_DB->SetQuery($query); $old_p = $JLMS_DB->LoadResult(); if ($old_p) { // previously not a Pool question !!! JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&id={$course_id}&page=quizzes")); } } } } } $row->course_id = $id; if ($row->c_type == 20 || $row->c_type == 21) { // Question from pool } else { $row->c_pool = 0; } $params = mosGetParam($_POST, 'params', ''); $quest_params = ''; if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { $txt[] = "{$k}={$v}"; } $quest_params = implode("\n", $txt); } $row->params = $quest_params; $quest_params = new JLMSParameters($row->params); $row->c_question = strval(JLMS_getParam_LowFilter($_POST, 'c_question', '')); $row->c_question = JLMS_ProcessText_LowFilter($row->c_question); $row->c_explanation = strval(JLMS_getParam_LowFilter($_POST, 'c_explanation', '')); $row->c_explanation = JLMS_ProcessText_LowFilter($row->c_explanation); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // q_ordering == -1 - last // q_ordering == 0 - first $q_ordering = intval(mosGetParam($_REQUEST, 'q_ordering', 0)); if (mosGetParam($_REQUEST, 'c_type') == 21 && !$row->c_id) { foreach ($_REQUEST['cid'] as $k => $v) { $row_cid = isset($_REQUEST['cid'][$k]) ? intval($_REQUEST['cid'][$k]) : 0; if ($row_cid) { $query = "INSERT INTO #__lms_quiz_t_question (course_id, c_quiz_id, c_type, ordering, c_pool_gqp, published)" . "\n VALUES('" . mosGetParam($_REQUEST, 'id') . "', '" . mosGetParam($_REQUEST, 'c_quiz_id') . "', '" . mosGetParam($_REQUEST, 'c_type') . "','" . mosGetParam($_REQUEST, 'q_ordering') . "', {$row_cid}, '" . mosGetParam($_REQUEST, 'published') . "' )"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); JLMS_quiz_admin_class::JQ_orderQuest_inside(mosGetParam($_REQUEST, 'id'), mosGetParam($_REQUEST, 'c_quiz_id'), $JLMS_DB->insertid(), $q_ordering); } } } elseif (mosGetParam($_REQUEST, 'c_type') == 21 && $row->c_id) { $query = "UPDATE #__lms_quiz_t_question SET c_pool_gqp='" . mosGetParam($_REQUEST, 'c_pool_gqp') . "', c_quiz_id ='" . mosGetParam($_REQUEST, 'c_quiz_id') . "' WHERE c_id = '" . $row->c_id . "'"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $qid = $row->c_id; JLMS_quiz_admin_class::JQ_orderQuest_inside(mosGetParam($_REQUEST, 'id'), mosGetParam($_REQUEST, 'c_quiz_id'), $row->c_id, $q_ordering); } else { if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $qid = $row->c_id; JLMS_quiz_admin_class::JQ_orderQuest_inside($id, $row->c_quiz_id, $qid, $q_ordering); } if ($quest_params->get('survey_question')) { $query = "UPDATE #__lms_quiz_t_question SET c_point='0' where c_id='" . $qid . "'"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } if ($row->c_type == 1 || $row->c_type == 12 || $row->c_type == 2 || $row->c_type == 13) { $field_order = 0; $ans_right = array(); if (isset($_REQUEST['jq_checked'])) { foreach ($_REQUEST['jq_checked'] as $sss) { $ans_right[] = $sss; } } if (isset($_POST['jq_hid_fields'])) { $fids_arr = array(); $mcounter = 0; foreach ($_POST['jq_hid_fields'] as $f_row) { $new_field = new mos_JoomQuiz_ChoiceField($JLMS_DB); if (intval($_POST['jq_hid_fields_ids'][$mcounter])) { $new_field->c_id = intval($_POST['jq_hid_fields_ids'][$mcounter]); } $new_field->c_question_id = $qid; $f_row_p = get_magic_quotes_gpc() ? stripslashes($f_row) : $f_row; $f_row_p = JLMS_quiz_admin_class::JQ_helper_badText($f_row_p); //(Max): $new_field->c_choice = $f_row_p; $new_field->c_right = in_array($field_order + 1, $ans_right) ? 1 : 0; $new_field->ordering = $field_order; if (!$new_field->check()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$new_field->store()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } $fids_arr[] = $new_field->c_id; $field_order++; $mcounter++; } $fieldss = implode(',', $fids_arr); $query = "DELETE FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $qid . "' AND c_id NOT IN (" . $fieldss . ")"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } else { $query = "DELETE FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $qid . "'"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } } elseif ($row->c_type == 3) { $query = "SELECT c_id,c_choice FROM #__lms_quiz_t_choice WHERE c_question_id = '" . $qid . "'"; $JLMS_DB->setQuery($query); $faltrue = $JLMS_DB->LoadObjectList(); $field_order = 0; $ans_right = intval(mosGetParam($_REQUEST, 'znach', 1)); $ans_true = 0; $ans_false = 0; if ($ans_right) { $ans_true = 1; } else { $ans_false = 1; } $new_field = new mos_JoomQuiz_ChoiceField($JLMS_DB); if (count($faltrue)) { if ($faltrue[0]->c_choice == 'true') { $new_field->c_id = $faltrue[0]->c_id; } else { if ($faltrue[1]->c_choice == 'true') { $new_field->c_id = $faltrue[1]->c_id; } } } $new_field->c_question_id = $qid; $new_field->c_choice = "true"; $new_field->c_right = $ans_true; $new_field->ordering = 0; if (!$new_field->check()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$new_field->store()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } $new_field = new mos_JoomQuiz_ChoiceField($JLMS_DB); if (count($faltrue)) { if ($faltrue[0]->c_choice == 'false') { $new_field->c_id = $faltrue[0]->c_id; } else { if ($faltrue[1]->c_choice == 'false') { $new_field->c_id = $faltrue[1]->c_id; } } } $new_field->c_question_id = $qid; $new_field->c_choice = "false"; $new_field->c_right = $ans_false; $new_field->ordering = 0; if (!$new_field->check()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$new_field->store()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } } elseif ($row->c_type == 4 || $row->c_type == 5 || $row->c_type == 11) { $mcounter = 0; $fids_arr = array(); $field_order = 0; if (isset($_POST['jq_hid_fields_left'])) { foreach ($_POST['jq_hid_fields_left'] as $f_row) { $new_field = new mos_JoomQuiz_MatchField($JLMS_DB); $new_field->c_question_id = $qid; $f_row_p = get_magic_quotes_gpc() ? stripslashes($f_row) : $f_row; $f_row_p = JLMS_quiz_admin_class::JQ_helper_badText($f_row_p); //(Max): $new_field->c_left_text = $f_row_p; $c_right_txt = isset($_POST['jq_hid_fields_right'][$field_order]) ? $_POST['jq_hid_fields_right'][$field_order] : ''; $c_right_txt = get_magic_quotes_gpc() ? stripslashes($c_right_txt) : $c_right_txt; $c_right_txt = JLMS_quiz_admin_class::JQ_helper_badText($c_right_txt); //(Max): $new_field->c_right_text = $c_right_txt; $new_field->ordering = $field_order; if (!$new_field->check()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$new_field->store()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } $fids_arr[] = $new_field->c_id; $field_order++; $mcounter++; } $fieldss = implode(',', $fids_arr); $query = "DELETE FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $qid . "' AND c_id NOT IN (" . $fieldss . ")"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } else { $query = "DELETE FROM #__lms_quiz_t_matching WHERE c_question_id = '" . $qid . "'"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } } elseif ($row->c_type == 6) { $JLMS_DB->SetQuery("SELECT c_id FROM #__lms_quiz_t_blank WHERE c_question_id = '" . $qid . "'"); $bid = $JLMS_DB->LoadResult(); if (!$bid) { $JLMS_DB->SetQuery("INSERT INTO #__lms_quiz_t_blank (c_question_id, c_default) VALUES('" . $qid . "','" . mysql_real_escape_string($_POST['c_default']) . "')"); $JLMS_DB->query(); $bid = $JLMS_DB->insertid(); } else { $JLMS_DB->SetQuery("UPDATE #__lms_quiz_t_blank SET c_default = '" . mysql_real_escape_string($_POST['c_default']) . "' WHERE c_question_id = '" . $qid . "'"); $JLMS_DB->query(); } $field_order = 0; $mcounter = 0; $fids_arr = array(); if (isset($_POST['jq_hid_fields'])) { foreach ($_POST['jq_hid_fields'] as $f_row) { $new_field = new mos_JoomQuiz_BlankTextField($JLMS_DB); if (intval($_POST['jq_hid_fields_ids'][$mcounter])) { $new_field->c_id = intval($_POST['jq_hid_fields_ids'][$mcounter]); } $new_field->c_blank_id = $bid; $f_row_p = get_magic_quotes_gpc() ? stripslashes($f_row) : $f_row; $f_row_p = JLMS_quiz_admin_class::JQ_helper_badText($f_row_p); //(Max): $new_field->c_text = $f_row_p; $new_field->ordering = $field_order; if (!$new_field->check()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$new_field->store()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } $fids_arr[] = $new_field->c_id; $field_order++; $mcounter++; } $fieldss = implode(',', $fids_arr); $query = "DELETE FROM #__lms_quiz_t_text WHERE c_blank_id = '" . $bid . "' AND c_id NOT IN (" . $fieldss . ")"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } else { $query = "DELETE FROM #__lms_quiz_t_text WHERE c_blank_id = '" . $bid . "'"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } } elseif ($row->c_type == 9) { $field_order = 0; $mcounter = 0; $fids_arr = array(); if (isset($_POST['jq_hid_fields'])) { foreach ($_POST['jq_hid_fields'] as $f_row) { $new_field = new mos_JoomQuiz_ScaleField($JLMS_DB); if (intval($_POST['jq_hid_fields_ids'][$mcounter])) { $new_field->c_id = intval($_POST['jq_hid_fields_ids'][$mcounter]); } $new_field->c_question_id = $qid; $f_row_p = get_magic_quotes_gpc() ? stripslashes($f_row) : $f_row; $f_row_p = JLMS_quiz_admin_class::JQ_helper_badText($f_row_p); //(Max): $new_field->c_field = $f_row_p; $new_field->ordering = $field_order; $new_field->c_type = 0; if (!$new_field->check()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$new_field->store()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } $fids_arr[] = $new_field->c_id; $field_order++; $mcounter++; } $fieldss = implode(',', $fids_arr); $query = "DELETE FROM #__lms_quiz_t_scale WHERE c_question_id = '" . $qid . "' AND c_type=0 AND c_id NOT IN (" . $fieldss . ")"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } $field_order = 0; $mcounter = 0; $fids_arr2 = array(); if (isset($_POST['jq_hid_fields_mark'])) { foreach ($_POST['jq_hid_fields_mark'] as $f_row) { $new_field = new mos_JoomQuiz_ScaleField($JLMS_DB); if (intval($_POST['jq_hid_fields_mark_ids'][$mcounter])) { $new_field->c_id = intval($_POST['jq_hid_fields_mark_ids'][$mcounter]); } $new_field->c_question_id = $qid; $f_row_p = get_magic_quotes_gpc() ? stripslashes($f_row) : $f_row; $f_row_p = JLMS_quiz_admin_class::JQ_helper_badText($f_row_p); //(Max): $new_field->c_field = $f_row_p; $new_field->ordering = $field_order; $new_field->c_type = 1; if (!$new_field->check()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$new_field->store()) { echo "<script> alert('" . $new_field->getError() . "'); window.history.go(-1); </script>\n"; exit; } $fids_arr2[] = $new_field->c_id; $field_order++; $mcounter++; } $fieldss = implode(',', $fids_arr2); $query = "DELETE FROM #__lms_quiz_t_scale WHERE c_question_id = '" . $qid . "' AND c_type=1 AND c_id NOT IN (" . $fieldss . ")"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } } if (isset($row->c_quiz_id) && $row->c_quiz_id) { $query = "SELECT * FROM #__lms_quiz_t_quiz WHERE c_id = '" . $row->c_quiz_id . "'"; $JLMS_DB->setQuery($query); $quiz_data = $JLMS_DB->loadObject(); } if (isset($_REQUEST['c_right_message'])) { $c_right_message = get_magic_quotes_gpc() ? stripslashes($_REQUEST['c_right_message']) : $_REQUEST['c_right_message']; } else { $c_right_message = get_magic_quotes_gpc() ? stripslashes($quiz_data->c_right_message) : $quiz_data->c_right_message; } if (isset($_REQUEST['c_wrong_message'])) { $c_wrong_message = get_magic_quotes_gpc() ? stripslashes($_REQUEST['c_wrong_message']) : $_REQUEST['c_wrong_message']; } else { $c_wrong_message = get_magic_quotes_gpc() ? stripslashes($quiz_data->c_wrong_message) : $quiz_data->c_wrong_message; } if (isset($qid) && $qid) { $query = "DELETE FROM #__lms_quiz_t_question_fb WHERE quest_id = {$qid}"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "INSERT INTO #__lms_quiz_t_question_fb (quest_id, choice_id, fb_text)" . "\n VALUES ({$qid}, -1, " . $JLMS_DB->Quote($c_wrong_message) . ")," . "\n ({$qid}, 0, " . $JLMS_DB->Quote($c_right_message) . ")"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); } JLMS_quiz_admin_class::JQ_Calculate_Quiz_totalScore($row->c_quiz_id); // JLMS_quiz_admin_class::GQP_save_multicat($row->c_id); //sofranenie v tablicu levels, teper ne nugno if ($page == 'apply_quest') { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&id={$id}&page=editA_quest&c_id=" . $row->c_id)); } elseif ($page == 'apply_quest_gqp') { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&page=editA_quest_gqp&c_id=" . $row->c_id)); } else { if ($gqp) { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&page=setup_gqp")); } else { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&id={$id}&page=setup_quest")); } } }
function JLMS_saveHWResult($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)); $user_id = intval(mosGetParam($_REQUEST, 'user_id', 0)); $hw_id = intval(mosGetParam($_REQUEST, 'hw_id', 0)); $JLMS_ACL =& JLMSFactory::getACL(); $assigned_groups_only = $JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only'); if ($JLMS_ACL->CheckPermissions('homework', 'manage') && ($hw_id && JLMS_GetHWCourse($hw_id) == $course_id)) { $oldH = new mos_Joomla_LMS_HomeWork($db); $AND_ST = ""; if ($assigned_groups_only) { $groups_where_admin_manager = JLMS_ACL_HELPER::GetAssignedGroups($user->get('id'), $hw_id); $groups_where_isset_user = JLMS_ACL_HELPER::GetUserGlobalGroup($user->get('id'), $hw_id); $groups_where_admin_manager = array_merge($groups_where_admin_manager, $groups_where_isset_user); if (count($groups_where_admin_manager)) { $AND_ST .= "\n AND (is_limited = 0 OR groups LIKE '%|{$groups_where_admin_manager['0']}|%'"; for ($i = 1; $i < count($groups_where_admin_manager); $i++) { $AND_ST .= "\n OR groups like '%|{$groups_where_admin_manager[$i]}|%'"; } $AND_ST .= "\n OR owner_id = '" . $user->get('id') . "')"; } else { $AND_ST .= "\n AND (is_limited = 0 OR owner_id = '" . $user->get('id') . "' OR a.id = 0) AND groups = ''"; } } $oldH->addCond($AND_ST); $oldH->load($hw_id); if (!$oldH->id) { JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=hw_stats&course_id={$course_id}&id=" . $hw_id)); } $row = new mos_JLMS_HomeWork_Result($db); $row->bind(JRequest::get('POST')); $row->comments = strval(JLMS_getParam_LowFilter($_POST, 'comments', '')); $row->comments = JLMS_ProcessText_LowFilter($row->comments); if ($row->grade == _STATUS_INCOMPLETE) { $row->hw_status = '0'; } $row->store(); $do_notify = false; if (isset($row->id) && $row->id) { $query = "SELECT hw_status FROM #__lms_homework_results WHERE id = {$row->id}"; $db->setQuery($query); $do_notify = $db->loadResult(); } if ($do_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 . "'"; $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}'] = 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=" . $hw_id)); }