RID pole sätitud, palun säti omale RID või hoopis otsi abi spikrist.
Too spikker (sinu keelele spikrit nagunii pole).
Teised kasutajad on saanud lahenduseks ka: Err0771: Sellist vahendit polegi olemas
'; } // CSS header for Pairs templates private function pairsCSSHeader(){ return ''; } // View template for Pairs private function pairsViewTemplate(){ $cwvt=''; return $cwvt; } private function pairsAnswerTemplate(){ $cwat = ''; return $cwat; } // Edit template for Pairs private function pairsEditTemplate(){ $cwvt=''; return $cwvt; } // array translator DB->array function makeArray($data, $info=false){ $r = 0; $c = 0; $a = array(); $rows = split("\n", $data); $r = count($rows); foreach ($rows as $row){ $cols = split(",", $row); $a[]=$cols; } $c = count($a[0]); if ($info){ return array($a, $r, $c); } return $a; } // Pairs View Page public function pairsview() { global $krihvel, $kdb; $isresource = false; if ( isset($_GET['rid'])){ $_SESSION['rid']=$_GET['rid']; } if ( isset($_SESSION['rid'])) { $rid = $_SESSION['rid']; $q_list = "title, description, keywords, mainQuestion, mainQuestionCol, questions, data"; $q_cond = sprintf("resourceID=%s AND type='%s'", $rid, "pairs"); $q = "SELECT %s from resources join pairs using(resourceID) where %s"; $q = sprintf($q, $q_list, $q_cond); $ret = $kdb->query($q); if ( isset($ret)) { $row = mysql_fetch_array($ret); if (count($row)>1){ $isresource=true; } } } if ($isresource){ $cwTitle = $row['title']; $cwDescription = $row['description']; $cwMainQuestion = $row['mainQuestion']; $cwSolutionNr = $row['mainQuestionCol']; $cwQuestions = split(",", $row['questions']); $cwArray = $this->makeArray($row['data'], 1); $cwData = $cwArray[0]; $cwRowCount = $cwArray[1]; $cwColCount = $cwArray[2]; $assignmentID = 1; //here is assgignment id }else{ $msg = $this->pairsErrorMessage(); } $cssHeader = $this->pairsCSSHeader(); $krihvel->out("head", $cssHeader); $krihvel->out("popup", $msg); } // Pairs Answer Page public function pairsanswer() { global $krihvel, $kdb; $isresource = false; if ( isset($_GET['aid'])){ $aid=$_GET['aid']; }else{ return 'kala'; } if ( isset($_GET['rid'])){ $_SESSION['rid']=$_GET['rid']; } if ( isset($_SESSION['rid'])) { $rid = $_SESSION['rid']; $q_list = "title, description, keywords, mainQuestion, mainQuestionCol, questions, data"; $q_cond = sprintf("resourceID=%s AND type='%s'", $rid, "pairs"); $q = "SELECT %s from resources join pairs using(resourceID) where %s"; $q = sprintf($q, $q_list, $q_cond); $ret = $kdb->query($q); $qa_cond = sprintf("resourceID=%s AND answerID=%s", $rid, $aid); $qa = sprintf("SELECT * from answers join pairs_answers using(answerID) where %s", $qa_cond); $reta = $kdb->query($qa); if ( isset($ret)) { $row = mysql_fetch_array($ret); $rowa = mysql_fetch_array($reta); if (count($row)>1){ $isresource=true; } } } if ($isresource){ $cwTitle = $row['title']; $cwDescription = $row['description']; $cwMainQuestion = $row['mainQuestion']; $cwSolutionNr = $row['mainQuestionCol']; $cwQuestions = split(",", $row['questions']); $cwArray = $this->makeArray($row['data'], 1); $cwaData = $this->makeArray($rowa['data'], 0); $cwData = $cwArray[0]; $cwRowCount = $cwArray[1]; $cwColCount = $cwArray[2]; }else{ $msg = $this->pairsErrorMessage(); } $cssHeader = $this->pairsCSSHeader(); $krihvel->out("head", $cssHeader); $krihvel->out("popup", $msg); } public function pairsedit() { global $krihvel, $kdb; $isresource=false; $cwTitle = ""; $cwDescription = ""; $cwKeywords = ""; $cwMainQuestion = ""; $cwSolutionNr = 0; $cwQuestions = array(); $cwData = array(); $cwRowCount = 2; $cwColCount = 2; if ( isset($_SESSION['rid']) && $_SESSION['rid'] != NULL) { $rid = $_SESSION['rid']; $q_list = "title, description, keywords, mainQuestion, mainQuestionCol, questions, data"; $q_cond = sprintf("resourceID='%s' AND type='%s'", $rid, "pairs"); $q = sprintf("SELECT %s from resources join pairs using(resourceID) where %s", $q_list, $q_cond); $ret = $kdb->query($q); if ( isset($ret)) { $row = mysql_fetch_array($ret); if (count($row)>1){ $cwTitle = $row['title']; $cwDescription = $row['description']; $cwKeywords = $this->keywords_from_database($row['keywords']); $cwMainQuestion = $row['mainQuestion']; $cwSolutionNr = $row['mainQuestionCol']; $cwQuestions = split(",", $row['questions']); $cwArray = $this->makeArray($row['data'], 1); $cwData = $cwArray[0]; $cwRowCount = $cwArray[1]; $cwColCount = $cwArray[2]; } } } $cssHeader = sprintf('%s', $this->pairsCSSHeader()); $krihvel->out("head", $cssHeader); $krihvel->out("popup", $msg); } function keywords_to_database($keywords){ $kws_raw = split(",", $keywords); $kws = ","; foreach ($kws_raw as $kw_raw){ $kw = trim($kw_raw); $kws .= sprintf("%s,", strtolower($kw)); } return $kws; } function keywords_from_database($keywords){ $keywords = trim($keywords, ","); $kws_raw = split(",", $keywords); $kws = ""; foreach ($kws_raw as $kw){ $kws .= sprintf("%s, ", $kw); } $kws = substr_replace($kws, "", -2); return $kws; } public function save_pairs(){ global $kdb, $user; $type="pairs"; $title=$_POST['title']; $desc=$_POST['desc']; $keywords=$this->keywords_to_database($_POST['keywords']); $user_id=$user->getId(); $creator=$user_id; $created=""; $modified="0000-00-00"; $x=$_POST['x']; $y=$_POST['y']; $solution_col=$_POST['solution_col']; $main_question=$_POST['mainquestion']; $data=""; $cwt=""; $questions=""; for ($i=0;$i<$y;$i++){ $cwt=""; for ($j=0;$j<$x;$j++){ $cwt.=$_POST["t".$i."c".$j].','; } $data.=(substr_replace($cwt ,"",-1)).'\n'; $questions.=$_POST['q'.$i].','; } $data=(substr_replace($data ,"",-2)); $questions=(substr_replace($questions ,"",-1)); if (isset($_SESSION['rid']) && $_SESSION['rid']!=0){ $q = "UPDATE resources SET title='%s', description='%s', keywords='%s', modified='%s' WHERE resourceID=".$_SESSION['rid']; $q = sprintf($q, $title, $desc, $keywords, $modified); $kdb->query($q); $q2 = "UPDATE pairs SET mainQuestion='%s', mainQuestionCol=%s, questions='%s', data='%s' WHERE resourceID=".$_SESSION['rid']; $q2 = sprintf($q2, $main_question, $solution_col, $questions, $data); $kdb->query($q2); }else{ $q = "INSERT INTO resources (type, title, description, keywords, userID, modified) values ('%s', '%s', '%s', '%s', %s, '%s')"; $q = sprintf($q, $type, $title, $desc, $keywords, $creator, $modified); $kdb->query($q); $dbuid = mysql_insert_id(); $_SESSION['rid'] = $dbuid; $q2 = "INSERT INTO pairs (resourceID, mainQuestion, mainQuestionCol, questions, data) values (%s, '%s', %s, '%s', '%s')"; $q2 = sprintf($q2, $dbuid, $main_question, $solution_col, $questions, $data); $kdb->query($q2); } return 'pairsview'; } public function answer_pairs(){ global $kdb, $user; $userID=$user->getId(); $y=$_POST['x']; $x=$_POST['y']; $assignmentID=$_POST['assignment']; $resourceID= $_SESSION['rid']; $data=""; $user_answers=""; $questions=""; for ($i=0;$i<$y;$i++){ $user_answers=""; for ($j=0;$j<$x;$j++){ $user_answer=$_POST["t".$i."c".$j]; $user_answers.=$user_answer.','; } $data.=(substr_replace($user_answers ,"",-1)).'\n'; } $data=(substr_replace($data ,"",-2)); $q = sprintf("INSERT INTO answers (resourceID, assignmentID, userID) values (%s, %s, %s)", $resourceID, $assignmentID, $userID); $kdb->query($q); $dbuid = mysql_insert_id(); $q2 = "INSERT INTO pairs_answers (answerID, data) values (%s, '%s')"; $q2 = sprintf($q2, $dbuid, $data); $kdb->query($q2); return 'pairsanswer'; } } ?>