コード例 #1
0
ファイル: gradebook.php プロジェクト: ASDAFF/bxApiDocs
	public static function AddExtraAttempts($STUDENT_ID, $TEST_ID, $COUNT = 1)
	{
		global $DB;

		$STUDENT_ID = intval($STUDENT_ID);
		$TEST_ID = intval($TEST_ID);
		$COUNT = intval($COUNT);

		$strSql = "SELECT ID, EXTRA_ATTEMPTS FROM b_learn_gradebook WHERE STUDENT_ID = ".$STUDENT_ID." AND TEST_ID = ".$TEST_ID."";
		$rs = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		if (!ar == $rs->Fetch())
		{
			$ID = CGradeBook::Add(Array(
					"STUDENT_ID" => $STUDENT_ID,
					"TEST_ID" => $TEST_ID,
					"RESULT" => "0",
					"MAX_RESULT" => "0",
					"COMPLETED" => "N",
					"EXTRA_ATTEMPTS" => $COUNT
			));

			return ($ID > 0);
		}
		else
		{
			$strSql = "UPDATE b_learn_gradebook SET EXTRA_ATTEMPTS = ".($ar["EXTRA_ATTEMPTS"] + $COUNT)." WHERE ID = ".$ar["ID"];
			if (!$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__))
				return false;
		}
	}
