summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2019-09-04 16:35:28 +0530
committerprashantsinalkar2019-09-04 16:35:28 +0530
commit1dfc2d4045840da1d9780e8a81cfd06adb7b6d57 (patch)
treea213fb13475ce74e1f57c312f55e52026bfbc13c
parentd37c4d019ca594fe5e8b3b8472d55fe1101b19b7 (diff)
downloadr_tbc_fixer-1dfc2d4045840da1d9780e8a81cfd06adb7b6d57.tar.gz
r_tbc_fixer-1dfc2d4045840da1d9780e8a81cfd06adb7b6d57.tar.bz2
r_tbc_fixer-1dfc2d4045840da1d9780e8a81cfd06adb7b6d57.zip
fixed the issues of code, caption update
-rwxr-xr-xjs/r_tbc_fixer.js34
-rwxr-xr-xr_tbc_fixer.module48
2 files changed, 19 insertions, 63 deletions
diff --git a/js/r_tbc_fixer.js b/js/r_tbc_fixer.js
index 92830b6..769d5a5 100755
--- a/js/r_tbc_fixer.js
+++ b/js/r_tbc_fixer.js
@@ -2,15 +2,13 @@
$(document).ready(function() {
var basePath = Drupal.settings.basePath;
var modPath = basePath + "r_tbc_fixer/";
- var modPath1 = basePath + "textbook_companion_fixer/aicte/book/";
- $category = $("#fix-tbc-form #edit-category");
$book = $("#fix-tbc-form #edit-book");
$chapter = $("#fix-tbc-form #edit-chapter");
$example = $("#fix-tbc-form #edit-example");
$caption = $("#fix-tbc-form #edit-caption");
$code = $("#fix-tbc-form #edit-code");
- $caption_form = $("#scilab-fixer-caption-form");
- $code_form = $("#scilab-fixer-code-form");
+ $caption_form = $("#r-fixer-caption-form");
+ $code_form = $("#r-fixer-code-form");
$updating = $("#fix-tbc-page #updating");
$done = $("#fix-tbc-page #done");
$example.attr("multiple", "enabled");
@@ -46,7 +44,7 @@
$book.change(function() {
reset("chapter", "example", "caption");
var book_id = $(this).val();
- if (book_id < 0) {
+ if (book_id < 1) {
$(".select-chapter").hide();
$(".select-example").hide();
$(".enter-caption").hide();
@@ -161,7 +159,7 @@
}
var chapter_caption = $("#edit-chapter-name").val();
chapter_caption = chapter_caption.trim();
- chapter_caption = caption.replace(/\s\s+/g, ' ');
+ chapter_caption = chapter_caption.replace(/\s\s+/g, ' ');
if(validateCaption(chapter_caption) == true) {
alert('Enter valid text for chapter caption');
return false;
@@ -172,7 +170,7 @@
}
$updating.show();
$.ajax({
- url: modPath + "ajax/update-both/",
+ url: modPath + "ajax/update-both/" + example_id,
type: "POST",
data: {
example_id: example_id,
@@ -207,11 +205,11 @@
}
$updating.show();
$.ajax({
- url: modPath + "ajax/update-example/",
+ url: modPath + "ajax/update-example/" + example_id,
type: "POST",
data: {
example_id: example_id,
- caption: caption
+ caption: caption,
},
dataType: "html",
success: function(data) {
@@ -227,8 +225,9 @@
} else if ($('.chapter-caption-chk').prop('checked') == true) {
if (chapter_id != "0") {
var chapter_caption = $("#edit-chapter-name").val();
+ alert(chapter_caption);
chapter_caption = chapter_caption.trim();
- chapter_caption = caption.replace(/\s\s+/g, ' ');
+ chapter_caption = chapter_caption.replace(/\s\s+/g, ' ');
if(validateCaption(chapter_caption) == true) {
alert('Enter valid text for chapter caption');
return false;
@@ -239,7 +238,7 @@
}
$updating.show();
$.ajax({
- url: modPath + "ajax/update-chapter/",
+ url: modPath + "ajax/update-chapter/" + example_id,
type: "POST",
data: {
chapter_id: chapter_id,
@@ -291,18 +290,7 @@
}
e.preventDefault();
});
- $Selected = $(".selected");
- $Selected.click(function(e) {
- $(".sync-msg").remove();
- $(this).after("<span class='sync-msg'>Saving...</span>");
- $.ajax({
- url: modPath1 + "ajax/selected/" + $(this).attr("data-bid"),
- success: function() {
- $(".sync-msg").remove();
- console.log("success");
- }
- });
- });
+
function validateCaption(text){
var re = /([a-zA-Z|*|_|.|+|-|\\|?|/|!|~|!|@|#|$|%|^|&|(|)|<|>|{|}|;|:|\"|\'|,])\1{2,}/;
return re.test(text);
diff --git a/r_tbc_fixer.module b/r_tbc_fixer.module
index dd9c2b6..a444136 100755
--- a/r_tbc_fixer.module
+++ b/r_tbc_fixer.module
@@ -190,32 +190,7 @@ function R_fixer_ajax($item, $key)
{
$data = "";
global $user;
- if ($item == "category" && $key) {
- /* $query = "
- SELECT pre.id AS id, pre.book, pre.author FROM textbook_companion_preference pre
- LEFT JOIN textbook_companion_proposal pro ON pro.id = pre.proposal_id
- WHERE pro.proposal_status = 3 AND pre.approval_status = 1 AND pre.category = %d
- ORDER BY pre.book ASC
- ";
- $result = db_query($query, $key);*/
- $query = db_select('textbook_companion_preference', 'pre');
- $query->fields('pre', array(
- 'id',
- 'book',
- 'author'
- ));
- $query->leftJoin('textbook_companion_proposal', 'pro', 'pro.id = pre.proposal_id');
- $query->condition('pro.proposal_status', 3);
- $query->condition('pre.approval_status', 1);
- $query->condition('pre.category', $key);
- $query->orderBy('pre.book', 'ASC');
- $result = $query->execute();
- $data .= "<option value='0'>Please select the book.</option>";
- while ($row = $result->fetchObject()) {
- $data .= "<option value='{$row->id}'>{$row->book} ({$row->author})</option>";
- } //$row = $result->fetchObject()
- } //$item == "category" && $key
- else if ($item == "book" && $key) {
+ if ($item == "book" && $key) {
/*$query = "SELECT * FROM {textbook_companion_chapter} WHERE preference_id = %d ORDER BY number";
$result = db_query($query, $key);*/
$query = db_select('textbook_companion_chapter');
@@ -369,18 +344,6 @@ function R_fixer_ajax($item, $key)
file_put_contents($example_path, $code);
$data .= "updated";
} //$item == "code" && $key
- else if ($item == "ind-ed" && $key) {
- $query = "
- UPDATE textbook_companion_aicte
- SET ind = !ind
- WHERE id = :id
- ";
- $args = array(
- ":id" => $key
- );
- db_query($query, $args);
- $data .= "updated";
- } //$item == "ind-ed" && $key
else {
$data = "<option value='0'>Please select a book</option>";
}
@@ -448,17 +411,22 @@ function R_fixer_code_all()
}
function r_get_tbc_books(){
- $query = "
+ $query = "
SELECT pre.id AS id, pre.book, pre.author FROM textbook_companion_preference pre
LEFT JOIN textbook_companion_proposal pro ON pro.id = pre.proposal_id
WHERE pro.proposal_status = 3 AND pre.approval_status = 1
ORDER BY pre.book ASC
";
$book_list = db_query($query);
+ $i = 1;
$book[0] = "Select any book";
while ($book_list_data = $book_list->fetchObject())
{
- $book[$book_list_data->id] = $book[$book_list_data->id]. $book_list_data->book ." (by " .$book_list_data->author. ")";
+ if (!isset($book[$book_list_data->id])) {
+ $book[$book_list_data->id] = '';
+ }
+ $book[$book_list_data->id] = $book[$book_list_data->id] . $i . ") ". $book_list_data->book . " (by " . $book_list_data->author . ")";
+ $i++;
}
return $book;
}