summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJayaram Pai2014-02-28 13:45:15 +0530
committerJayaram Pai2014-02-28 13:45:15 +0530
commit6c70e5ade428d43eda6a44a4442a36b776e47272 (patch)
tree6c97a8b572a9a5ec9f914d5f0e382680c1c7344c
parent9e25a2e31cc22ac02035d44081400f54d0cf964b (diff)
downloadtbc-external-review-6c70e5ade428d43eda6a44a4442a36b776e47272.tar.gz
tbc-external-review-6c70e5ade428d43eda6a44a4442a36b776e47272.tar.bz2
tbc-external-review-6c70e5ade428d43eda6a44a4442a36b776e47272.zip
added manage_comments for administration role.
-rw-r--r--css/tbc_external_review.css12
-rw-r--r--js/jquery.lightbox_me.js234
-rw-r--r--js/tbc_external_review.js29
-rw-r--r--tbc_external_review.module113
4 files changed, 381 insertions, 7 deletions
diff --git a/css/tbc_external_review.css b/css/tbc_external_review.css
index d8c3db8..1341691 100644
--- a/css/tbc_external_review.css
+++ b/css/tbc_external_review.css
@@ -13,3 +13,15 @@
background: lightgreen;
border: 2px solid green;
}
+#lightbox-wrapper {
+ background: #ffffff;
+ padding: 25px;
+}
+#lightbox-wrapper table tr {
+ border-bottom: 1px solid #cccccc;
+ padding: 10px 0;
+}
+
+#lightbox-wrapper table tr:hover {
+ background: #f3f3f3;
+}
diff --git a/js/jquery.lightbox_me.js b/js/jquery.lightbox_me.js
new file mode 100644
index 0000000..548e8eb
--- /dev/null
+++ b/js/jquery.lightbox_me.js
@@ -0,0 +1,234 @@
+/*
+* $ lightbox_me
+* By: Buck Wilson
+* Version : 2.4
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+(function($) {
+
+ $.fn.lightbox_me = function(options) {
+
+ return this.each(function() {
+
+ var
+ opts = $.extend({}, $.fn.lightbox_me.defaults, options),
+ $overlay = $(),
+ $self = $(this),
+ $iframe = $('<iframe id="foo" style="z-index: ' + (opts.zIndex + 1) + ';border: none; margin: 0; padding: 0; position: absolute; width: 100%; height: 100%; top: 0; left: 0; filter: mask();"/>');
+
+ if (opts.showOverlay) {
+ //check if there's an existing overlay, if so, make subequent ones clear
+ var $currentOverlays = $(".js_lb_overlay:visible");
+ if ($currentOverlays.length > 0){
+ $overlay = $('<div class="lb_overlay_clear js_lb_overlay"/>');
+ } else {
+ $overlay = $('<div class="' + opts.classPrefix + '_overlay js_lb_overlay"/>');
+ }
+ }
+
+ /*----------------------------------------------------
+ DOM Building
+ ---------------------------------------------------- */
+ $('body').append($self.hide()).append($overlay);
+
+
+ /*----------------------------------------------------
+ Overlay CSS stuffs
+ ---------------------------------------------------- */
+
+ // set css of the overlay
+ if (opts.showOverlay) {
+ setOverlayHeight(); // pulled this into a function because it is called on window resize.
+ $overlay.css({ position: 'absolute', width: '100%', top: 0, left: 0, right: 0, bottom: 0, zIndex: (opts.zIndex + 2), display: 'none' });
+ if (!$overlay.hasClass('lb_overlay_clear')){
+ $overlay.css(opts.overlayCSS);
+ }
+ }
+
+ /*----------------------------------------------------
+ Animate it in.
+ ---------------------------------------------------- */
+ //
+ if (opts.showOverlay) {
+ $overlay.fadeIn(opts.overlaySpeed, function() {
+ setSelfPosition();
+ $self[opts.appearEffect](opts.lightboxSpeed, function() { setOverlayHeight(); setSelfPosition(); opts.onLoad()});
+ });
+ } else {
+ setSelfPosition();
+ $self[opts.appearEffect](opts.lightboxSpeed, function() { opts.onLoad()});
+ }
+
+ /*----------------------------------------------------
+ Hide parent if parent specified (parentLightbox should be jquery reference to any parent lightbox)
+ ---------------------------------------------------- */
+ if (opts.parentLightbox) {
+ opts.parentLightbox.fadeOut(200);
+ }
+
+
+ /*----------------------------------------------------
+ Bind Events
+ ---------------------------------------------------- */
+
+ $(window).resize(setOverlayHeight)
+ .resize(setSelfPosition)
+ .scroll(setSelfPosition);
+
+ $(window).bind('keyup.lightbox_me', observeKeyPress);
+
+ if (opts.closeClick) {
+ $overlay.click(function(e) { closeLightbox(); e.preventDefault; });
+ }
+ $self.delegate(opts.closeSelector, "click", function(e) {
+ closeLightbox(); e.preventDefault();
+ });
+ $self.bind('close', closeLightbox);
+ $self.bind('reposition', setSelfPosition);
+
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
+
+
+ /*----------------------------------------------------
+ Private Functions
+ ---------------------------------------------------- */
+
+ /* Remove or hide all elements */
+ function closeLightbox() {
+ var s = $self[0].style;
+ if (opts.destroyOnClose) {
+ $self.add($overlay).remove();
+ } else {
+ $self.add($overlay).hide();
+ }
+
+ //show the hidden parent lightbox
+ if (opts.parentLightbox) {
+ opts.parentLightbox.fadeIn(200);
+ }
+ if (opts.preventScroll) {
+ $('body').css('overflow', '');
+ }
+ $iframe.remove();
+
+ // clean up events.
+ $self.undelegate(opts.closeSelector, "click");
+ $self.unbind('close', closeLightbox);
+ $self.unbind('repositon', setSelfPosition);
+
+ $(window).unbind('resize', setOverlayHeight);
+ $(window).unbind('resize', setSelfPosition);
+ $(window).unbind('scroll', setSelfPosition);
+ $(window).unbind('keyup.lightbox_me');
+ opts.onClose();
+ }
+
+
+ /* Function to bind to the window to observe the escape/enter key press */
+ function observeKeyPress(e) {
+ if((e.keyCode == 27 || (e.DOM_VK_ESCAPE == 27 && e.which==0)) && opts.closeEsc) closeLightbox();
+ }
+
+
+ /* Set the height of the overlay
+ : if the document height is taller than the window, then set the overlay height to the document height.
+ : otherwise, just set overlay height: 100%
+ */
+ function setOverlayHeight() {
+ if ($(window).height() < $(document).height()) {
+ $overlay.css({height: $(document).height() + 'px'});
+ $iframe.css({height: $(document).height() + 'px'});
+ } else {
+ $overlay.css({height: '100%'});
+ }
+ }
+
+
+ /* Set the position of the modal'd window ($self)
+ : if $self is taller than the window, then make it absolutely positioned
+ : otherwise fixed
+ */
+ function setSelfPosition() {
+ var s = $self[0].style;
+
+ // reset CSS so width is re-calculated for margin-left CSS
+ $self.css({left: '50%', marginLeft: ($self.outerWidth() / 2) * -1, zIndex: (opts.zIndex + 3) });
+
+
+ /* we have to get a little fancy when dealing with height, because lightbox_me
+ is just so fancy.
+ */
+
+ // if the height of $self is bigger than the window and self isn't already position absolute
+ if (($self.height() + 80 >= $(window).height()) && ($self.css('position') != 'absolute')) {
+
+ // we are going to make it positioned where the user can see it, but they can still scroll
+ // so the top offset is based on the user's scroll position.
+ var topOffset = $(document).scrollTop() + 40;
+ $self.css({position: 'absolute', top: topOffset + 'px', marginTop: 0})
+ } else if ($self.height()+ 80 < $(window).height()) {
+ //if the height is less than the window height, then we're gonna make this thing position: fixed.
+ if (opts.centered) {
+ $self.css({ position: 'fixed', top: '50%', marginTop: ($self.outerHeight() / 2) * -1})
+ } else {
+ $self.css({ position: 'fixed'}).css(opts.modalCSS);
+ }
+ if (opts.preventScroll) {
+ $('body').css('overflow', 'hidden');
+ }
+ }
+ }
+
+ });
+
+
+
+ };
+
+ $.fn.lightbox_me.defaults = {
+
+ // animation
+ appearEffect: "fadeIn",
+ appearEase: "",
+ overlaySpeed: 250,
+ lightboxSpeed: 300,
+
+ // close
+ closeSelector: ".close",
+ closeClick: true,
+ closeEsc: true,
+
+ // behavior
+ destroyOnClose: false,
+ showOverlay: true,
+ parentLightbox: false,
+ preventScroll: false,
+
+ // callbacks
+ onLoad: function() {},
+ onClose: function() {},
+
+ // style
+ classPrefix: 'lb',
+ zIndex: 999,
+ centered: false,
+ modalCSS: {top: '40px'},
+ overlayCSS: {background: 'black', opacity: .3}
+ }
+})(jQuery);
diff --git a/js/tbc_external_review.js b/js/tbc_external_review.js
index bfd1142..99b08b9 100644
--- a/js/tbc_external_review.js
+++ b/js/tbc_external_review.js
@@ -1,4 +1,8 @@
$(document).ready(function() {
+
+ var basePath = Drupal.settings.basePath;
+ var modPath = basePath + "tbc_external_review/";
+ /* for "tbc_external_review/comments" page */
$book = $("#edit-book");
$chapter = $("#edit-chapter");
$chapter_wrapper = $("#edit-chapter-wrapper");
@@ -11,7 +15,7 @@ $(document).ready(function() {
$book.change(function() {
var pid = $(this).val();
$.ajax({
- url: "ajax/book/"+pid,
+ url: modPath + "ajax/book/"+pid,
type: "GET",
success: function(data) {
$chapter.html(data);
@@ -23,7 +27,7 @@ $(document).ready(function() {
$chapter.change(function() {
var cid = $(this).val();
$.ajax({
- url: "ajax/chapter/"+cid,
+ url: modPath + "ajax/chapter/"+cid,
type: "GET",
success: function(data) {
$example.html(data);
@@ -37,6 +41,27 @@ $(document).ready(function() {
$submit.show();
});
+ /* for "tbc_external_review/manage_comments/#some_number" page */
+ $view_comment = $(".view-comment");
+ $lightbox_wrapper = $("#lightbox-wrapper");
+ $lightbox_inner = $("#lightbox-inner");
+ $view_comment.click(function(e) {
+ var comment_id = $(this).attr("data-comment");
+
+ $.ajax({
+ url: modPath + "ajax/comment/" + comment_id,
+ type: "GET",
+ dataType: "html",
+ success: function(data) {
+ $lightbox_inner.html(data);
+ $lightbox_wrapper.lightbox_me({
+ centered: true
+ });
+ },
+ });
+ e.preventDefault();
+ });
+
$(document).ajaxStart(function() {
$ajax_loader.show();
});
diff --git a/tbc_external_review.module b/tbc_external_review.module
index 1d8745a..6847237 100644
--- a/tbc_external_review.module
+++ b/tbc_external_review.module
@@ -38,10 +38,10 @@
"access arguments" => array("download tbc_external_review"),
"type" => MENU_NORMAL_ITEM
);
- $items["tbc_external_review/view_comments"] = array(
- "title" => "External Review Comments",
- "page callback" => "tbc_external_review_view_comments_all",
- "access arguments" => array("download tbc_external_review"),
+ $items["tbc_external_review/manage_comments"] = array(
+ "title" => "ER Manage Comments",
+ "page callback" => "tbc_external_review_manage_comments_all",
+ "access arguments" => array("administer tbc_external_review"),
"type" => MENU_NORMAL_ITEM
);
$items["tbc_external_review/status"] = array(
@@ -504,13 +504,22 @@
(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%s')
";
$result = db_query(
- $query, $user->uid, $v["book"], $v["chapter"], $v["example"], $v["ncf"], $v["eit"], $v["axl"], $v["sua"], $v["sfu"], $v["sum"], $v["aci"], $v["auu"], $v["teo"], $v["amt"], $v["comment"]
+ $query, $user->uid, $v["book"], $v["chapter"], $v["example"],
+ $v["ncf"], $v["eit"], $v["axl"], $v["sua"], $v["sfu"], $v["sum"],
+ $v["aci"], $v["auu"], $v["teo"], $v["amt"], $v["comment"]
);
drupal_set_message(t("Comment submited successfully"), "status");
}
/* Ajax Calls */
function tbc_external_review_ajax($item, $key) {
+ function _bool($var) {
+ if($var == 1) {
+ return "No";
+ }
+ return "Yes";
+ }
+
$data = "";
if($item == "book" && $key) {
$query = "select * from {textbook_companion_chapter} where preference_id = %d order by number";
@@ -528,6 +537,26 @@
while($row = db_fetch_object($result)) {
$data .= "<option value='{$row->id}'>{$row->number} {$row->caption}</option>";
}
+ } else if($item = "comment" && $key) {
+ $query = "
+ SELECT * FROM {external_review_comments} WHERE id = %d
+ ";
+ $result = db_query($query, $key);
+ $row = db_fetch_object($result);
+
+ $data .= "<table><th>Type of Error</th><th>Status</th>";
+ $data .= "<tr><td>Naming convention followed?</td><td>" . _bool($row->ncf) . "</td></tr>";
+ $data .= "<tr><td>Problem statement included in code?</td><td>" . _bool($row->eit) . "</td></tr>";
+ $data .= "<tr><td>Axes labeled ?</td><td>" . _bool($row->axl) . "</td></tr>";
+ $data .= "<tr><td>Symbols used are appropiate?</td><td>" . _bool($row->sua) . "</td></tr>";
+ $data .= "<tr><td>Scilab functions used?</td><td>" . _bool($row->sfu) . "</td></tr>";
+ $data .= "<tr><td>Solved using Matlab in textbook?</td><td>" . _bool($row->sum) . "</td></tr>";
+ $data .= "<tr><td>Appropriate comments included as mentioned in checklist point 7 ?</td><td>" . _bool($row->aci) . "</td></tr>";
+ $data .= "<tr><td>Appropriate units used as given in the textbook?</td><td>" . _bool($row->auu) . "</td></tr>";
+ $data .= "<tr><td>Typographical errors in output and/or comments?</td><td>" . _bool($row->teo) . "</td></tr>";
+ $data .= "<tr><td>Answers matching with the textbook?</td><td>" . _bool($row->amt) . "</td></tr>";
+ $data .= "<tr><td>Any Other Comment ?</td><td>" . $row->comment . "</td></tr>";
+ $data .= "</table>";
}
echo $data;
exit();
@@ -595,8 +624,82 @@
return $page_content;
}
+ function tbc_external_review_manage_comments_all($preference_id=0) {
+ global $base_url;
+ $page_content = "";
+ if($preference_id) {
+ global $user;
+ /* displaying comments of a particular user */
+ $query = "
+ SELECT erc.*, cha.number AS chapter, exa.number AS example FROM external_review_comments erc
+ LEFT JOIN textbook_companion_chapter cha ON cha.id = erc.chapter_id
+ LEFT JOIN textbook_companion_example exa ON exa.id = erc.example_id
+ WHERE erc.preference_id = %d
+ ORDER BY erc.time DESC
+ ";
+ $result = db_query($query, $preference_id);
+ $headers = array(
+ "Chapter", "Example",
+ "Time", "Action"
+ );
+ $rows = array();
+ while($row = db_fetch_object($result)) {
+ $options = array(
+ /* # linking in drupal l() */
+ "fragment" => " ",
+ "external" => TRUE,
+ "attributes" => array(
+ "class" => "view-comment",
+ "data-comment" => "{$row->id}",
+ )
+ );
+ $item = array(
+ "{$row->chapter}",
+ "{$row->example}",
+ "{$row->time}",
+ l("View", "", $options),
+ );
+ array_push($rows, $item);
+ }
+ $page_content .= theme("table", $headers, $rows);
+ $page_content .= "<div id='lightbox-wrapper'>";
+ $page_content .= "<div id='lightbox-inner'></div></div> ";
+ } else {
+ /* displaying the list of users */
+ $query = "
+ SELECT DISTINCT erc.preference_id, pre.book, pre.author, usr_con.name AS contributor, usr_ext.name AS reviewer
+ FROM external_review_comments erc
+ LEFT JOIN textbook_companion_preference pre ON erc.preference_id = pre.id
+ LEFT JOIN textbook_companion_proposal pro ON pre.proposal_id = pro.id
+ LEFT JOIN users usr_con ON usr_con.uid = pro.uid
+ LEFT JOIN users usr_ext ON usr_ext.uid = erc.uid
+ ORDER BY pre.book
+ ";
+ $result = db_query($query);
+ $headers = array(
+ "Book", "Author",
+ "Contributor", "Reviewer",
+ "Action",
+ );
+ $rows = array();
+ while($row = db_fetch_object($result)) {
+ $item = array(
+ "{$row->book}",
+ "{$row->author}",
+ "{$row->contributor}",
+ "{$row->reviewer}",
+ l("View", "tbc_external_review/manage_comments/" . $row->preference_id),
+ );
+ array_push($rows, $item);
+ }
+ $page_content .= theme("table", $headers, $rows);
+ }
+ return $page_content;
+ }
+
function tbc_external_review_init() {
drupal_add_css(drupal_get_path("module", "tbc_external_review") . "/css/tbc_external_review.css");
+ drupal_add_js(drupal_get_path("module", "tbc_external_review") . "/js/jquery.lightbox_me.js");
drupal_add_js(drupal_get_path("module", "tbc_external_review") . "/js/tbc_external_review.js");
}
?>