コード例 #2
0
ファイル: component.php プロジェクト: webgksupport/alpina
//Params
$arParams["TEST_DETAIL_TEMPLATE"] = strlen($arParams["TEST_DETAIL_TEMPLATE"]) > 0 ? htmlspecialcharsbx($arParams["TEST_DETAIL_TEMPLATE"]) : "course/test.php?TEST_ID=#TEST_ID#";
$arParams["COURSE_DETAIL_TEMPLATE"] = strlen($arParams["COURSE_DETAIL_TEMPLATE"]) > 0 ? htmlspecialcharsbx($arParams["COURSE_DETAIL_TEMPLATE"]) : "course/index.php?COURSE_ID=#COURSE_ID#";
if (strlen($arParams["TEST_ID_VARIABLE"]) <= 0 || !preg_match("#^[A-Za-z_][A-Za-z01-9_]*\$#", $arParams["TEST_ID_VARIABLE"])) {
    $arParams["TEST_ID_VARIABLE"] = "TEST_ID";
}
//Set Title
$arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y";
if ($arParams["SET_TITLE"] == "Y") {
    $APPLICATION->SetTitle(GetMessage("LEARNING_PROFILE_TITLE"));
}
$currentPage = GetPagePath(false, false);
$queryString = htmlspecialcharsbx(DeleteParam(array($arParams["TEST_ID_VARIABLE"])));
$arResult = array("RECORDS" => array(), "ATTEMPTS" => array(), "CURRENT_PAGE" => $currentPage . ($queryString == "" ? "" : "?") . $queryString);
//GradeBook
$rsGradebook = CGradeBook::GetList(array("ID" => "DESC"), array("STUDENT_ID" => intval($USER->GetID()), "SITE_ID" => LANG, "TEST_ID" => array_key_exists($arParams["TEST_ID_VARIABLE"], $_REQUEST) ? intval($_REQUEST[$arParams["TEST_ID_VARIABLE"]]) : ""));
// Collection of tests' ids
$arTestsIds = array();
while ($arGradebook = $rsGradebook->GetNext()) {
    //Test Url
    $arGradebook["TEST_DETAIL_URL"] = CComponentEngine::MakePathFromTemplate($arParams["TEST_DETAIL_TEMPLATE"], array("TEST_ID" => $arGradebook["TEST_ID"], "COURSE_ID" => $arGradebook["COURSE_ID"]));
    $arGradebook['APPROVED'] = $arGradebook['TEST_APPROVED'];
    //Course Url
    $arGradebook["COURSE_DETAIL_URL"] = CComponentEngine::MakePathFromTemplate($arParams["COURSE_DETAIL_TEMPLATE"], array("COURSE_ID" => $arGradebook["COURSE_ID"]));
    $arGradebook["ATTEMPT_DETAIL_URL"] = $arResult["CURRENT_PAGE"] . ($queryString == "" ? "?" : "&") . $arParams["TEST_ID_VARIABLE"] . "=" . $arGradebook["TEST_ID"];
    $arResult["RECORDS"][] = $arGradebook;
    // collect tests' ids
    if (!in_array($arGradebook['TEST_ID'], $arTestsIds)) {
        $arTestsIds[] = $arGradebook['TEST_ID'];
    }
}
コード例 #3
0
ファイル: attempt.php プロジェクト: k-kalashnikov/geekcon_new
 function OnAttemptChange($ATTEMPT_ID, $bCOMPLETED = false)
 {
     global $DB;
     $ATTEMPT_ID = intval($ATTEMPT_ID);
     if ($ATTEMPT_ID < 1) {
         return false;
     }
     $strSql = "SELECT A.*, T.APPROVED, T.COMPLETED_SCORE, T.COURSE_ID " . "FROM b_learn_attempt A " . "INNER JOIN b_learn_test T ON A.TEST_ID = T.ID " . "WHERE A.ID = '" . $ATTEMPT_ID . "' AND A.STATUS = 'F' ";
     $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if (!($arAttempt = $res->Fetch())) {
         return false;
     }
     $COMPLETED = "N";
     if ($arAttempt["APPROVED"] == "Y" && intval($arAttempt["COMPLETED_SCORE"]) > 0 && CTestAttempt::IsTestCompleted($ATTEMPT_ID, $arAttempt["COMPLETED_SCORE"])) {
         $COMPLETED = "Y";
     }
     if ($bCOMPLETED) {
         $COMPLETED = "Y";
     }
     $strSql = "UPDATE b_learn_attempt SET COMPLETED = '" . $COMPLETED . "' " . "WHERE ID = '" . $ATTEMPT_ID . "'";
     if (!($res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__))) {
         return false;
     }
     $strSql = "SELECT * FROM b_learn_gradebook WHERE STUDENT_ID='" . $arAttempt["STUDENT_ID"] . "' AND TEST_ID='" . $arAttempt["TEST_ID"] . "'";
     $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if (!($arGradeBook = $res->Fetch())) {
         $arFields = array("STUDENT_ID" => $arAttempt["STUDENT_ID"], "TEST_ID" => $arAttempt["TEST_ID"], "RESULT" => $arAttempt["SCORE"], "MAX_RESULT" => intval($arAttempt["MAX_SCORE"]), "COMPLETED" => $COMPLETED);
         $at = new CGradeBook();
         if (!($res = $at->Add($arFields))) {
             return false;
         }
         CCertification::Certificate($arAttempt["STUDENT_ID"], $arAttempt["COURSE_ID"]);
     } else {
         $strSql = "SELECT A.SCORE, A.MAX_SCORE FROM b_learn_attempt A " . "WHERE A.STUDENT_ID = '" . $arAttempt["STUDENT_ID"] . "' AND A.TEST_ID = '" . $arAttempt["TEST_ID"] . "'  ORDER BY COMPLETED DESC, SCORE DESC";
         //AND A.COMPLETED = 'Y'
         $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if (!($arMaxScore = $res->Fetch())) {
             return false;
         }
         if ($arGradeBook["COMPLETED"] == "Y") {
             $COMPLETED = "Y";
         }
         $strSql = "UPDATE b_learn_gradebook SET RESULT = '" . intval($arMaxScore["SCORE"]) . "', MAX_RESULT = '" . intval($arMaxScore["MAX_SCORE"]) . "',COMPLETED = '" . $COMPLETED . "' " . "WHERE ID = '" . $arGradeBook["ID"] . "'";
         if (!($res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__))) {
             return false;
         }
         CCertification::Certificate($arAttempt["STUDENT_ID"], $arAttempt["COURSE_ID"]);
     }
     return true;
 }
コード例 #4
0
ファイル: certification.php プロジェクト: Satariall/izurit
 function Delete($ID)
 {
     global $DB;
     $ID = intval($ID);
     if ($ID < 1) {
         return false;
     }
     CLearnHelper::FireEvent('OnBeforeCertificateDelete', $ID);
     $strSql = "SELECT G.ID FROM b_learn_certification C\n\t\t\t\t\tINNER JOIN b_learn_test T ON C.COURSE_ID = T.COURSE_ID\n\t\t\t\t\tINNER JOIN b_learn_gradebook G ON (G.TEST_ID = T.ID AND G.STUDENT_ID = C.STUDENT_ID)\n\t\t\t\t\tWHERE C.ID = " . $ID;
     $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     //Gradebook
     while ($arRecord = $res->Fetch()) {
         if (!CGradeBook::Delete($arRecord["ID"])) {
             return false;
         }
     }
     $strSql = "DELETE FROM b_learn_certification WHERE ID = " . $ID;
     if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
         return false;
     }
     CLearnHelper::FireEvent('OnAfterCertificateDelete', $ID);
     return true;
 }
コード例 #5
0
 function GetList($arOrder = array(), $arFilter = array())
 {
     global $DB, $USER, $APPLICATION;
     $oPermParser = new CLearnParsePermissionsFromFilter($arFilter);
     $arSqlSearch = CGradeBook::GetFilter($arFilter);
     $strSqlSearch = "";
     for ($i = 0; $i < count($arSqlSearch); $i++) {
         if (strlen($arSqlSearch[$i]) > 0) {
             $strSqlSearch .= " AND " . $arSqlSearch[$i] . " ";
         }
     }
     //Sites
     $SqlSearchLang = "''";
     if (array_key_exists("SITE_ID", $arFilter)) {
         $arLID = array();
         if (is_array($arFilter["SITE_ID"])) {
             $arLID = $arFilter["SITE_ID"];
         } else {
             if (strlen($arFilter["SITE_ID"]) > 0) {
                 $arLID[] = $arFilter["SITE_ID"];
             }
         }
         foreach ($arLID as $v) {
             $SqlSearchLang .= ", '" . $DB->ForSql($v, 2) . "'";
         }
     }
     $strSql = "SELECT DISTINCT G.*, T.NAME as TEST_NAME, T.COURSE_ID as COURSE_ID, \n\t\t(T.ATTEMPT_LIMIT + G.EXTRA_ATTEMPTS) AS ATTEMPT_LIMIT, TUL.NAME as COURSE_NAME, \n\t\tC.LINKED_LESSON_ID AS LINKED_LESSON_ID, " . $DB->Concat("'('", 'U.LOGIN', "') '", "CASE WHEN U.NAME IS NULL THEN '' ELSE U.NAME END", "' '", "CASE WHEN U.LAST_NAME IS NULL THEN '' ELSE U.LAST_NAME END") . " as USER_NAME, U.ID as USER_ID " . "FROM b_learn_gradebook G " . "INNER JOIN b_learn_test T ON G.TEST_ID = T.ID " . "INNER JOIN b_user U ON U.ID = G.STUDENT_ID " . "LEFT JOIN b_learn_course C ON C.ID = T.COURSE_ID " . "LEFT JOIN b_learn_lesson TUL ON TUL.ID = C.LINKED_LESSON_ID " . "LEFT JOIN b_learn_test_mark TM ON G.TEST_ID = TM.TEST_ID " . (strlen($SqlSearchLang) > 2 ? "LEFT JOIN b_learn_course_site CS ON C.ID = CS.COURSE_ID " : "") . "WHERE \n\t\t\t(TM.SCORE IS NULL \n\t\t\tOR TM.SCORE = \n\t\t\t\t(SELECT SCORE \n\t\t\t\tFROM b_learn_test_mark \n\t\t\t\tWHERE SCORE >= (G.RESULT/G.MAX_RESULT*100) \n\t\t\t\tORDER BY SCORE ASC \n\t\t\t\tLIMIT 1)\n\t\t\t) ";
     if ($oPermParser->IsNeedCheckPerm()) {
         $strSql .= " AND TUL.ID IN (" . $oPermParser->SQLForAccessibleLessons() . ") ";
     }
     $strSql .= $strSqlSearch;
     if (strlen($SqlSearchLang) > 2) {
         $strSql .= " AND CS.SITE_ID IN (" . $SqlSearchLang . ")";
     }
     /* was:
     		$bCheckPerm = ($APPLICATION->GetUserRight("learning") < "W" && !$USER->IsAdmin() && $arFilter["CHECK_PERMISSIONS"] != "N");
     
     		$strSql =
     		"SELECT DISTINCT G.*, T.NAME as TEST_NAME, T.COURSE_ID as COURSE_ID, (T.ATTEMPT_LIMIT + G.EXTRA_ATTEMPTS) AS ATTEMPT_LIMIT, C.NAME as COURSE_NAME, C.LINKED_LESSON_ID AS LINKED_LESSON_ID ".
     		$DB->Concat("'('",'U.LOGIN',"') '","CASE WHEN U.NAME IS NULL THEN '' ELSE U.NAME END","' '", "CASE WHEN U.LAST_NAME IS NULL THEN '' ELSE U.LAST_NAME END")." as USER_NAME, U.ID as USER_ID ".
     		"FROM b_learn_gradebook G ".
     		"INNER JOIN b_learn_test T ON G.TEST_ID = T.ID ".
     		"INNER JOIN b_user U ON U.ID = G.STUDENT_ID ".
     		"LEFT JOIN b_learn_course C ON C.ID = T.COURSE_ID ".
     		"LEFT JOIN b_learn_lesson TUL ON TUL.ID = C.LINKED_LESSON_ID ".
     		"LEFT JOIN b_learn_test_mark TM ON G.TEST_ID = TM.TEST_ID ".
     		(strlen($SqlSearchLang) > 2 ? "LEFT JOIN b_learn_course_site CS ON C.ID = CS.COURSE_ID " : "").
     		($bCheckPerm ? "LEFT JOIN b_learn_course_permission CP ON CP.COURSE_ID = C.ID " : "").
     		"WHERE 1=1 ".
     		"AND (TM.SCORE IS NULL OR TM.SCORE = (SELECT SCORE FROM b_learn_test_mark WHERE SCORE >= (G.RESULT/G.MAX_RESULT*100) ORDER BY SCORE ASC LIMIT 1)) ".
     		($bCheckPerm ?
     		"AND CP.USER_GROUP_ID IN (".$USER->GetGroups().") ".
     		"AND CP.PERMISSION >= '".(strlen($arFilter["MIN_PERMISSION"])==1 ? $arFilter["MIN_PERMISSION"] : "R")."' ".
     		"AND (CP.PERMISSION='X' OR TUL.ACTIVE='Y')"
     		:"").
     		$strSqlSearch.
     		(strlen($SqlSearchLang) > 2 ? " AND CS.SITE_ID IN (".$SqlSearchLang.")" : "");
     		*/
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     foreach ($arOrder as $by => $order) {
         $by = strtolower($by);
         $order = strtolower($order);
         if ($order != "asc") {
             $order = "desc";
         }
         if ($by == "id") {
             $arSqlOrder[] = " G.ID " . $order . " ";
         } elseif ($by == "student_id") {
             $arSqlOrder[] = " G.STUDENT_ID " . $order . " ";
         } elseif ($by == "test_id") {
             $arSqlOrder[] = " G.TEST_ID " . $order . " ";
         } elseif ($by == "completed") {
             $arSqlOrder[] = " G.COMPLETED " . $order . " ";
         } elseif ($by == "result") {
             $arSqlOrder[] = " G.RESULT " . $order . " ";
         } elseif ($by == "max_result") {
             $arSqlOrder[] = " G.MAX_RESULT " . $order . " ";
         } elseif ($by == "user_name") {
             $arSqlOrder[] = " USER_NAME " . $order . " ";
         } elseif ($by == "test_name") {
             $arSqlOrder[] = " TEST_NAME " . $order . " ";
         } else {
             $arSqlOrder[] = " G.ID " . $order . " ";
             $by = "id";
         }
     }
     $strSqlOrder = "";
     DelDuplicateSort($arSqlOrder);
     for ($i = 0; $i < count($arSqlOrder); $i++) {
         if ($i == 0) {
             $strSqlOrder = " ORDER BY ";
         } else {
             $strSqlOrder .= ",";
         }
         $strSqlOrder .= $arSqlOrder[$i];
     }
     $strSql .= $strSqlOrder;
     //echo $strSql;
     return $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
 }
コード例 #6
0
            case "delete":
                $oAccess = CLearnAccess::GetInstance($USER->GetID());
                if (!$oAccess->IsLessonAccessible(CGradeBook::LessonIdByGradeBookId($ID), CLearnAccess::OP_LESSON_WRITE)) {
                    break;
                }
                @set_time_limit(0);
                $DB->StartTransaction();
                if (!CGradeBook::Delete($ID)) {
                    $DB->Rollback();
                    $lAdmin->AddGroupError(GetMessage("LEARNING_DELETE_ERROR"), $ID);
                }
                $DB->Commit();
                break;
            case "completed":
            case "uncompleted":
                $ob = new CGradeBook();
                $arFields = array("COMPLETED" => $_REQUEST['action'] == "completed" ? "Y" : "N");
                if (!$ob->Update($ID, $arFields)) {
                    if ($e = $APPLICATION->GetException()) {
                        $lAdmin->AddGroupError(GetMessage("SAVE_ERROR") . $ID . ": " . $e->GetString(), $ID);
                    }
                }
                break;
        }
    }
}
// fetch data
$rsData = CGradeBook::GetList(array($by => $order), $arFilter);
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
// navigation string setup
コード例 #7
0
ファイル: component.php プロジェクト: Satariall/izurit
        $arTest["FINAL_INDICATION_SCORE"] = "N";
        $arTest["FINAL_INDICATION_MARK"] = "N";
        $arTest["FINAL_INDICATION_MESSAGE"] = "N";
    }
    if ($arTest["PREVIOUS_TEST_ID"] > 0 && $arTest["PREVIOUS_TEST_SCORE"] > 0) {
        $rsPrevTest = CTest::GetList(array(), array("ID" => $arTest["PREVIOUS_TEST_ID"], 'CHECK_PERMISSIONS' => 'N'));
        if ($arPrevTest = $rsPrevTest->GetNext()) {
            if ($parent = $this->GetParent()) {
                $testUrlTemplate = CComponentEngine::MakePathFromTemplate($parent->arResult["URL_TEMPLATES"]["test"], array("TEST_ID" => $arPrevTest["ID"], "COURSE_ID" => $arPrevTest["COURSE_ID"]));
                $arTest["PREVIOUS_TEST_LINK"] = "<a href=\"" . $testUrlTemplate . "\">" . $arPrevTest["NAME"] . "</a>";
            }
        }
    }
}
if ($USER->GetID()) {
    $arTest["ATTEMPT_LIMIT"] += CGradeBook::GetExtraAttempts($USER->GetID(), $arParams["TEST_ID"]);
}
$oAccess = CLearnAccess::GetInstance($USER->GetID());
$isRelativelyHighAccessLevel = $oAccess->IsBaseAccess(CLearnAccess::OP_LESSON_CREATE | CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_WRITE | CLearnAccess::OP_LESSON_REMOVE);
$bCheckPerm = !$isRelativelyHighAccessLevel && !$USER->IsAdmin();
if ($bCheckPerm && $arTest["PREVIOUS_TEST_ID"] > 0 && $arTest["PREVIOUS_TEST_SCORE"] > 0 && !CTest::isPrevPassed($arTest["PREVIOUS_TEST_ID"], $arTest["PREVIOUS_TEST_SCORE"])) {
    if ($arTest["PREVIOUS_TEST_LINK"]) {
        $errors[] = str_replace("#TEST_LINK#", "\"" . $arTest["PREVIOUS_TEST_LINK"] . "\"", GetMessage("LEARNING_TEST_DENIED_PREVIOUS"));
    }
}
//Session variables
$userID = $USER->GetID() ? $USER->GetID() : 0;
$sessAttemptID =& $_SESSION["LEARN_" . $arParams["TEST_ID"] . "_ATTEMPT_ID_" . $userID];
$sessAttemptFinished =& $_SESSION["LEARN_" . $arParams["TEST_ID"] . "_FINISHED_" . $userID];
$sessAttemptError =& $_SESSION["LEARN_" . $arParams["TEST_ID"] . "_ERROR_" . $userID];
$sessAttempt =& $_SESSION["LEARN_" . $arParams["TEST_ID"] . "_COMPLETED_" . $userID];
コード例 #8
0
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0) {
            continue;
        }
        $ID = intval($ID);
        switch ($_REQUEST['action']) {
            case "delete":
                @set_time_limit(0);
                $res = CTestAttempt::GetList(array(), array('ID' => $ID, 'ACCESS_OPERATIONS' => CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_WRITE));
                if ($ar = $res->Fetch()) {
                    $DB->StartTransaction();
                    if (!CTestAttempt::Delete($ID)) {
                        $DB->Rollback();
                        $lAdmin->AddGroupError(GetMessage("LEARNING_DELETE_ERROR"), $ID);
                    } else {
                        CGradeBook::RecountAttempts($ar["STUDENT_ID"], $ar["TEST_ID"]);
                    }
                    $DB->Commit();
                }
                break;
        }
    }
}
// fetch data
$rsData = CTestAttempt::GetList(array($by => $order), $arFilter, array(), array('nPageSize' => CAdminResult::GetNavSize($sTableID)));
$rsData = new CAdminResult($rsData, $sTableID);
// navigation string setup
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("LEARNING_ADMIN_RESULTS")));
// list header
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "id", "default" => true), array("id" => "USER_NAME", "content" => GetMessage('LEARNING_ADMIN_STUDENT'), "sort" => "student_id", "default" => true), array("id" => "TEST_NAME", "content" => GetMessage('LEARNING_ADMIN_TEST'), "sort" => "test_name", "default" => true), array("id" => "DATE_START", "content" => GetMessage('LEARNING_ADMIN_DATE_START'), "sort" => "date_start", "default" => true), array("id" => "DATE_END", "content" => GetMessage('LEARNING_ADMIN_DATE_END'), "sort" => "date_end", "default" => true), array("id" => "STATUS", "content" => GetMessage('LEARNING_ADMIN_STATUS'), "sort" => "status", "default" => true), array("id" => "QUESTIONS", "content" => Getmessage('LEARNING_ADMIN_QUESTIONS'), "sort" => "questions", "default" => true, "align" => "center"), array("id" => "COMPLETED", "content" => Getmessage('LEARNING_ADMIN_COMPLETED'), "sort" => "completed", "default" => true), array("id" => "SCORE", "content" => GetMessage('LEARNING_ADMIN_SCORE'), "sort" => "score", "default" => true), array("id" => "MAX_SCORE", "content" => GetMessage('LEARNING_ADMIN_MAX_SCORE'), "sort" => "max_score", "default" => true)));
// building list
コード例 #9
0
ファイル: gradebook.php プロジェクト: rasuldev/torino
 /**
  * <p>Возвращает список записей журнала по фильтру arFilter, отсортированный в порядке arOrder. Учитываются права доступа текущего пользователя.</p>
  *
  *
  *
  *
  * @param array $arrayarOrder = Array("ID"=>"DESC") Массив для сортировки результата. Массив вида <i>array("поле
  * сортировки"=&gt;"направление сортировки" [, ...])</i>.<br> Поле для
  * сортировки может принимать значения: <ul> <li> <b>ID</b> - идентификатор
  * записи;</li> <li> <b>TEST_ID</b> - идентификатор теста;</li> <li> <b>STUDENT_ID</b> -
  * идентификатор студента ;</li> <li> <b>RESULT</b> - количество баллов;</li> <li>
  * <b>MAX_RESULT</b> - максимальное количество баллов;</li> <li> <b>COMPLETED</b> - тест
  * пройден;</li> <li> <b>USER_NAME</b> - имя студента;</li> <li> <b>TEST_NAME</b> - название
  * теста.</li> </ul> Направление сортировки может принимать значения: <ul>
  * <li> <b>asc</b> - по возрастанию;</li> <li> <b>desc</b> - по убыванию;</li> </ul>
  * Необязательный. По умолчанию фильтруется по убыванию
  * идентификатора записи журнала.
  *
  *
  *
  * @param array $arrayarFilter = Array() Массив вида <i> array("фильтруемое поле"=&gt;"значение фильтра" [, ...])</i>.
  * Фильтруемое поле может принимать значения: <ul> <li> <b>ID</b> -
  * идентификатор записи;</li> <li> <b>TEST_ID</b> - идентификатор теста;</li> <li>
  * <b>STUDENT_ID</b> - идентификатор студента;</li> <li> <b>RESULT</b> - количество
  * баллов;</li> <li> <b>MAX_RESULT</b> - максимальное количество баллов;</li> <li>
  * <b>COMPLETED</b> - тест пройден (Y|N);</li> <li> <b>USER</b> - пользователь (возможны
  * сложные условия по полям пользователя ID, LOGIN, NAME, LAST_NAME);</li> <li>
  * <b>MIN_PERMISSION</b> - минимальный уровень доcтупа. По умолчанию "R". Список
  * прав доступа см. в <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/setpermission.php">CCourse::SetPermission</a>.</li> <li>
  * <b>CHECK_PERMISSIONS</b> - проверять уровень доступа. Если установлено
  * значение "N" - права доступа не проверяются.</li> </ul> Перед названием
  * фильтруемого поля может указать тип фильтрации: <ul> <li>"!" - не
  * равно</li> <li>"&lt;" - меньше</li> <li>"&lt;=" - меньше либо равно</li> <li>"&gt;" -
  * больше</li> <li>"&gt;=" - больше либо равно</li> </ul> <br> "<i>значения
  * фильтра</i>" - одиночное значение или массив.<br><br> Необязательный.
  * По умолчанию записи не фильтруются.
  *
  *
  *
  * @return CDBResult <p>Возвращается объект <a
  * href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/index.php">CDBResult</a>.</p> </h
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * if (CModule::IncludeModule("learning"))
  * {
  *     $TEST_ID = 45;
  *     $res = CGradebook::GetList(
  *         Array("ID" =&gt; "ASC"), 
  *         Array("TEST_ID" =&gt; $TEST_ID)
  *     );
  * 
  *     while ($arGradebook = $res-&gt;GetNext())
  *     {
  *         echo "Student: ".$arGradebook["USER_NAME"]."; Test name: ".$arGradebook["TEST_NAME"]."; Completed: ".$arGradebook["COMPLETED"]."&lt;br&gt;";
  *     }
  * }
  * 
  * ?&gt;
  * 
  * &lt;?
  * 
  * if (CModule::IncludeModule("learning"))
  * {
  *     $TEST_ID = 45;
  *     $STUDENT_ID = 3;
  * 
  *     $res = CGradebook::GetList(
  *         Array("ID" =&gt; "ASC"), 
  *         Array("CHECK_PERMISSIONS" =&gt; "N", "TEST_ID" =&gt; $TEST_ID, "STUDENT_ID" =&gt; $STUDENT_ID)
  *     );
  * 
  *     while ($arGradebook = $res-&gt;GetNext())
  *     {
  *         echo "Student: ".$arGradebook["USER_NAME"]."; Test name: ".$arGradebook["TEST_NAME"]."; Completed: ".$arGradebook["COMPLETED"]."&lt;br&gt;";
  *     }
  * 
  * }
  * 
  * ?&gt;
  * </pre>
  *
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/main/reference/cdbresult/index.php">CDBResult</a> </li> <li> <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/cgradebook/index.php">CGradeBook</a>::<a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/cgradebook/getbyid.php">GetByID</a> </li> <li><a
  * href="http://dev.1c-bitrix.ru/api_help/learning/fields.php#gradebook">Поля журнала</a></li> </ul> <a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/learning/classes/cgradebook/getlist.php
  * @author Bitrix
  */
 public static function GetList($arOrder = array(), $arFilter = array(), $arNavParams = array())
 {
     global $DB;
     $oPermParser = new CLearnParsePermissionsFromFilter($arFilter);
     $arSqlSearch = array_filter(CGradeBook::GetFilter($arFilter));
     $strSqlSearch = '';
     if (!empty($arSqlSearch)) {
         $strSqlSearch .= implode(' AND ', $arSqlSearch);
     }
     //Sites
     $SqlSearchLang = "''";
     if (array_key_exists("SITE_ID", $arFilter)) {
         $arLID = array();
         if (is_array($arFilter["SITE_ID"])) {
             $arLID = $arFilter["SITE_ID"];
         } else {
             if (strlen($arFilter["SITE_ID"]) > 0) {
                 $arLID[] = $arFilter["SITE_ID"];
             }
         }
         foreach ($arLID as $v) {
             $SqlSearchLang .= ", '" . $DB->ForSql($v, 2) . "'";
         }
     }
     $strSqlFrom = static::__getSqlFromClause($SqlSearchLang);
     if ($oPermParser->IsNeedCheckPerm()) {
         $strSqlFrom .= " AND TUL.ID IN (" . $oPermParser->SQLForAccessibleLessons() . ") ";
     }
     if ($strSqlSearch !== '') {
         $strSqlFrom .= ' AND ' . $strSqlSearch;
     }
     $strSql = "SELECT G.*, T.NAME as TEST_NAME, T.COURSE_ID as COURSE_ID, \n\t\tT.APPROVED as TEST_APPROVED,\n\t\t(T.ATTEMPT_LIMIT + G.EXTRA_ATTEMPTS) AS ATTEMPT_LIMIT, TUL.NAME as COURSE_NAME, \n\t\tC.LINKED_LESSON_ID AS LINKED_LESSON_ID, " . $DB->Concat("'('", 'U.LOGIN', "') '", "CASE WHEN U.NAME IS NULL THEN '' ELSE U.NAME END", "' '", "CASE WHEN U.LAST_NAME IS NULL THEN '' ELSE U.LAST_NAME END") . " as USER_NAME, U.ID as USER_ID " . $strSqlFrom;
     if (!is_array($arOrder)) {
         $arOrder = array();
     }
     foreach ($arOrder as $by => $order) {
         $by = strtolower($by);
         $order = strtolower($order);
         if ($order != "asc") {
             $order = "desc";
         }
         if ($by == "id") {
             $arSqlOrder[] = " G.ID " . $order . " ";
         } elseif ($by == "student_id") {
             $arSqlOrder[] = " G.STUDENT_ID " . $order . " ";
         } elseif ($by == "test_id") {
             $arSqlOrder[] = " G.TEST_ID " . $order . " ";
         } elseif ($by == "completed") {
             $arSqlOrder[] = " G.COMPLETED " . $order . " ";
         } elseif ($by == "result") {
             $arSqlOrder[] = " G.RESULT " . $order . " ";
         } elseif ($by == "max_result") {
             $arSqlOrder[] = " G.MAX_RESULT " . $order . " ";
         } elseif ($by == "user_name") {
             $arSqlOrder[] = " USER_NAME " . $order . " ";
         } elseif ($by == "test_name") {
             $arSqlOrder[] = " TEST_NAME " . $order . " ";
         } else {
             $arSqlOrder[] = " G.ID " . $order . " ";
         }
     }
     $strSqlOrder = "";
     DelDuplicateSort($arSqlOrder);
     for ($i = 0; $i < count($arSqlOrder); $i++) {
         if ($i == 0) {
             $strSqlOrder = " ORDER BY ";
         } else {
             $strSqlOrder .= ",";
         }
         $strSqlOrder .= $arSqlOrder[$i];
     }
     $strSql .= $strSqlOrder;
     if (is_array($arNavParams) && !empty($arNavParams)) {
         if (isset($arNavParams['nTopCount']) && (int) $arNavParams['nTopCount'] > 0) {
             $strSql = $DB->TopSql($strSql, (int) $arNavParams['nTopCount']);
             $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         } else {
             $res_cnt = $DB->Query("SELECT COUNT(G.ID) as C " . $strSqlFrom);
             $res_cnt = $res_cnt->fetch();
             $res = new CDBResult();
             $res->NavQuery($strSql, $res_cnt['C'], $arNavParams);
         }
     } else {
         $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
 }
コード例 #10
0
ファイル: test.php プロジェクト: DarneoStudio/bitrix
 function Delete($ID)
 {
     global $DB;
     $ID = intval($ID);
     if ($ID < 1) {
         return false;
     }
     CLearnHelper::FireEvent('OnBeforeTestDelete', $ID);
     //Gradebook
     $records = CGradeBook::GetList(array(), array("TEST_ID" => $ID));
     while ($arRecord = $records->Fetch()) {
         if (!CGradeBook::Delete($arRecord["ID"])) {
             return false;
         }
     }
     //Attempts
     $attempts = CTestAttempt::GetList(array(), array("TEST_ID" => $ID));
     while ($arAttempt = $attempts->Fetch()) {
         if (!CTestAttempt::Delete($arAttempt["ID"])) {
             return false;
         }
     }
     //Marks
     $marks = CLTestMark::GetList(array(), array("TEST_ID" => $ID));
     while ($arMark = $marks->Fetch()) {
         if (!CLTestMark::Delete($arMark["ID"])) {
             return false;
         }
     }
     $strSql = "DELETE FROM b_learn_test WHERE ID = " . $ID;
     if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
         return false;
     }
     CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'T #' . $ID, 'DESCRIPTION' => 'test removed'));
     CLearnHelper::FireEvent('OnAfterTestDelete', $ID);
     return true;
 }
コード例 #11
0
ファイル: test.php プロジェクト: ASDAFF/bxApiDocs
	/**
	 * <p>Метод удаляет тест с идентификатором ID.</p>
	 *
	 *
	 *
	 *
	 * @param int $ID  Идентификатор теста.
	 *
	 *
	 *
	 * @return bool <p>Метод возвращает <i>true</i> в случае успешного удаления теста, в
	 * противном случае возвращает <i>false</i>.</p><a name="examples"></a>
	 *
	 *
	 * <h4>Example</h4> 
	 * <pre>
	 * &lt;?
	 * if (CModule::IncludeModule("learning"))
	 * {
	 * 
	 *     $TEST_ID = 99;
	 *     $COURSE_ID = 97;
	 * 
	 *     if (CCourse::GetPermission($COURSE_ID) &gt;= 'W')
	 *     {
	 *         @set_time_limit(0);
	 *         $DB-&gt;StartTransaction();
	 *         if (!CTest::Delete($TEST_ID))
	 *         {
	 *             echo "Error!";
	 *             $DB-&gt;Rollback();
	 *         }
	 *         else
	 *             $DB-&gt;Commit();
	 *     }
	 * }
	 * ?&gt;
	 * </pre>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/learning/classes/ctest/delete.php
	 * @author Bitrix
	 */
	public static function Delete($ID)
	{
		global $DB;

		$ID = intval($ID);
		if ($ID < 1) return false;

		CLearnHelper::FireEvent('OnBeforeTestDelete', $ID);

		//Gradebook
		$records = CGradeBook::GetList(Array(), Array("TEST_ID" => $ID));
		while($arRecord = $records->Fetch())
		{
			if(!CGradeBook::Delete($arRecord["ID"]))
				return false;
		}

		//Attempts
		$attempts = CTestAttempt::GetList(Array(), Array("TEST_ID" => $ID));
		while($arAttempt = $attempts->Fetch())
		{
			if(!CTestAttempt::Delete($arAttempt["ID"]))
				return false;
		}

		//Marks
		$marks = CLTestMark::GetList(Array(), Array("TEST_ID" => $ID));
		while($arMark = $marks->Fetch())
		{
			if(!CLTestMark::Delete($arMark["ID"]))
				return false;
		}


		$strSql = "DELETE FROM b_learn_test WHERE ID = ".$ID;

		if (!$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__))
			return false;

		CLearnHelper::FireEvent('OnAfterTestDelete', $ID);

		return true;

	}