Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bundler.py34
-rw-r--r--Bundler.pycbin0 -> 1672 bytes
-rw-r--r--COPYING339
-rwxr-xr-xMANIFEST28
-rwxr-xr-xModels.py723
-rw-r--r--Models.pycbin0 -> 29897 bytes
-rwxr-xr-xTemplate.py99
-rw-r--r--Template.pycbin0 -> 4255 bytes
-rw-r--r--YardStickActivity.py1400
-rw-r--r--YardStickActivity.pycbin0 -> 35863 bytes
-rw-r--r--activity/activity-yardstick.svg44
-rw-r--r--activity/activity.info8
-rw-r--r--dist/YardStick-1.xobin0 -> 418283 bytes
-rw-r--r--images/YardStick.pngbin0 -> 8720 bytes
-rw-r--r--images/addnew.pngbin0 -> 5892 bytes
-rw-r--r--images/author.pngbin0 -> 4798 bytes
-rw-r--r--images/categories.pngbin0 -> 7211 bytes
-rw-r--r--images/child.pngbin0 -> 6891 bytes
-rw-r--r--images/delete.pngbin0 -> 3967 bytes
-rw-r--r--images/description.pngbin0 -> 6937 bytes
-rw-r--r--images/edit.pngbin0 -> 2908 bytes
-rw-r--r--images/editpoints.pngbin0 -> 3857 bytes
-rw-r--r--images/finalize.pngbin0 -> 4343 bytes
-rw-r--r--images/homepage.pngbin0 -> 254499 bytes
-rw-r--r--images/levels.pngbin0 -> 3920 bytes
-rw-r--r--images/pic1.pngbin0 -> 20169 bytes
-rw-r--r--images/picture.pngbin0 -> 30315 bytes
-rw-r--r--images/save.pngbin0 -> 3555 bytes
-rw-r--r--images/sendtoscorepad.pngbin0 -> 5063 bytes
-rw-r--r--images/share.pngbin0 -> 5033 bytes
-rw-r--r--images/submit.pngbin0 -> 4796 bytes
-rw-r--r--images/title.pngbin0 -> 2877 bytes
-rw-r--r--images/update.pngbin0 -> 4750 bytes
-rwxr-xr-xsetup.py3
34 files changed, 2678 insertions, 0 deletions
diff --git a/Bundler.py b/Bundler.py
new file mode 100644
index 0000000..f8b5286
--- /dev/null
+++ b/Bundler.py
@@ -0,0 +1,34 @@
+from Models import *
+
+class Bundler():
+
+ def bundle_rubric(self,rubric):
+
+ rubric_bundle = "Rubric|" + str(rubric.rubric_id)+"|"+rubric.title+"|"+\
+ rubric.author+"|"+rubric.description+"|"+\
+ str(rubric.is_predefined) +"|"+rubric.xo_name +"|"+\
+ rubric.rubric_sha+"|"+str(rubric.enable_points)
+
+ return rubric_bundle
+
+ def bundle_category(self, categories):
+
+ categorylist = []
+ for category in categories:
+ bundle = "Category|" + str(category.category_id)+"|"+category.name+"|"+\
+ str(category.rubric_id) +"|"+\
+ category.category_sha+"|"+str(category.percentage)
+ categorylist.append(bundle)
+
+ return categorylist
+
+ def bundle_level(self, levels):
+
+ levelist = []
+ for level in levels:
+ bundle = "Level|" + str(level.level_id) +"|"+ level.name+"|"+level.description+"|"+\
+ str(level.category_id)+"|"+str(level.rubric_id)+"|"+\
+ level.level_sha+"|"+str(level.points)
+ levelist.append(bundle)
+
+ return levelist \ No newline at end of file
diff --git a/Bundler.pyc b/Bundler.pyc
new file mode 100644
index 0000000..d02d88d
--- /dev/null
+++ b/Bundler.pyc
Binary files differ
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..d511905
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/MANIFEST b/MANIFEST
new file mode 100755
index 0000000..0a75f15
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,28 @@
+YardStickActivity.py
+Bundler.py
+activity/activity.info
+activity/activity-yardstick.svg
+setup.py
+images/picture.png
+images/homepage.png
+images/description.png
+images/title.png
+images/levels.png
+images/author.png
+images/categories.png
+images/pic1.png
+images/YardStick.png
+images/child.png
+images/edit.png
+images/share.png
+images/delete.png
+images/sendtoscorepad.png
+images/addnew.png
+images/editpoints.png
+images/finalize.png
+images/save.png
+images/submit.png
+images/update.png
+Template.py
+Models.py
+COPYING
diff --git a/Models.py b/Models.py
new file mode 100755
index 0000000..44f1021
--- /dev/null
+++ b/Models.py
@@ -0,0 +1,723 @@
+import sqlite3
+import hashlib
+import os
+import logging
+
+class ScorePadDB():
+
+ def __init__(self, nickname = ""):
+
+ self.scorepaddb = "../ScorePad.activity/"+str(nickname)+"db.sqlite"
+ self.connection = sqlite3.connect(self.scorepaddb)
+ self.cursor = self.connection.cursor()
+
+ def insert_rubric(self, rubric):
+ temp = (rubric.title, rubric.author, rubric.description, rubric.is_predefined,
+ rubric.xo_name, rubric.rubric_sha, rubric.enable_points)
+ insert_str = "INSERT INTO rubric_table(title, author, description,is_predefined,\
+ xo_name, rubric_sha,enable_points)\
+ VALUES(?,?,?,?,?,?,?)"
+ self.cursor.execute(insert_str,temp)
+ self.connection.commit()
+
+ def insert_category(self, category):
+ temp = (category.name, category.rubric_id, category.category_sha, category.percentage)
+ insert_str = "INSERT INTO category_table(name,rubric_id,category_sha,percentage) VALUES (?,?,?,?)"
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+ def insert_level(self, level):
+ temp = (level.name,level.description,level.category_id,level.rubric_id,level.level_sha,level.points)
+ insert_str = "INSERT INTO level_table(name, description, category_id, rubric_id,level_sha,points) \
+ VALUES(?,?,?,?,?,?)"
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+ def insert_criteria2(self, category, levels, rubric_id):
+ temp = (category.name, rubric_id, category.category_sha,category.percentage)
+ insert_str = "INSERT INTO category_table(name,rubric_id,category_sha,percentage) VALUES (?,?,?,?)"
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+ query_str = "SELECT MAX(category_id) from category_table"
+ self.cursor.execute(query_str)
+ category_id = self.cursor.fetchone()[0]
+
+ insert_str = "INSERT INTO level_table(name,description,category_id,rubric_id,level_sha,points)\
+ VALUES(?,?,?,?,?,?)"
+ for level in levels:
+ temp = (level.name, level.description,category_id,\
+ rubric_id, level.level_sha,level.points)
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+ def query_maxrubric(self):
+ query_str = "SELECT MAX(rubric_id) from rubric_table"
+ self.cursor.execute(query_str)
+ rubric_id = self.cursor.fetchone()[0]
+ return rubric_id
+
+ def query_level(self,category_id):
+
+ query_str = "SELECT * from level_table where category_id ="+str(category_id)
+ self.cursor.execute(query_str)
+
+ level_list = []
+ for row in self.cursor:
+ level = Level(row[0], row[1], row[2], row[3], row[4], row[5],row[6])
+ level_list.append(level)
+ return level_list
+
+ def rubric_exists(self, title, author):
+ temp = (title, author)
+ query_str = "SELECT * FROM rubric_table WHERE title = ? and author = ?"
+
+ self.cursor.execute(query_str, temp)
+ for row in self.cursor:
+ rubric = Rubric(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7])
+
+ try:
+ if rubric.rubric_id == None:
+ return None
+ else:
+ return rubric.rubric_id
+ except:
+ return None
+
+ def close_db(self):
+ self.cursor.close()
+
+class YardStickDB():
+
+ def connect_db(self, nickname = ""):
+ is_newlycreated = False
+ self.yardstickdb = str(nickname)+"db.sqlite"
+ if not os.path.isfile(self.yardstickdb):
+ logging.debug("the database already exist")
+
+ self.connection = sqlite3.connect(self.yardstickdb)
+ logging.debug("ScorepadDB-->connect")
+ self.cursor = self.connection.cursor()
+ try:
+ self.create_tables()
+ is_newlycreated = True
+ logging.debug("ScorepadDB -->create_tables")
+ except:
+ logging.debug("Exception here")
+
+ return is_newlycreated
+
+ def create_tables(self):
+ rubric_table = "CREATE TABLE rubric_table (rubric_id INTEGER PRIMARY KEY,\
+ title VARCHAR(40) NOT NULL,\
+ author VARCHAR(40) NOT NULL,\
+ description TEXT,\
+ is_predefined INTEGER,\
+ xo_name VARCHAR(50),\
+ rubric_sha TEXT,\
+ enable_points INTERGER)"
+ category_table = "CREATE TABLE category_table (category_id INTEGER PRIMARY KEY,\
+ name VARCHAR(40) NOT NULL,\
+ rubric_id INTEGER NOT NULL REFERENCES rubric_table(rubric_id),\
+ category_sha TEXT,\
+ percentage FLOAT)"
+
+ level_table = "CREATE TABLE level_table (level_id INTEGER PRIMARY KEY,\
+ name VARCHAR(40) NOT NULL,\
+ description TEXT NOT NULL,\
+ category_id INTEGER NOT NULL REFERENCES category_table(category_id),\
+ rubric_id INTEGER NOT NULL REFERENCES rubric_table(rubric_id),\
+ level_sha TEXT,\
+ points INTEGER)"
+
+ project_table = "CREATE TABLE project_table (project_id INTEGER PRIMARY KEY,\
+ title VARCHAR(40) NOT NULL,\
+ author VARCHAR(40) NOT NULL,\
+ description TEXT,\
+ subject VARCHAR(40),\
+ publish_date TEXT,\
+ is_owned INTEGER,\
+ is_shared INTEGER,\
+ rubric_id INTEGER NOT NULL REFERENCES rubric_table(rubric_id),\
+ xo_name VARCHAR(50),\
+ project_sha TEXT,\
+ total_score FLOAT)"
+
+ score_table = "CREATE TABLE score_table (score_id INTEGER PRIMARY KEY,\
+ project_id INTEGER NOT NULL REFERENCES project_table(project_id),\
+ rubric_id INTEGER NOT NULL REFERENCES rubric_table(rubric_id),\
+ category_id INTEGER NOT NULL REFERENCES category_table(category_id),\
+ level_id INTEGER NOT NULL REFERENCES level_table(level_id),\
+ project_sha TEXT REFERENCES project_table(project_sha),\
+ rubric_sha TEXT REFERENCES rubric_table(rubric_sha),\
+ category_sha TEXT REFERENCES category_table(category_sha),\
+ level_sha TEXT REFERENCES level_table(level_sha),\
+ count INTEGER NOT NULL)"
+
+ self.cursor.execute(rubric_table)
+ print "rubric table created"
+ self.cursor.execute(category_table)
+ print "category table created"
+ self.cursor.execute(level_table)
+ print "level table created"
+ self.cursor.execute(project_table)
+ print "project table created"
+ self.cursor.execute(score_table)
+ print "score table created"
+
+ def insert_rubric(self, rubric):
+ temp = (rubric.title, rubric.author, rubric.description, rubric.is_predefined,
+ rubric.xo_name, rubric.rubric_sha, rubric.enable_points)
+ insert_str = "INSERT INTO rubric_table(title, author, description,is_predefined,\
+ xo_name,rubric_sha,enable_points)\
+ VALUES(?,?,?,?,?,?,?)"
+ self.cursor.execute(insert_str,temp)
+ self.connection.commit()
+
+ def query_maxrubric(self):
+ query_str = "SELECT MAX(rubric_id) from rubric_table"
+ self.cursor.execute(query_str)
+ rubric_id = self.cursor.fetchone()[0]
+ return rubric_id
+
+ def insert_criteria(self, category, levels):
+ temp = (category.name, category.rubric_id,category.category_sha,category.percentage)
+ insert_str = "INSERT INTO category_table(name,rubric_id,category_sha,percentage) VALUES (?,?,?,?)"
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+ query_str = "SELECT MAX(category_id) from category_table"
+ self.cursor.execute(query_str)
+ category_id = self.cursor.fetchone()[0]
+
+ insert_str = "INSERT INTO level_table(name,description,category_id,rubric_id,level_sha,points)\
+ VALUES(?,?,?,?,?,?)"
+ for i in range(len(levels)):
+ temp = (levels[i].name, levels[i].description,category_id ,\
+ levels[i].rubric_id, levels[i].level_sha, levels[i].points)
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+ def insert_project(self, project):
+ temp = (project.title, project.author, project.description, project.subject,\
+ project.publish_date, project.is_owned,\
+ project.is_shared, project.rubric_id,project.xo_name,\
+ project.project_sha,project.total_score)
+
+ insert_str = "INSERT INTO project_table(title, author, description, subject,\
+ publish_date, is_owned, is_shared, rubric_id,xo_name,\
+ project_sha,total_score) VALUES (?,?,?,?,?,?,?,?,?,?,?)"
+
+ self.cursor.execute(insert_str,temp)
+ self.connection.commit()
+
+ def query_maxproject(self):
+ query_str = "SELECT MAX(project_id) from project_table"
+ self.cursor.execute(query_str)
+ project_id = self.cursor.fetchone()[0]
+ return project_id
+
+ def insert_score(self, score):
+ temp = (score.project_id, score.rubric_id, score.category_id, score.level_id,
+ score.project_sha, score.rubric_sha, score.category_sha, score.level_sha, score.count)
+ insert_str = "INSERT INTO score_table(project_id,rubric_id,category_id,level_id,\
+ project_sha, rubric_sha, category_sha, level_sha, count)\
+ VALUES (?,?,?,?,?,?,?,?,?)"
+ self.cursor.execute(insert_str,temp)
+ self.connection.commit()
+
+ def insert_category(self, category):
+ temp = (category.name,category.rubric_id,category.category_sha,category.percentage)
+ insert_str = "INSERT INTO category_table(name,rubric_id,category_sha,percentage) VALUES (?,?,?,?)"
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+ def insert_level(self, level):
+ temp = (level.name, level.description, level.category_id, level.rubric_id, level.level_sha, level.points)
+ insert_str = "INSERT INTO level_table(name, description, category_id, rubric_id, level_sha, points) \
+ VALUES(?,?,?,?,?,?)"
+ self.cursor.execute(insert_str, temp)
+ self.connection.commit()
+
+
+ def query_maxscore(self):
+ query_str = "SELECT MAX(score_id) from score_table"
+ self.cursor.execute(query_str)
+ score_id = self.cursor.fetchone()[0]
+ return score_id
+
+ def query_maxcategory(self):
+ query_str = "SELECT MAX(category_id) from category_table"
+ self.cursor.execute(query_str)
+ category_id = self.cursor.fetchone()[0]
+ return category_id
+
+ def queryall_rubric(self, is_predefined):
+ query_str = "SELECT * from rubric_table where is_predefined = "+str(is_predefined)
+ self.cursor.execute(query_str)
+
+ rubric_list = []
+ for row in self.cursor:
+ rubric = Rubric(row[0], row[1], row[2], row[3], row[4], row[5], row[6],row[7])
+ rubric_list.append(rubric)
+ return rubric_list
+
+ def queryall_project(self, is_owned):
+ query_str = "SELECT * from project_table where is_owned = "+str(is_owned)
+ self.cursor.execute(query_str)
+
+ project_list = []
+ for row in self.cursor:
+ project = Project(row[0],row[1],row[2],row[3],row[4],
+ row[5],row[6],row[7],row[8], row[9],row[10],row[11])
+ project_list.append(project)
+ return project_list
+
+ def query_rubric(self, rubric_id):
+ query_str = "SELECT * from rubric_table where rubric_id = "+str(rubric_id)
+ self.cursor.execute(query_str)
+
+ for row in self.cursor:
+ rubric = Rubric(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7])
+
+ return rubric
+
+ def queryall_category(self, rubric_id):
+ query_str = "SELECT * from category_table where rubric_id = "+str(rubric_id)
+ self.cursor.execute(query_str)
+
+ category_list = []
+ for row in self.cursor:
+ category = Category(row[0], row[1], row[2], row[3],row[4])
+ category_list.append(category)
+ return category_list
+
+ def query_level(self,category_id):
+
+ query_str = "SELECT * from level_table where category_id ="+str(category_id)
+ self.cursor.execute(query_str)
+
+ level_list = []
+ for row in self.cursor:
+ level = Level(row[0], row[1], row[2], row[3], row[4], row[5],row[6])
+ level_list.append(level)
+ return level_list
+
+ def querylevel_id(self, category_id, level_name):
+ temp = (category_id, level_name)
+ query_str = "SELECT level_id from level_table WHERE category_id = ? and name = ?"
+ self.cursor.execute(query_str,temp)
+ level_id = self.cursor.fetchone()[0]
+ return level_id
+
+ def query_score(self, project_id, rubric_id, category_id, level_id):
+ temp = (project_id, rubric_id, category_id, level_id)
+ query_str = "SELECT count from score_table WHERE project_id = ? \
+ and rubric_id = ? and category_id = ? and \
+ level_id = ?"
+ self.cursor.execute(query_str, temp)
+ count = self.cursor.fetchone()[0]
+ return count
+
+ def query_score2(self, project_id, rubric_id, category_id, level_id):
+ temp = (project_id, rubric_id, category_id, level_id)
+ query_str = "SELECT * from score_table WHERE project_id = ? \
+ and rubric_id = ? and category_id = ? and \
+ level_id = ?"
+
+ self.cursor.execute(query_str, temp)
+ for row in self.cursor:
+ score = Score(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9])
+ return score
+
+ def query_project_sha(self, project_id):
+ query_str = "SELECT project_sha from project_table WHERE project_id = "+ str(project_id)
+ self.cursor.execute(query_str)
+
+ project_sha = self.cursor.fetchone()[0]
+ return str(project_sha)
+
+ def query_project(self, project_id):
+ query_str = "SELECT * from project_table WHERE project_id ="+ str(project_id)
+ self.cursor.execute(query_str)
+
+ for row in self.cursor:
+ project = Project(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11])
+
+ return project
+
+ def query_rubric_sha(self, rubric_id):
+ query_str = "SELECT rubric_sha from rubric_table WHERE rubric_id = "+ str(rubric_id)
+ self.cursor.execute(query_str)
+
+ rubric_sha = self.cursor.fetchone()[0]
+ return str(rubric_sha)
+
+ def query_category_sha(self, category_id):
+ query_str = "SELECT category_sha from category_table WHERE category_id = "+ str(category_id)
+ self.cursor.execute(query_str)
+
+ category_sha = self.cursor.fetchone()[0]
+ return str(category_sha)
+
+ def query_level_sha(self, level_id):
+ query_str = "SELECT level_sha from level_table WHERE level_id = "+ str(level_id)
+ self.cursor.execute(query_str)
+
+ level_sha = self.cursor.fetchone()[0]
+ return str(level_sha)
+
+ def query_score_id(self, project_sha, rubric_sha, category_sha, level_sha):
+ temp = (project_sha, rubric_sha, category_sha, level_sha)
+ query_str = "SELECT score_id from score_table WHERE project_sha = ? \
+ and rubric_sha = ? and category_sha = ? and level_sha = ?"
+ self.cursor.execute(query_str, temp)
+ score_id = self.cursor.fetchone()[0]
+ return score_id
+
+ def is_points_enabled(self, rubric_id):
+ query_str = "SELECT enable_points from rubric_table WHERE rubric_id = " + str(rubric_id)
+ self.cursor.execute(query_str)
+ enable_points = self.cursor.fetchone()[0]
+ if enable_points == 0:
+ return False
+ else :
+ return True
+
+ def queryall_level(self, rubric_id):
+ query_str = "SELECT * from level_table where rubric_id = "+str(rubric_id)
+ self.cursor.execute(query_str)
+
+ level_list = []
+ for row in self.cursor:
+ level = Level(row[0],row[1],row[2],row[3],row[4],row[5],row[6])
+ level_list.append(level)
+ return level_list
+
+ def query_category_id(self, rubric_id, name):
+ temp = (rubric_id, name)
+ query_str = "SELECT * from category_table where rubric_id = ? and name = ?"
+ self.cursor.execute(query_str, temp)
+ category_id = self.cursor.fetchone()[0]
+
+ return category_id
+
+ def query_level_id(self, rubric_id, category_id, name):
+ temp = (rubric_id, category_id, name)
+ query_str = "SELECT * from level_table where rubric_id = ? and category_id = ? and name = ?"
+ self.cursor.execute(query_str, temp)
+ level_id = self.cursor.fetchone()[0]
+
+ return level_id
+
+ def update_project(self, modified_project):
+ temp = (modified_project.title,modified_project.author,modified_project.description,\
+ modified_project.subject,\
+ modified_project.publish_date,\
+ modified_project.rubric_id,modified_project.project_sha,\
+ modified_project.total_score,\
+ modified_project.project_id)
+ update_str = "UPDATE project_table SET title = ?,"+\
+ "author = ?, "+\
+ "description = ?,"+\
+ "subject = ?,"+\
+ "publish_date = ?,"+\
+ "rubric_id = ?,"+\
+ "project_sha = ?"+\
+ "total_score = ?"+\
+ "WHERE project_id = ?"
+ self.cursor.execute(update_str,temp)
+ self.connection.commit()
+
+ def update_levels(self, modified_levels):
+
+ for i in modified_levels:
+ temp = (i.name,i.description,i.level_id,)
+ update_str = "UPDATE level_table SET name = ?,"+\
+ "description = ?"+\
+ "WHERE level_id = ?"
+ self.cursor.execute(update_str,temp)
+ self.connection.commit()
+
+ def update_level(self, modified_level):
+ temp = (modified_level.name,modified_level.description,modified_level.level_id,)
+ update_str = "UPDATE level_table SET name = ?,"+\
+ "description = ?"+\
+ "WHERE level_id = ?"
+ self.cursor.execute(update_str,temp)
+ self.connection.commit()
+
+ def update_categories(self, modified_categories):
+ for i in modified_categories:
+ temp = (i.name,i.rubric_id,i.category_id)
+ update_str = "UPDATE category_table SET name = ?"+\
+ "WHERE rubric_id = ? and category_id = ?"
+ self.cursor.execute(update_str,temp)
+ self.connection.commit()
+
+ def update_category(self, modified_category):
+ temp = (modified_category.name,modified_category.rubric_id,modified_category.category_id)
+ update_str = "UPDATE category_table SET name = ?"+\
+ "WHERE rubric_id = ? and category_id = ?"
+ self.cursor.execute(update_str,temp)
+ self.connection.commit()
+
+ def update_rubric(self, modified_rubric):
+ temp = (modified_rubric.title,modified_rubric.author,modified_rubric.description,modified_rubric.enable_points,
+ modified_rubric.rubric_id)
+ update_str = "UPDATE rubric_table SET title = ?,"+\
+ "author = ?, "+\
+ "description = ?,"+\
+ "enable_points = ?"+\
+ "WHERE rubric_id = ?"
+ self.cursor.execute(update_str,temp)
+ self.connection.commit()
+
+ def update_percentage(self, category_id, percentage):
+ temp = (percentage, category_id)
+ update_str = "UPDATE category_table SET percentage = ?"+\
+ "WHERE category_id = ?"
+ self.cursor.execute(update_str, temp)
+ self.connection.commit()
+
+ def update_points(self, category_id, level_name, points):
+ temp = (points, category_id, level_name)
+ update_str = "UPDATE level_table SET points = ?"+\
+ "WHERE category_id = ? and name = ?"
+ self.cursor.execute(update_str, temp)
+ self.connection.commit()
+
+ def update_enablepoints(self, rubric_id, is_enable):
+ temp = (is_enable, rubric_id)
+ update_str = "UPDATE rubric_table SET enable_points = ?"+\
+ "WHERE rubric_id = ?"
+ self.cursor.execute(update_str, temp)
+ self.connection.commit()
+
+
+
+ def delete_project(self, project_id):
+ delete_str = "DELETE FROM project_table WHERE project_id ="+ str(project_id)
+ self.cursor.execute(delete_str)
+
+ self.connection.commit()
+
+ def delete_rubric(self, rubric_id):
+ delete_str = "DELETE FROM rubric_table WHERE rubric_id ="+ str(rubric_id)
+ self.cursor.execute(delete_str)
+
+ delete_str = "DELETE FROM category_table WHERE rubric_id ="+ str(rubric_id)
+ self.cursor.execute(delete_str)
+
+ delete_str = "DELETE FROM level_table WHERE rubric_id ="+ str(rubric_id)
+ self.cursor.execute(delete_str)
+
+ self.connection.commit()
+
+ def score_exists(self, project_id, rubric_id, category_id, level_id):
+ temp = (project_id, rubric_id, category_id, level_id)
+ query_str = "SELECT * FROM score_table WHERE project_id = ? and rubric_id = ? and \
+ category_id = ? and level_id = ?"
+
+ self.cursor.execute(query_str, temp)
+ for row in self.cursor:
+ score = Score(row[0],row[1],row[2],row[3],row[4],row[5],row[6],\
+ row[7],row[8],row[9])
+
+ try:
+ if score.score_id == None:
+ return False
+ else:
+ return True
+ except:
+ return False
+
+ def project_exists(self, project_sha, author):
+ temp = (project_sha, author)
+ query_str = "SELECT * FROM project_table WHERE project_sha = ? and author = ?"
+
+ self.cursor.execute(query_str, temp)
+ for row in self.cursor:
+ project = Project(row[0],row[1],row[2],row[3],row[4],row[5],row[6],\
+ row[7],row[8],row[9],row[10],row[11])
+
+ try:
+ if project.project_id == None:
+ return False
+ else:
+ return True
+ except:
+ return False
+
+ def rubric_exists(self, rubric_sha, description):
+ temp = (rubric_sha, description)
+ query_str = "SELECT * FROM rubric_table WHERE rubric_sha = ? and description = ?"
+
+ self.cursor.execute(query_str, temp)
+ for row in self.cursor:
+ rubric = Rubric(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7])
+
+ try:
+ if rubric.rubric_id == None:
+ return None
+ else:
+ return rubric.rubric_id
+ except:
+ return None
+
+ def rubric_title_exists(self, rubric_title):
+ query_str = "SELECT * FROM rubric_table WHERE title = \'" + str(rubric_title) +"\'"
+ self.cursor.execute(query_str)
+ count = 0
+ for row in self.cursor:
+ rubric = Rubric(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7])
+ count = count+1
+
+ try:
+ if rubric.rubric_id == None:
+ return None
+ else:
+ return count
+ except:
+ return None
+
+ def query_score_attr(self, score_id):
+ query_str = "SELECT * from score_table WHERE score_id = " + str(score_id)
+ self.cursor.execute(query_str)
+
+ for row in self.cursor:
+ score = Score(row[0],row[1],row[2],row[3],row[4],row[5],row[6],\
+ row[7],row[8],row[9])
+
+ attr = [score.project_id, score.rubric_id, score.category_id, score.level_id]
+ return attr
+
+
+ def increment_scorecount(self, project_id, rubric_id, category_id, level_id):
+ temp = (project_id, rubric_id, category_id, level_id)
+ query_str = "SELECT * FROM score_table WHERE project_id = ? and rubric_id = ? and \
+ category_id = ? and level_id = ?"
+ self.cursor.execute(query_str, temp)
+
+ for row in self.cursor:
+ score = Score(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9])
+
+ score_id = score.score_id
+ count = score.count
+ count = count +1
+ temp = (count, score_id)
+ update_str = "UPDATE score_table SET count = ?"+\
+ "WHERE score_id = ?"
+ self.cursor.execute(update_str, temp)
+ self.connection.commit()
+ return score_id
+
+ def close_db(self):
+ self.cursor.close()
+
+class Project():
+
+ def __init__(self, project_id = 0, title = "", author = "",
+ description = "", subject = "", publish_date = "",
+ is_owned = 1, is_shared = 1, rubric_id = None, xo_name = "",
+ project_sha = "", total_score = 0):
+ self.project_id = project_id
+ self.title = title
+ self.author = author
+ self.description = description
+ self.subject = subject
+ self.publish_date = publish_date
+ self.is_owned = is_owned
+ self.is_shared = is_shared
+ self.rubric_id = rubric_id
+ self.xo_name = xo_name
+ self.project_sha = self.get_sha(xo_name, title, publish_date)
+ self.total_score = total_score
+
+
+ def get_sha(self, xo_name, title, publish_date):
+ text = xo_name + title + str(publish_date)
+ h = hashlib.sha1()
+ h.update(text)
+ project_sha = str(h.hexdigest())
+
+ return project_sha
+
+
+
+class Rubric():
+
+ def __init__(self, rubric_id = 0, title = "", author = "", description = "",\
+ is_predefined =None, xo_name = "", rubric_sha = "", enable_points = 0):
+ self.rubric_id = rubric_id
+ self.title = title
+ self.author = author
+ self.description = description
+ self.is_predefined = is_predefined
+ self.xo_name = xo_name
+ self.rubric_sha = self.get_sha(xo_name, title, author)
+ self.enable_points = enable_points
+
+ def get_sha(self, xo_name, title, author):
+ text = xo_name + title + author
+ h = hashlib.sha1()
+ h.update(text)
+ rubric_sha = str(h.hexdigest())
+
+ return rubric_sha
+
+
+class Category():
+
+ def __init__(self, category_id = None, name = "", rubric_id = None,
+ category_sha = "", percentage = 0.0):
+ self.category_id = category_id
+ self.name = name
+ self.rubric_id = rubric_id
+ self.category_sha = self.get_sha(name)
+ self.percentage = percentage
+
+ def get_sha(self, name):
+ text = name
+ h = hashlib.sha1()
+ h.update(text)
+ category_sha = str(h.hexdigest())
+
+ return category_sha
+
+
+class Level():
+
+ def __init__(self, level_id = None, name = "", description = "",
+ category_id = None, rubric_id = None,
+ level_sha = "", points = 0):
+ self.level_id = level_id
+ self.name = name
+ self.description = description
+ self.category_id = category_id
+ self.rubric_id = rubric_id
+ self.level_sha = self.get_sha(name,description)
+ self.points = points
+
+ def get_sha(self, name, description):
+ text = name + description
+ h = hashlib.sha1()
+ h.update(text)
+ level_sha = str(h.hexdigest())
+
+ return level_sha
+
+class Score():
+
+ def __init__(self, score_id = 0, project_id = None, rubric_id = None, category_id = None,level_id = None,
+ project_sha = "", rubric_sha = "", category_sha = "", level_sha = "",count = 0):
+ self.score_id = score_id
+ self.project_id = project_id
+ self.rubric_id = rubric_id
+ self.category_id = category_id
+ self.level_id = level_id
+ self.project_sha = project_sha
+ self.rubric_sha = rubric_sha
+ self.category_sha = category_sha
+ self.level_sha = level_sha
+ self.count = count
diff --git a/Models.pyc b/Models.pyc
new file mode 100644
index 0000000..2f4814c
--- /dev/null
+++ b/Models.pyc
Binary files differ
diff --git a/Template.py b/Template.py
new file mode 100755
index 0000000..1712ff8
--- /dev/null
+++ b/Template.py
@@ -0,0 +1,99 @@
+from Models import Rubric
+from Models import Project
+from Models import Category
+from Models import Level
+import datetime
+
+class Template():
+
+ def __init__(self, nickname = "", yardstickdDB =None):
+ self.yardstickdDB = yardstickdDB
+ self.owner_nick = nickname
+
+ def save_template(self):
+
+ today = datetime.datetime.now()
+
+ rubric = Rubric(None, "Music", "Sample", "Music Rubric",1,"sample","",1)
+ self.yardstickdDB.insert_rubric(rubric)
+ rubric_id = self.yardstickdDB.query_maxrubric()
+
+ category = Category(None, "Song", rubric_id,"",25)
+ level0 = Level(None, "Exemplary","Song relates to genre", None, rubric_id,"",4)
+ level1 = Level(None, "Proficient","Song loosely relates to genre", None, rubric_id,"",3)
+ level2 = Level(None, "Developing","Song doesn't relate to genre", None, rubric_id,"",2)
+ level3 = Level(None, "Unsatisfactory","No song chosen", None, rubric_id,"",1)
+
+ levels = [level0, level1, level2, level3]
+ self.yardstickdDB.insert_criteria(category, levels)
+
+ category = Category(None, "Presentation", rubric_id,"",25)
+ level0 = Level(None, "Exemplary","Song is explained.Tied well to genre.", None, rubric_id,"",4)
+ level1 = Level(None, "Proficient","Song explained but not tied well to \
+ genre/assignment.", None, rubric_id,"",3)
+ level2 = Level(None, "Developing","Vague explanation given.", None, rubric_id,"",2)
+ level3 = Level(None, "Unsatisfactory","No historical context given.", None, rubric_id,"",1)
+ levels = []
+ levels = [level0, level1, level2, level3]
+ self.yardstickdDB.insert_criteria(category, levels)
+
+ category = Category(None, "Performance", rubric_id,"",25)
+ level0 = Level(None, "Exemplary","Taken seriously. Performed well", None, rubric_id,"",4)
+ level1 = Level(None, "Proficient","Performed well with some mistakes", None, rubric_id,"",3)
+ level2 = Level(None, "Developing","Not taken very seriously", None, rubric_id,"",2)
+ level3 = Level(None, "Unsatisfactory","Weak performance", None, rubric_id,"",1)
+ levels = []
+ levels = [level0, level1, level2, level3]
+ self.yardstickdDB.insert_criteria(category, levels)
+
+ category = Category(None, "Effort", rubric_id,"",25)
+ level0 = Level(None, "Exemplary","Went above and beyond for effort", None, rubric_id,"",4)
+ level1 = Level(None, "Proficient","Put significant effort", None, rubric_id,"",3)
+ level2 = Level(None, "Developing","Effort put is only asked in class", None, rubric_id,"",2)
+ level3 = Level(None, "Unsatisfactory","No effort put in", None, rubric_id,"",1)
+ levels = []
+ levels = [level0, level1, level2, level3]
+ self.yardstickdDB.insert_criteria(category, levels)
+
+ project = Project(None, "My song", "Sample", "Great Song","Music I",\
+ str(unicode(today.replace(microsecond=0))), 1, 1,rubric_id,"sample","",0)
+
+ print project.subject
+ self.yardstickdDB.insert_project(project)
+
+
+ rubric = Rubric(None, "Art", "Sample", "Art Rubric",1,"sample","",1)
+ self.yardstickdDB.insert_rubric(rubric)
+ rubric_id = self.yardstickdDB.query_maxrubric()
+
+ category = Category(None, "Creativity", rubric_id,"",33.3333)
+ level0 = Level(None, "Exemplary","Generating many ideas", None, rubric_id,"",5)
+ level1 = Level(None, "Proficient","Based his or her work on someone else's idea", None, rubric_id,"",4)
+ level2 = Level(None, "Developing","Lacked originality", None, rubric_id,"",3)
+ level3 = Level(None, "Unsatisfactory","No evidence of trying anything unusual", None, rubric_id,"",2)
+ levels = []
+ levels = [level0, level1, level2, level3]
+ self.yardstickdDB.insert_criteria(category, levels)
+
+ category = Category(None, "Effort", rubric_id,"",33.3333)
+ level0 = Level(None, "Exemplary","Gave it effort far beyond that required", None, rubric_id,"",5)
+ level1 = Level(None, "Proficient","The student work hard and completed the project", None, rubric_id,"",4)
+ level2 = Level(None, "Developing","Chose an easy project and did it indifferently", None, rubric_id,"",3)
+ level3 = Level(None, "Unsatisfactory","Completed with minimum effort", None, rubric_id,"",2)
+ levels = []
+ levels = [level0, level1, level2, level3]
+ self.yardstickdDB.insert_criteria(category, levels)
+
+ category = Category(None, "Craftsmanship/Skill", rubric_id,"",33.3333)
+ level0 = Level(None, "Exemplary","The artwork was beautiful and patiently done", None, rubric_id,"",5)
+ level1 = Level(None, "Proficient","Lacks the finishing touches", None, rubric_id,"",4)
+ level2 = Level(None, "Developing","The student showed average craftsmanship", None, rubric_id,"",3)
+ level3 = Level(None, "Unsatisfactory","The student showed below average craftsmanship", None, rubric_id,"",2)
+ levels = []
+ levels = [level0, level1, level2, level3]
+ self.yardstickdDB.insert_criteria(category, levels)
+
+ project2 = Project(None, "My Mosaic", "Sample", "Art Project","Art Stud I",\
+ str(unicode(today.replace(microsecond=0))), 0, 1,rubric_id,"sample","",0)
+
+ self.yardstickdDB.insert_project(project2)
diff --git a/Template.pyc b/Template.pyc
new file mode 100644
index 0000000..442cd50
--- /dev/null
+++ b/Template.pyc
Binary files differ
diff --git a/YardStickActivity.py b/YardStickActivity.py
new file mode 100644
index 0000000..66ee52d
--- /dev/null
+++ b/YardStickActivity.py
@@ -0,0 +1,1400 @@
+# Copyright 2011-2012 Almira Cayetano
+# Copyright 2011-2012 Christian Joy Aranas
+# Copyright 2011-2012 Ma. Rowena Solamo
+# Copyright 2011-2012 Rommel Feria
+# Copyright 2007-2008 One Laptop Per Child
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# This program is a project of the University of the Philippines, College
+# of Engineering, Department of Computer Science intended for
+# educational purposes. If you have any suggestions and comments, you can contact us
+# with the following email addresses :
+#
+# Almira Cayetano - almiracayetano@gmail.com
+# Christian Joy Aranas - cjmaranas@gmail.com
+# Ma. Rowena Solamo - rcsolamo@dcs.upd.edu.ph
+# Rommel Feria - rpferia@dcs.upd.edu.ph
+
+import pygtk
+pygtk.require('2.0')
+import gtk, gobject
+from Models import*
+from Template import Template
+from Bundler import Bundler
+import datetime
+import pango
+import hippo
+import logging
+import telepathy
+
+import cjson
+import logging
+import telepathy
+from dbus.service import method, signal
+from dbus.gobject_service import ExportedGObject
+
+from sugar.activity.activity import Activity, ActivityToolbox
+from sugar.activity import activity
+from sugar.graphics import style
+from sugar.graphics.alert import NotifyAlert
+from sugar.presence import presenceservice
+from sugar.presence.tubeconn import TubeConnection
+
+from telepathy.interfaces import (
+ CHANNEL_INTERFACE, CHANNEL_INTERFACE_GROUP, CHANNEL_TYPE_TEXT,
+ CONN_INTERFACE_ALIASING)
+from telepathy.constants import (
+ CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES,
+ CHANNEL_TEXT_MESSAGE_TYPE_NORMAL)
+from telepathy.client import Connection, Channel
+
+SERVICE = "org.laptop.YardStick"
+IFACE = SERVICE
+PATH = "/org/laptop/YardStick"
+
+
+BORDER_COLOR = '#FFDE00'
+BACKGROUND_COLOR = '#66CC00'
+BUTTON_COLOR = '#097054'
+WHITE = '#FFFFFF'
+BLUE = '#82CAFA'
+PINK = '#FF0198'
+
+restrictions_level = ["2", "3", "4", "5", "6", "7", "8", "9"]
+restrictions_category = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
+RUBRICTITLE = []
+RUBRICLIST = []
+
+
+def theme_button(button):
+
+ button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(BLUE))
+ return button
+
+def image_button(button, path):
+ pixbufanim = gtk.gdk.PixbufAnimation(path)
+ image = gtk.Image()
+ image.set_from_animation(pixbufanim)
+ image.show()
+ button.add(image)
+ return button
+
+def theme_box(box, color):
+ eb = gtk.EventBox()
+ box.set_border_width(5)
+ eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(color))
+ eb.add(box)
+
+ return eb
+
+class YardStickActivity(activity.Activity):
+#class YardStickActivity():
+ def __init__(self, handle):
+# def __init__(self):
+ Activity.__init__(self, handle)
+ self.set_title('YardStick Activity')
+
+ toolbox = ActivityToolbox(self)
+ self.set_toolbox(toolbox)
+ toolbox.show()
+
+ self.pservice = presenceservice.get_instance()
+
+ owner = self.pservice.get_owner()
+ self.owner = owner
+ self.owner_nick = owner.props.nick
+ self.is_exists = False
+ self.overwrite = False
+ self.current_category_id = None
+# self.owner_nick = "cnix"
+
+ self.yardstickDB = YardStickDB()
+ is_newlycreated = self.yardstickDB.connect_db(self.owner_nick)
+ if(is_newlycreated):
+ template = Template(self.owner_nick, self.yardstickDB)
+ logging.debug("ScorepadDB --> template")
+ template.save_template()
+ logging.debug("ScorepadDB -->save_template")
+
+ list = self.yardstickDB.queryall_rubric(1)
+
+ for temp in list:
+ RUBRICLIST.append(temp)
+ RUBRICTITLE.append(temp.title)
+
+ list = self.yardstickDB.queryall_rubric(0)
+
+ for temp in list:
+ RUBRICLIST.append(temp)
+ RUBRICTITLE.append(temp.title)
+
+ self.main_table_eb = gtk.EventBox()
+ self.main_table = gtk.Table(1,3,True)
+ self.main_table_eb.add(self.main_table)
+ self.main_table_eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+ self.main_table_eb.set_border_width(20)
+
+ self.rubric_box = gtk.Table(12,3, True)
+ self.processpanel = gtk.Frame()
+ self.processpanel.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+ self.processpanel.set_border_width(10)
+ self.processpanel.set_label("Welcome to YardStick!")
+ logo = gtk.Image()
+ logo.set_from_file("images/homepage.png")
+ logo.show()
+ self.rubric_box.attach(logo,0,3,0,12)
+
+ self.processpanel.add(self.rubric_box)
+
+ self.hpaned_window = gtk.HPaned()
+ self.hpaned_window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+
+ self.left_hpaned = self.create_rubric_list()
+ self.hpaned_window.add1(self.left_hpaned)
+ self.hpaned_window.set_position(270)
+
+ self.hpaned_window.add2(self.processpanel)
+
+ self.main_event_box = gtk.EventBox()
+ self.main_event_box.add(self.hpaned_window)
+ self.main_event_box.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+ self.main_event_box.show_all()
+ self.set_canvas(self.main_event_box)
+
+
+ self.is_shared = False
+ self.text_channel = None
+ if self.shared_activity:
+ logging.debug('Activity joined')
+ self.connect('joined', self._joined_cb)
+ if self.get_shared():
+ self._joined_cb(self)
+ else:
+ logging.debug('Activity shared')
+ self.connect('shared', self._shared_cb)
+
+# self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+# self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
+# self.window.set_title("YardStick")
+# self.window.resize(730,650)
+# self.window.add(self.main_event_box)
+# self.window.show_all()
+
+ def load_window(self):
+ self.left_hpaned.destroy()
+ self.left_hpaned = self.create_rubric_list()
+ self.hpaned_window.add1(self.left_hpaned)
+
+ self.processpanel.set_label("Welcome to YardStick!")
+
+ logo = gtk.Image()
+ logo.set_from_file("images/homepage.png")
+ logo.show()
+
+ self.rubric_box.attach(logo,0,3,0,12)
+ self.processpanel.add(self.rubric_box)
+
+ self.hpaned_window.add2(self.processpanel)
+ self.hpaned_window.show_all()
+
+ def create_rubric_list(self):
+ rubric_list_table = gtk.Table(12,1,True)
+
+ tree_store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
+
+ count = 0
+ for r in RUBRICTITLE:
+ tree_store.append(None, (r + " - " +str(RUBRICLIST[count].author),None))
+ count = count+1
+
+ scrolled_window = gtk.ScrolledWindow()
+ scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ scrolled_window.set_border_width(5)
+
+ self.model = gtk.ListStore(gobject.TYPE_STRING)
+ self.tree_view = gtk.TreeView(tree_store)
+
+ scrolled_window.add_with_viewport (self.tree_view)
+ self.tree_view.show()
+
+ self.cell = gtk.CellRendererText()
+
+ self.column = gtk.TreeViewColumn("Rubrics List", self.cell, text=0)
+
+ self.tree_view.append_column(self.column)
+
+ share_button = gtk.Button()
+ share_button = image_button(share_button,"images/share.png")
+ share_button = theme_button(share_button)
+
+ box = gtk.HBox(False,2)
+ new_rubric_button = gtk.Button()
+ new_rubric_button = image_button(new_rubric_button,"images/addnew.png")
+ new_rubric_button = theme_button(new_rubric_button)
+ new_rubric_button.connect("clicked", self.enter_row_column, "Rubric")
+ box.add(new_rubric_button)
+ box = theme_box(box,BUTTON_COLOR)
+
+ rubric_list_table.attach(box,0,1,11,12)
+
+ logo = gtk.Image()
+ logo.set_from_file("images/YardStick.png")
+ logo.show()
+
+ self.tree_view.connect("row-activated", self.view_rubric_details)
+ self.tree_view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(BLUE))
+ rubric_list_table.attach(logo, 0,1,0,4)
+
+ rubric_list_table.attach(scrolled_window,0,1,4,11)
+ rubric_list_table.show_all()
+ scrolled_window.show_all()
+
+ return rubric_list_table
+
+ def view_rubric_details(self,widget,row,col):
+ r = row[0]
+ self.selected_rubric = r
+ rubric = RUBRICLIST[r]
+ rubric_id = RUBRICLIST[r].rubric_id
+ print "almira"+str(RUBRICLIST[r].rubric_id)
+ self.selected_rubric_id = rubric_id
+ category = self.yardstickDB.queryall_category(rubric_id)
+ category_id = category[0].category_id
+ row = len(category)+1
+
+ c = len(self.yardstickDB.query_level(category_id))+1
+ column_names = self.yardstickDB.query_level(category_id)
+ level_names = []
+
+ for i in column_names:
+ level_names.append(i.name)
+
+ levels = []
+
+ for i in range(c-1):
+ level = []
+ for j in range(row-1):
+ category_id = category[j].category_id
+ level_temp = self.yardstickDB.query_level(category_id)
+ level.append(level_temp[i].description)
+ levels.append(level)
+
+ tree_store = self.create_tree_store(c)
+
+ column = []
+
+ for i in range(len(levels)):
+ column.append(levels[i])
+
+ rubric_id = rubric.rubric_id
+ category = self.yardstickDB.queryall_category(rubric_id)
+ tuple = []
+ for i in range(len(category)):
+ tuple = []
+ tuple.append(category[i].name + " (" + str(category[i].percentage) + ")")
+
+ for j in range(c-1):
+ tuple.append(column[j][i])
+
+ tree_store.append(None, tuple)
+
+ view = gtk.TreeView(tree_store)
+ view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(BLUE))
+ view.set_rules_hint(True)
+ renderer = gtk.CellRendererText()
+ renderer.props.wrap_width = 100
+ renderer.props.wrap_mode = pango.WRAP_WORD
+ column0 = gtk.TreeViewColumn("Category", renderer, text=0)
+ column0.set_resizable(True)
+ view.append_column(column0)
+
+ for i in range(len(levels)):
+ render = gtk.CellRendererText()
+ render.props.wrap_width = 100
+ render.props.wrap_mode = pango.WRAP_WORD
+ column = gtk.TreeViewColumn(column_names[i].name + " (" + str(column_names[i].points) + ")", render, text=i+1)
+ column.set_resizable(True)
+ view.append_column(column)
+
+ hbox = gtk.HBox(False, 2)
+ self.rubric_title_copy = rubric.title
+
+ edit_button = gtk.Button()
+ edit_button = image_button(edit_button,"images/edit.png")
+ edit_button = theme_button(edit_button)
+ edit_button.connect("clicked", self.edit_rubric, rubric, r, row, c, level_names, levels)
+ hbox.add(edit_button)
+
+ delete_button = gtk.Button()
+ delete_button = image_button(delete_button,"images/delete.png")
+ delete_button = theme_button(delete_button)
+ delete_button.connect("clicked", self.delete_rubric, rubric, r)
+ hbox.add(delete_button)
+
+ share_button = gtk.Button()
+ share_button = image_button(share_button,"images/share.png")
+ share_button = theme_button(share_button)
+ share_button.connect("clicked", self.share_cb)
+ hbox.add(share_button)
+
+ send_sp = gtk.Button()
+ send_sp = image_button(send_sp,"images/sendtoscorepad.png")
+ send_sp = theme_button(send_sp)
+ send_sp.connect("clicked", self.send_to_ScorePad)
+ hbox.add(send_sp)
+
+ hbox = theme_box(hbox, BUTTON_COLOR)
+
+ author_img = gtk.Image()
+ author_img.set_from_file("images/author.png")
+ author_text = gtk.Entry()
+ author_text.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ author_text.set_text(rubric.author)
+
+ description_img = gtk.Image()
+ description_img.set_from_file("images/description.png")
+ description_text = gtk.Entry()
+ description_text.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ description_text.set_text(rubric.description)
+
+ vbox1 = gtk.VBox(False,2)
+ vbox1.add(author_img)
+ vbox1.add(description_img)
+
+ vbox2 = gtk.VBox(False,2)
+ vbox2.add(author_text)
+ vbox2.add(description_text)
+
+ box = view
+ box = theme_box(box,BACKGROUND_COLOR)
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
+ sw.add_with_viewport(box)
+ sw.set_border_width(5)
+
+ self.processpanel.destroy()
+
+ design = gtk.Image()
+ design.set_from_file("images/child.png")
+
+ self.view_rubric_table = gtk.Table(12,3,True)
+ self.view_rubric_table.attach(vbox1,0,1,0,2)
+ self.view_rubric_table.attach(vbox2,1,2,0,2)
+ self.view_rubric_table.attach(design,2,3,0,2)
+ self.view_rubric_table.attach(sw,0,3,2,11)
+ self.view_rubric_table.attach(hbox,0,3,11,12)
+
+ self.processpanel.add(self.view_rubric_table)
+ self.processpanel.set_label(rubric.title + " Details")
+
+ self.hpaned_window.add2(self.processpanel)
+ self.hpaned_window.show_all()
+
+ def edit_rubric(self, widget, rubric, r, row, column, levels, level_description):
+
+ title_img = gtk.Image()
+ title_img.set_from_file("images/title.png")
+ author_img = gtk.Image()
+ author_img.set_from_file("images/author.png")
+ self.title_entry = gtk.Entry(50)
+ self.title_entry.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ self.title_entry.set_text(rubric.title)
+ self.author_entry = gtk.Entry(50)
+ self.author_entry.set_text(rubric.author)
+ self.author_entry.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ self.description_field = gtk.TextView()
+ self.description_field.set_wrap_mode(gtk.WRAP_WORD)
+ df_buffer = self.description_field.get_buffer()
+ df_buffer.set_text(rubric.description)
+ self.description_field.set_border_width(3)
+ self.description_field.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BUTTON_COLOR))
+ df_sw = gtk.ScrolledWindow()
+ df_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ df_sw.add_with_viewport(self.description_field)
+
+ self.category_entries = []
+ self.level_entries = []
+ self.text_entries = []
+
+ hbox = gtk.HBox(False,2)
+
+ self.checkbox = gtk.CheckButton("Enable Points")
+ self.checkbox = theme_button(self.checkbox)
+
+ is_enabled = self.yardstickDB.is_points_enabled(rubric.rubric_id)
+ self.checkbox.set_active(is_enabled)
+ self.checkbox.connect("clicked", self.enable_points)
+ self.rubric_box.attach(self.checkbox,0,1,11,12)
+
+ self.points_button = gtk.Button()
+ self.points_button = image_button(self.points_button,"images/editpoints.png")
+
+ if is_enabled :
+ self.points_button.set_sensitive(True)
+ else:
+ self.points_button.set_sensitive(False)
+ self.points_button = theme_button(self.points_button)
+ hbox.add(self.points_button)
+
+ self.update_button = gtk.Button()
+ self.update_button = image_button(self.update_button,"images/update.png")
+ self.update_button = theme_button(self.update_button)
+ self.update_button.connect("clicked", self.update_warning, rubric, r)
+ hbox.add(self.update_button)
+
+ hbox = theme_box(hbox, BUTTON_COLOR)
+
+ self.rubric_text_view_table = gtk.Table((row*5)+1,(column*5)+1,True)
+ rubric_text_eb = gtk.EventBox()
+ rubric_text_eb.add(self.rubric_text_view_table)
+ rubric_text_eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+
+ categories = self.yardstickDB.queryall_category(rubric.rubric_id)
+ category_names = []
+ category_ids = []
+ description = []
+
+ for i in categories:
+ category_names.append(i.name)
+ category_ids.append(i.category_id)
+
+ for i in category_ids:
+ level = self.yardstickDB.query_level(i)
+
+ for j in level:
+ description.append(j.description)
+
+ self.points_button.connect("clicked", self.points_cb, rubric, categories, level)
+
+ left = 1
+ right = 5
+ up = 1
+ down = 5
+ level_counter = 0
+ category_counter = 0
+ description_counter = 0
+ for i in range(row):
+ for j in range(column):
+
+ if i == 0 and j == 0:
+ self.level_label = gtk.Label("Level")
+ self.category_label = gtk.Label("Category")
+ self.rubric_text_view_table.attach(self.level_label,1,5,1,3)
+ self.rubric_text_view_table.attach(self.category_label,1,5,3,5)
+ left += 5
+ right += 5
+ elif i == 0:
+ temp = gtk.TextView()
+ temp.set_wrap_mode(gtk.WRAP_WORD)
+ buffer = temp.get_buffer()
+ buffer.set_text(levels[level_counter])
+ level_counter += 1
+ self.level_entries.append(buffer)
+ temp.set_border_width(3)
+ temp.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(PINK))
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_NEVER)
+ sw.add(temp)
+ self.rubric_text_view_table.attach(sw, left, right, up, down)
+ left += 5
+ right += 5
+ elif j == 0:
+ temp = gtk.TextView()
+ temp.set_wrap_mode(gtk.WRAP_WORD)
+ buffer = temp.get_buffer()
+ buffer.set_text(category_names[category_counter])
+ category_counter += 1
+ self.category_entries.append(buffer)
+ temp.set_border_width(3)
+ temp.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(PINK))
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_NEVER)
+ sw.add(temp)
+ self.rubric_text_view_table.attach(sw, left, right, up, down)
+ left += 5
+ right += 5
+ else:
+ temp = gtk.TextView()
+ temp.set_wrap_mode(gtk.WRAP_WORD)
+ buffer = temp.get_buffer()
+ buffer.set_text(description[description_counter])
+ description_counter += 1
+ self.text_entries.append(buffer)
+ temp.set_border_width(3)
+ temp.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BUTTON_COLOR))
+ temp.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color(BLUE))
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_NEVER)
+ sw.add(temp)
+ self.rubric_text_view_table.attach(sw, left, right, up, down)
+ left += 5
+ right += 5
+ left = 1
+ right = 5
+ up += 5
+ down += 5
+
+ self.rubricVB1 = gtk.VBox(False,0)
+ self.rubricVB2 = gtk.VBox(False,0)
+
+ self.processpanel.destroy()
+ self.processpanel.add(self.rubric_box)
+ self.processpanel.set_label("Rubric Maker")
+
+ self.rubricVB1.add(title_img)
+ self.rubricVB1.add(author_img)
+
+ description_frame = gtk.Frame()
+ description_frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+ description_frame.set_border_width(5)
+ description_frame.set_label("Description")
+ description_frame.add(df_sw)
+
+ self.rubricVB2.add(self.title_entry)
+ self.rubricVB2.add(self.author_entry)
+
+ self.rubric_box.attach(self.rubricVB1, 0,1,0,2)
+ self.rubric_box.attach(self.rubricVB2, 1,2,0,2)
+ self.rubric_box.attach(description_frame,2,3,0,2)
+ self.rubric_box.attach(hbox, 1,3,11,12)
+
+ sw_eb = gtk.EventBox()
+
+ self.scrolled_window = gtk.ScrolledWindow()
+ self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ self.scrolled_window.add_with_viewport(rubric_text_eb)
+ self.scrolled_window = theme_box(self.scrolled_window, BORDER_COLOR)
+
+ sw_eb.add(self.scrolled_window)
+ self.rubric_box.attach(sw_eb, 0,3,2,11)
+
+ self.hpaned_window.add2(self.processpanel)
+ self.hpaned_window.show_all()
+
+ def points_cb(self,widget,rubric, categories,levels):
+ title_img = gtk.Image()
+ title_img.set_from_file("images/title.png")
+ author_img = gtk.Image()
+ author_img.set_from_file("images/author.png")
+ self.title_entry = gtk.Entry(50)
+ self.title_entry.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ self.title_entry.set_text(rubric.title)
+ self.author_entry = gtk.Entry(50)
+ self.author_entry.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ self.author_entry.set_text(rubric.author)
+ self.description_field = gtk.TextView()
+ self.description_field.set_wrap_mode(gtk.WRAP_WORD)
+ df_buffer = self.description_field.get_buffer()
+ df_buffer.set_text(rubric.description)
+ self.description_field.set_border_width(3)
+ self.description_field.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BUTTON_COLOR))
+ df_sw = gtk.ScrolledWindow()
+ df_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ df_sw.add_with_viewport(self.description_field)
+
+ self.rubricVB1 = gtk.VBox(False,0)
+ self.rubricVB2 = gtk.VBox(False,0)
+
+ self.processpanel.destroy()
+ self.processpanel.add(self.rubric_box)
+ self.processpanel.set_label("Rubric Maker")
+
+ self.rubricVB1.add(title_img)
+ self.rubricVB1.add(author_img)
+
+ description_frame = gtk.Frame()
+ description_frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+ description_frame.set_border_width(5)
+ description_frame.set_label("Description")
+ description_frame.add(df_sw)
+
+ self.rubricVB2.add(self.title_entry)
+ self.rubricVB2.add(self.author_entry)
+
+ self.rubric_box.attach(self.rubricVB1, 0,1,0,2)
+ self.rubric_box.attach(self.rubricVB2, 1,2,0,2)
+ self.rubric_box.attach(description_frame,2,3,0,2)
+
+ self.level_attr = []
+ self.category_attr = []
+
+ middlebox = gtk.HBox(False,20)
+ middlebox.add(self.build_pointbox(levels, 0))
+ middlebox.add(self.build_pointbox(categories, 1))
+ middlebox = theme_box(middlebox, BLUE)
+ self.rubric_box.attach(middlebox,0,3,3,11)
+
+ img_box = gtk.HBox(False,20)
+ level_img = gtk.Image()
+ level_img.set_from_file("images/levels.png")
+ category_img = gtk.Image()
+ category_img.set_from_file("images/categories.png")
+ img_box.add(level_img)
+ img_box.add(category_img)
+ img_box = theme_box(img_box, BLUE)
+
+ self.rubric_box.attach(img_box,0,3,2,3)
+
+ hbox = gtk.HBox(False,2)
+
+ save_points_button = gtk.Button()
+ save_points_button = image_button(save_points_button,"images/save.png")
+ save_points_button = theme_button(save_points_button)
+ save_points_button.connect("clicked", self.save_points, rubric.rubric_id)
+ hbox.add(save_points_button)
+ hbox = theme_box(hbox, BUTTON_COLOR)
+ self.rubric_box.attach(hbox, 2,3,11,12)
+
+ self.hpaned_window.add2(self.processpanel)
+ self.hpaned_window.show_all()
+
+
+ def enable_points(self, widget, data=None):
+ if self.checkbox.get_active():
+ self.points_button.set_sensitive(True)
+ else:
+ self.points_button.set_sensitive(False)
+
+
+ def build_pointbox(self, elements, checker):
+ label_vbox = gtk.VBox(False,0)
+ spinner_vbox = gtk.VBox(False,0)
+ count = len(elements)
+ equal_percentage = 100.0/count
+
+ for element in elements:
+ label_temp = gtk.Label(element.name)
+ label_vbox.add(label_temp)
+ if checker == 0:
+ initial = element.points
+ else:
+ initial = element.percentage
+ if initial == 0.0:
+ initial = equal_percentage
+
+ adj = gtk.Adjustment(initial,1,100,10,0,0)
+ spinner = gtk.SpinButton(adj, 0, 0)
+ spinner.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BLUE))
+ spinner.set_wrap(True)
+ spinner_vbox.add(spinner)
+ if checker == 0:
+ tuple = (element.name, spinner)
+ self.level_attr.append(tuple)
+ else:
+ tuple = (element.category_id, spinner)
+ self.category_attr.append(tuple)
+ hbox = gtk.HBox(False,0)
+ hbox.add(label_vbox)
+ hbox.add(spinner_vbox)
+
+ return hbox
+
+ def save_points(self, widget, rubric_id):
+
+ percent = 0
+ for attr in self.category_attr:
+ id = attr[0]
+ spinner = attr[1]
+ percent = percent + spinner.get_value_as_int()
+
+ if percent > 100 or percent < 100:
+ md = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Total percentage must exactly be 100%")
+ md.run()
+ md.destroy()
+ else:
+ self.yardstickDB.update_enablepoints(rubric_id,1)
+ for attr in self.category_attr:
+ id = attr[0]
+ spinner = attr[1]
+ self.yardstickDB.update_percentage(id, spinner.get_value_as_int())
+ for attr2 in self.level_attr:
+ name = attr2[0]
+ spinner2 = attr2[1]
+ self.yardstickDB.update_points(id, name, spinner2.get_value_as_int())
+
+ md = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Points saved!")
+ md.run()
+ md.destroy()
+ self.processpanel.destroy()
+ self.load_window()
+
+
+ def update_warning(self, widget, rubric, r):
+ warning = gtk.MessageDialog(parent = None,buttons = gtk.BUTTONS_YES_NO, \
+ flags =gtk.DIALOG_DESTROY_WITH_PARENT,\
+ type = gtk.MESSAGE_WARNING,\
+ message_format = "Are you sure you want to save changes?")
+ result = warning.run()
+
+ if(result == gtk.RESPONSE_YES):
+ count = self.yardstickDB.rubric_title_exists(self.title_entry.get_text())
+ warning.destroy()
+ if(count == None):
+ self.update_rubric(widget,rubric,r)
+ self.processpanel.destroy()
+ self.load_window()
+ print "Count if"
+ else:
+ print self.title_entry.get_text() + " " + self.rubric_title_copy
+ if(self.title_entry.get_text() == self.rubric_title_copy):
+ self.update_rubric(widget,rubric,r)
+ self.processpanel.destroy()
+ self.load_window()
+ print "Count else title if"
+ else:
+ warning2 = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Name already exists. Please rename the rubric.")
+ result = warning2.run()
+ warning2.destroy()
+ elif(result == gtk.RESPONSE_NO):
+ warning.destroy()
+ warning.destroy()
+
+ def update_rubric(self,widget,orig_rubric,r):
+
+ title = self.title_entry.get_text()
+ author = self.author_entry.get_text()
+ description_buffer = self.description_field.get_buffer()
+ start = description_buffer.get_start_iter()
+ end = description_buffer.get_end_iter()
+ description = description_buffer.get_text(start,end,True)
+
+ self.get_texts()
+ #self.processpanel.destroy()
+
+ if self.checkbox.get_active():
+ enable_points = 1
+ else :
+ enable_points = 0
+
+ rubric = Rubric(orig_rubric.rubric_id, title, author, description, 0, self.owner_nick, "",enable_points)
+ self.yardstickDB.update_rubric(rubric)
+ rubric = self.yardstickDB.query_rubric(orig_rubric.rubric_id)
+
+ RUBRICTITLE[r] = rubric.title
+ RUBRICLIST[r] = rubric
+
+ level = []
+ category_id_retrieve = []
+
+ temporary = self.yardstickDB.queryall_category(orig_rubric.rubric_id)
+
+ for i in temporary:
+ category_id_retrieve.append(i.category_id)
+
+ level_id_retrieve = []
+
+ for i in category_id_retrieve:
+
+ temporary = self.yardstickDB.query_level(i)
+
+ for j in temporary:
+ level_id_retrieve.append(j.level_id)
+
+ for i in self.levels:
+ temp = Level()
+ temp.name = i
+ temp.rubric_id = orig_rubric.rubric_id
+ level.append(temp)
+
+ counter = 0
+ category_counter = 0
+ level_counter = 0
+ category_array = []
+
+ for i in self.categories:
+ for k in level:
+ k.description = self.criteria_description[counter]
+ counter += 1
+ k.category_id = category_id_retrieve[category_counter]
+ k.level_id = level_id_retrieve[level_counter]
+ level_counter += 1
+
+ category = Category()
+ category.name = i
+ category.description = "NONE"
+ category.rubric_id = orig_rubric.rubric_id
+ category.category_id = category_id_retrieve[category_counter]
+ category_counter += 1
+ category_array.append(category)
+ self.yardstickDB.update_levels(level)
+ self.yardstickDB.update_categories(category_array)
+ #self.load_window()
+
+ def delete_rubric(self, widget, rubric, r):
+
+ warning = gtk.MessageDialog(parent = None,buttons = gtk.BUTTONS_YES_NO, \
+ flags =gtk.DIALOG_DESTROY_WITH_PARENT,\
+ type = gtk.MESSAGE_WARNING,\
+ message_format = "Are you sure you want to delete the rubric?")
+ result = warning.run()
+ rubric_id = rubric.rubric_id
+
+ if result == gtk.RESPONSE_YES:
+ RUBRICTITLE.remove(rubric.title)
+ RUBRICLIST.remove(rubric)
+ self.yardstickDB.delete_rubric(rubric_id)
+ warning.destroy()
+ self.processpanel.destroy()
+ self.load_window()
+ elif result == gtk.RESPONSE_NO:
+ warning.destroy()
+ warning.destroy()
+
+ def create_tree_store(self, c):
+
+ if c == 2:
+ p = gtk.TreeStore(str,str)
+ elif c == 3:
+ p = gtk.TreeStore(str,str,str)
+ elif c == 4:
+ p = gtk.TreeStore(str,str,str,str)
+ elif c == 5:
+ p = gtk.TreeStore(str,str,str,str,str)
+ elif c == 6:
+ p = gtk.TreeStore(str,str,str,str,str,str)
+ elif c == 7:
+ p = gtk.TreeStore(str,str,str,str,str,str,str)
+ elif c == 8:
+ p = gtk.TreeStore(str,str,str,str,str,str,str,str)
+ elif c == 9:
+ p = gtk.TreeStore(str,str,str,str,str,str,str,str,str)
+ return p
+
+ def enter_row_column(self,widget,label):
+
+ self.processpanel.destroy()
+ self.processpanel.set_label("Enter number of categories and levels")
+
+ self.rc_table = gtk.Table(8,3, True)
+
+ level_label = gtk.Label("Levels")
+ category_label = gtk.Label("Categories")
+
+ level_adj = gtk.Adjustment(2,2,9,1,0,0)
+ level_spinner = gtk.SpinButton(level_adj, 0, 0)
+ level_spinner.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ level_spinner.set_wrap(True)
+
+ category_adj = gtk.Adjustment(1,1,9,1,0,0)
+ category_spinner = gtk.SpinButton(category_adj, 0, 0)
+ category_spinner.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ category_spinner.set_wrap(True)
+
+ submit_button = gtk.Button()
+ submit_button = image_button(submit_button,"images/submit.png")
+ submit_button = theme_button(submit_button)
+ submit_button.connect("clicked", self.add_rubric, category_spinner, level_spinner)
+
+ vbox1 = gtk.VBox(False,2)
+ vbox2 = gtk.VBox(False,2)
+
+ button_table = gtk.Table(2,1,True)
+ button_table.attach(submit_button, 0,1,0,1)
+
+ vbox1.add(level_label)
+ vbox1.add(category_label)
+
+ vbox2.add(level_spinner)
+ vbox2.add(category_spinner)
+
+ self.rc_table.attach(vbox1,0,1,3,4)
+ self.rc_table.attach(vbox2,1,2,3,4)
+ self.rc_table.attach(button_table,1,2,4,5)
+
+ self.processpanel.add(self.rc_table)
+
+ self.hpaned_window.add2(self.processpanel)
+ self.hpaned_window.show_all()
+
+ def add_rubric(self,widget,r,c):
+ self.title_label = gtk.Label("Rubric Title")
+ self.author_label = gtk.Label("Author")
+ self.title_entry = gtk.Entry(50)
+ self.title_entry.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ self.author_entry = gtk.Entry(50)
+ self.author_entry.modify_bg(gtk.STATE_INSENSITIVE,gtk.gdk.color_parse(BACKGROUND_COLOR))
+ self.description_field = gtk.TextView()
+ self.description_field.set_wrap_mode(gtk.WRAP_WORD)
+ self.description_field.set_border_width(3)
+ self.description_field.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BUTTON_COLOR))
+ df_sw = gtk.ScrolledWindow()
+ df_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ df_sw.add_with_viewport(self.description_field)
+
+ self.category_entries = []
+ self.level_entries = []
+ self.text_entries = []
+
+ hbox = gtk.HBox(False, 2)
+
+ self.finalize_button = gtk.Button()
+ self.finalize_button = image_button(self.finalize_button,"images/finalize.png")
+ self.finalize_button = theme_button(self.finalize_button)
+ self.finalize_button.connect("clicked", self.finalize_cb)
+ hbox.add(self.finalize_button)
+ hbox = theme_box(hbox, BUTTON_COLOR)
+
+ row = r.get_value_as_int() + 1
+ column = c.get_value_as_int() + 1
+ self.rubric_text_view_table = gtk.Table((row*5)+1,(column*5)+1,True)
+ rubric_text_eb = gtk.EventBox()
+ rubric_text_eb.add(self.rubric_text_view_table)
+ rubric_text_eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+
+ left = 1
+ right = 5
+ up = 1
+ down = 5
+
+ for i in range(row):
+ for j in range(column):
+
+ if i == 0 and j == 0:
+ self.level_label = gtk.Label("Level")
+ self.category_label = gtk.Label("Category")
+ self.rubric_text_view_table.attach(self.level_label,1,5,1,3)
+ self.rubric_text_view_table.attach(self.category_label,1,5,3,5)
+ left += 5
+ right += 5
+ elif i == 0:
+ temp = gtk.TextView()
+ temp.set_wrap_mode(gtk.WRAP_WORD)
+ buffer = temp.get_buffer()
+ self.level_entries.append(buffer)
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
+ temp.set_border_width(3)
+ temp.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(PINK))
+ sw.add(temp)
+ self.rubric_text_view_table.attach(sw, left, right, up, down)
+ left += 5
+ right += 5
+ elif j == 0:
+ temp = gtk.TextView()
+ temp.set_wrap_mode(gtk.WRAP_WORD)
+ buffer = temp.get_buffer()
+ self.category_entries.append(buffer)
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
+ temp.set_border_width(3)
+ temp.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(PINK))
+ sw.add(temp)
+ self.rubric_text_view_table.attach(sw, left, right, up, down)
+ left += 5
+ right += 5
+ else:
+ temp = gtk.TextView()
+ temp.set_wrap_mode(gtk.WRAP_WORD)
+ buffer = temp.get_buffer()
+ self.text_entries.append(buffer)
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
+ temp.set_border_width(3)
+ temp.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BUTTON_COLOR))
+ temp.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color(BLUE))
+ sw.add(temp)
+ self.rubric_text_view_table.attach(sw, left, right, up, down)
+ left += 5
+ right += 5
+ left = 1
+ right = 5
+ up += 5
+ down += 5
+
+ self.rubricVB1 = gtk.VBox(False,3)
+ self.rubricVB2 = gtk.VBox(False, 3)
+
+ self.processpanel.destroy()
+ self.processpanel.add(self.rubric_box)
+ self.processpanel.set_label("Rubric Maker")
+ self.processpanel.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+ self.processpanel.set_border_width(5)
+
+ self.rubricVB1.add(self.title_label)
+ self.rubricVB1.add(self.author_label)
+
+ description_frame = gtk.Frame()
+ description_frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(BACKGROUND_COLOR))
+ description_frame.set_border_width(5)
+ description_frame.set_label("Description")
+ description_frame.add(df_sw)
+
+ self.rubricVB2.add(self.title_entry)
+ self.rubricVB2.add(self.author_entry)
+
+ self.rubric_box.attach(self.rubricVB1, 0,1,0,2)
+ self.rubric_box.attach(self.rubricVB2, 1,2,0,2)
+ self.rubric_box.attach(description_frame,2,3,0,2)
+ self.rubric_box.attach(hbox,2,3,11,12)
+
+ scrolled_window = gtk.ScrolledWindow()
+ scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ scrolled_window.add_with_viewport(rubric_text_eb)
+ scrolled_window.set_border_width(5)
+ scrolled_window = theme_box(scrolled_window, BORDER_COLOR)
+
+ self.rubric_box.attach(scrolled_window, 0,3,2,11)
+
+ self.hpaned_window.add2(self.processpanel)
+ self.hpaned_window.show_all()
+
+ def get_texts(self):
+
+ self.categories = []
+ self.levels = []
+ self.criteria_description = []
+
+ for i in self.category_entries:
+ start, end = i.get_bounds()
+ text = i.get_slice(start,end, True)
+ self.categories.append(text)
+
+ for i in self.level_entries:
+ start, end = i.get_bounds()
+ text = i.get_text(start,end, True)
+ self.levels.append(text)
+
+ for i in self.text_entries:
+ start, end = i.get_bounds()
+ text = i.get_text(start,end, True)
+ self.criteria_description.append(text)
+
+ def finalize_cb(self, widget):
+
+ rubric_id = self.yardstickDB.query_maxrubric() + 1
+ title = self.title_entry.get_text()
+ author = self.author_entry.get_text()
+ description_buffer = self.description_field.get_buffer()
+ start = description_buffer.get_start_iter()
+ end = description_buffer.get_end_iter()
+ description = description_buffer.get_text(start,end,True)
+
+ self.get_texts()
+ rubric = Rubric(None, title, author, description, 0, self.owner_nick, "",0)
+ count = self.yardstickDB.rubric_title_exists(rubric.title)
+
+ if(count == None):
+ self.yardstickDB.insert_rubric(rubric)
+ rubric_id = self.yardstickDB.query_maxrubric()
+ rubric = self.yardstickDB.query_rubric(rubric_id)
+ RUBRICLIST.append(rubric)
+ RUBRICTITLE.append(rubric.title)
+
+ counter = 0
+ for i in self.categories:
+ levels = []
+ category = Category(None, i, rubric_id, "", 0.0)
+ for j in self.levels:
+ level = Level(None, j, self.criteria_description[counter], None, rubric_id, "", 0)
+ counter += 1
+ levels.append(level)
+ self.yardstickDB.insert_criteria(category, levels)
+ self.processpanel.destroy()
+ self.load_window()
+ else:
+ md = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Name already exists. Please rename the rubric.")
+ md.run()
+ md.destroy()
+
+ def send_to_ScorePad(self, widget):
+ rubric = RUBRICLIST[self.selected_rubric]
+ categories = []
+ categories = self.yardstickDB.queryall_category(self.selected_rubric_id)
+ levels = []
+
+ self.yardstickDB.close_db()
+
+ self.scorepadDB = ScorePadDB(self.owner_nick)
+
+ if(self.scorepadDB.rubric_exists(rubric.title, rubric.author)==None):
+ self.scorepadDB.insert_rubric(rubric)
+ rubric_id = self.scorepadDB.query_maxrubric()
+ self.scorepadDB.close_db()
+
+ for category in categories:
+ self.yardstickDB = YardStickDB()
+ self.yardstickDB.connect_db(self.owner_nick)
+ levels = self.yardstickDB.query_level(category.category_id)
+ self.yardstickDB.close_db()
+ self.scorepadDB = ScorePadDB(self.owner_nick)
+ self.scorepadDB.insert_criteria2(category,levels,rubric_id)
+ self.scorepadDB.close_db()
+
+ md = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Rubric sucessfully inserted")
+ md.run()
+ md.destroy()
+ else:
+ md = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Rubric exists. Please rename the rubric title.")
+ md.run()
+ md.destroy()
+
+ self.yardstickDB = YardStickDB()
+ self.yardstickDB.connect_db(self.owner_nick)
+
+ def share_cb(self,widget,data=None):
+
+ if self.is_shared :
+ rubric = RUBRICLIST[self.selected_rubric]
+
+ bundler = Bundler()
+ rubric_bundle = bundler.bundle_rubric(rubric)
+ logging.debug("Rubric Bundle")
+ logging.debug(rubric_bundle)
+ categories = self.yardstickDB.queryall_category(rubric.rubric_id)
+ category_bundle = bundler.bundle_category(categories)
+ level_bundle_list = []
+ for category in categories:
+ levels = self.yardstickDB.query_level(category.category_id)
+ level_bundle = bundler.bundle_level(levels)
+ level_bundle_list.append(level_bundle)
+
+ self.sendbundle_cb(rubric_bundle)
+ for i in range(len(category_bundle)):
+ self.sendbundle_cb(category_bundle[i])
+ level_temp = level_bundle_list[i]
+ for level in level_temp:
+ logging.debug('Function: share_cb --> levelbundle sent')
+ self.sendbundle_cb(level)
+
+ md = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Rubric shared")
+ md.run()
+ md.destroy()
+ else:
+ md = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, \
+ flags = gtk.DIALOG_DESTROY_WITH_PARENT, \
+ type = gtk.MESSAGE_INFO,\
+ message_format = "Cannot share. You are not connected to anybody.")
+ md.run()
+ md.destroy()
+
+# def destroy(self, widget, data=None):
+# gtk.main_quit()
+
+# def main(self):
+# gtk.main()
+
+
+#if __name__ == "__main__":
+# yardStick = YardStickActivity()
+# yardStick.main()
+
+ def update_status(self, nick, text):
+ text = text.split("|")
+ model_name = text[0]
+
+ if model_name == "Rubric":
+ self._alert("A Rubric was shared by", nick)
+ rubric = Rubric(None, text[2], text[3], text[4], 0, text[6], text[7], text[8])
+
+ logging.debug("Update Status->Rubric")
+
+ self.rubric_exists = self.yardstickDB.rubric_exists(rubric.rubric_sha, rubric.description)
+ if self.rubric_exists == None:
+ logging.debug("Update Status->Rubric: rubric_exists = None")
+ self.yardstickDB.insert_rubric(rubric)
+ rubric_id = self.yardstickDB.query_maxrubric()
+ rubric = self.yardstickDB.query_rubric(rubric_id)
+ RUBRICLIST.append(rubric)
+ RUBRICTITLE.append(rubric.title)
+ self.is_exists = False
+
+ logging.debug("Update Status->Rubric: rubric_exists =None; is_exists = False")
+ else:
+ logging.debug("Update Status->Rubric: rubric_exists = not None")
+ self.is_exists = True
+ logging.debug("Update Status->Rubric: is_exists = True")
+ warning = gtk.MessageDialog(parent = None,buttons = gtk.BUTTONS_YES_NO, \
+ flags =gtk.DIALOG_DESTROY_WITH_PARENT,\
+ type = gtk.MESSAGE_WARNING,\
+ message_format = "Rubric exists. Would like to overwrite?")
+ result = warning.run()
+ if(result == gtk.RESPONSE_YES):
+ logging.debug("Update Status->Rubric: response yes")
+ self.overwrite = True
+ warning.destroy()
+ self.yardstickDB.delete_rubric(self.rubric_exists)
+ self.yardstickDB.insert_rubric(rubric)
+ elif(result == gtk.RESPONSE_NO):
+ logging.debug("Update Status->Rubric: response no")
+ warning.destroy()
+ self.overwrite = False
+ warning.destroy()
+ self.processpanel.destroy()
+ self.load_window()
+
+ if model_name == "Category":
+ if self.is_exists == False or self.overwrite == True:
+ logging.debug("Update Status->Category: is_exists = False")
+ rubric_id = self.yardstickDB.query_maxrubric()
+ category = Category(None, text[2], rubric_id, text[4],text[5])
+ self.yardstickDB.insert_category(category)
+ logging.debug("Update Status->Category: is_exists = False; category_inserted")
+
+ if model_name == "Level":
+ if self.is_exists == False or self.overwrite == True:
+ logging.debug("Update Status->Level: is_exists = False")
+ rubric_id = self.yardstickDB.query_maxrubric()
+ category_id = self.yardstickDB.query_maxcategory()
+ level = Level(None, text[2], text[3], category_id, rubric_id, text[6], text[7])
+ self.yardstickDB.insert_level(level)
+ logging.debug("Update Status->Level: level inserted")
+
+ def _alert(self, title, text=None):
+ alert = NotifyAlert(timeout=3)
+ alert.props.title = title
+ alert.props.msg = text
+ self.add_alert(alert)
+ alert.connect('response', self._alert_cancel_cb)
+ alert.show()
+
+ def _alert_cancel_cb(self, alert, response_id):
+ self.remove_alert(alert)
+
+ def _shared_cb(self, sender):
+ self._setup()
+ self.is_shared = True
+ self._alert('Shared', 'The activity is shared')
+
+ def _setup(self):
+ self.text_channel = TextChannelWrapper(
+ self.shared_activity.telepathy_text_chan,
+ self.shared_activity.telepathy_conn)
+ self.text_channel.set_received_callback(self._received_cb)
+ self._alert("Activity Shared", "Connected")
+ self.shared_activity.connect('buddy-joined', self._buddy_joined_cb)
+ self.shared_activity.connect('buddy-left', self._buddy_left_cb)
+
+ def _joined_cb(self, sender):
+ if not self.shared_activity:
+ return
+ for buddy in self.shared_activity.get_joined_buddies():
+ self._buddy_already_exists(buddy)
+ self.is_shared = True
+ self._setup()
+ self._alert("Joined", "Joined Scorepad Activity")
+
+ def _received_cb(self, buddy, text):
+ if buddy:
+ if type(buddy) is dict:
+ nick = buddy['nick']
+ else:
+ nick = buddy.props.nick
+ else:
+ nick = '???'
+ self.update_status(str(nick),text)
+
+ def _buddy_joined_cb(self, sender, buddy):
+ if buddy == self.owner:
+ return
+ self._alert(str(buddy.props.nick), "joined the activity")
+
+ def _buddy_left_cb(self, sender, buddy):
+ if buddy == self.owner:
+ return
+ self._alert(str(buddy.props.nick), "left")
+
+ def _buddy_already_exists(self, buddy):
+ if buddy == self.owner:
+ return
+ self._alert(str(buddy.props.nick), "is here")
+
+ def sendbundle_cb(self, bundle):
+ text = bundle
+ if text:
+ if self.text_channel:
+ self.text_channel.send(text)
+ else:
+ print "Not connected"
+ self._alert("Bundle", "sent!")
+
+# def main(self):
+# gtk.main()
+
+class TextChannelWrapper(object):
+
+ def __init__(self, text_chan, conn):
+ self._activity_cb = None
+ self._text_chan = text_chan
+ self._conn = conn
+ self._signal_matches = []
+
+ def send(self, text):
+ if self._text_chan is not None:
+ self._text_chan[CHANNEL_TYPE_TEXT].Send(
+ CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, text)
+
+ def set_received_callback(self, callback):
+ if self._text_chan is None:
+ return
+ self._activity_cb = callback
+ m = self._text_chan[CHANNEL_TYPE_TEXT].connect_to_signal('Received',
+ self._received_cb)
+ self._signal_matches.append(m)
+
+ def _received_cb(self, identity, timestamp, sender, type_, flags, text):
+ if self._activity_cb:
+ try:
+ self._text_chan[CHANNEL_INTERFACE_GROUP]
+ except Exception:
+ nick = self._conn[
+ CONN_INTERFACE_ALIASING].RequestAliases([sender])[0]
+ buddy = {'nick': nick, 'color': '#000000,#808080'}
+ else:
+ buddy = self._get_buddy(sender)
+ self._activity_cb(buddy, text)
+ self._text_chan[
+ CHANNEL_TYPE_TEXT].AcknowledgePendingMessages([identity])
+ else:
+ print "Disconnected"
+
+ def _get_buddy(self, cs_handle):
+ pservice = presenceservice.get_instance()
+ tp_name, tp_path = pservice.get_preferred_connection()
+ conn = Connection(tp_name, tp_path)
+ group = self._text_chan[CHANNEL_INTERFACE_GROUP]
+ my_csh = group.GetSelfHandle()
+ if my_csh == cs_handle:
+ handle = conn.GetSelfHandle()
+ elif group.GetGroupFlags() & \
+ CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES:
+ handle = group.GetHandleOwners([cs_handle])[0]
+ else:
+ handle = cs_handle
+ assert handle != 0
+
+ return pservice.get_buddy_by_telepathy_handle(
+ tp_name, tp_path, handle)
diff --git a/YardStickActivity.pyc b/YardStickActivity.pyc
new file mode 100644
index 0000000..e986f86
--- /dev/null
+++ b/YardStickActivity.pyc
Binary files differ
diff --git a/activity/activity-yardstick.svg b/activity/activity-yardstick.svg
new file mode 100644
index 0000000..d7b4a8a
--- /dev/null
+++ b/activity/activity-yardstick.svg
@@ -0,0 +1,44 @@
+<?xml version="1.0" ?><!-- Created with Inkscape (http://www.inkscape.org/) --><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
+ <!ENTITY stroke_color "#666666">
+ <!ENTITY fill_color "#ffffff">
+]><svg height="48px" id="svg2985" inkscape:version="0.48.1 r9760" sodipodi:docname="activity-helloworld.sugar.svg" version="1.1" width="48px" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
+ <defs id="defs2987"/>
+ <sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="layer1" inkscape:cx="24" inkscape:cy="24" inkscape:document-units="px" inkscape:grid-bbox="true" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:snap-bbox="true" inkscape:snap-global="false" inkscape:window-height="626" inkscape:window-maximized="0" inkscape:window-width="901" inkscape:window-x="240" inkscape:window-y="78" inkscape:zoom="7" pagecolor="#ffffff" showgrid="true"/>
+ <metadata id="metadata2990">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:title/>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer1" inkscape:groupmode="layer" inkscape:label="Layer 1">
+ <path d="m 24.857143,18.071428 a 4.9285712,5.5 0 1 1 -9.857143,0 4.9285712,5.5 0 1 1 9.857143,0 z" id="path3004" sodipodi:cx="19.928572" sodipodi:cy="18.071428" sodipodi:rx="4.9285712" sodipodi:ry="5.5" sodipodi:type="arc" style="fill:&fill_color;;fill-opacity:0.00431034;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" transform="matrix(1.9205252,0,0,1.656055,-13.559039,-17.855853)"/>
+ <path d="M 8.4285714,17 42.142857,38.857143" id="path3788" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 42,38.857143 -3.571429,5 L 5,22.428571 l 3.7142857,-5" id="path3804" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="M 9.7142857,21.714286 11.142857,19.285714" id="path3806" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 12.428571,23.285715 1.428572,-2.428572" id="path3808" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 15,24.857144 1.428572,-2.428572" id="path3810" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 17.428571,26.428573 1.428572,-2.428572" id="path3812" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="M 19.571428,27.857144 21,25.428572" id="path3814" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 22.142857,29.428573 1.428572,-2.428572" id="path3816" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="M 24.857143,31.000002 26.285715,28.57143" id="path3818" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 27.571429,32.714288 1.428572,-2.428572" id="path3820" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 30,34.571431 1.428572,-2.428572" id="path3822" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 32.714286,36.285717 1.428572,-2.428572" id="path3824" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 35.285715,37.857146 1.428572,-2.428572" id="path3826" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 37.714286,39.428575 1.428572,-2.428572" id="path3828" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 42.142857,38.857143 0.285714,-0.142857 -1.714285,2" id="path3834" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="M 25.714286,27.571429 40,16.142857 42.857143,19.428571 29.285714,29.857143" id="path3838" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 19.571429,32 -8.714286,6.285714" id="path3840" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 23.142857,34.428571 -9.714286,6.857143" id="path3842" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="M 11,37.857143 8.7142857,42.571429 13.857143,41.285714" id="path3850" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 11,38.142857 2.142857,0.428572 -0.714286,1.285714 L 14.285714,40" id="path3852" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="M 25.571429,27.714286 27,26.571429" id="path3858" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 37.142857,18.857143 2.428572,2.857143" id="path3870" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 36,19.428571 2.857143,3.285715" id="path3872" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 35,20.142857 2.857143,3.142857" id="path3882" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ <path d="m 28.857143,30.285714 3.571428,-2.857143" id="path3888" inkscape:connector-curvature="0" style="fill:none;stroke:&stroke_color;;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"/>
+ </g>
+</svg> \ No newline at end of file
diff --git a/activity/activity.info b/activity/activity.info
new file mode 100644
index 0000000..8506388
--- /dev/null
+++ b/activity/activity.info
@@ -0,0 +1,8 @@
+[Activity]
+name = YardStick
+bundle_id = org.laptop.YardStickActivity
+class = YardStickActivity.YardStickActivity
+icon = activity-yardstick
+activity_version = 1
+host_version = 1
+show_launcher = yes
diff --git a/dist/YardStick-1.xo b/dist/YardStick-1.xo
new file mode 100644
index 0000000..1ef4398
--- /dev/null
+++ b/dist/YardStick-1.xo
Binary files differ
diff --git a/images/YardStick.png b/images/YardStick.png
new file mode 100644
index 0000000..e4156bc
--- /dev/null
+++ b/images/YardStick.png
Binary files differ
diff --git a/images/addnew.png b/images/addnew.png
new file mode 100644
index 0000000..22db12e
--- /dev/null
+++ b/images/addnew.png
Binary files differ
diff --git a/images/author.png b/images/author.png
new file mode 100644
index 0000000..0e693c6
--- /dev/null
+++ b/images/author.png
Binary files differ
diff --git a/images/categories.png b/images/categories.png
new file mode 100644
index 0000000..00558f7
--- /dev/null
+++ b/images/categories.png
Binary files differ
diff --git a/images/child.png b/images/child.png
new file mode 100644
index 0000000..ffe6971
--- /dev/null
+++ b/images/child.png
Binary files differ
diff --git a/images/delete.png b/images/delete.png
new file mode 100644
index 0000000..edb51f9
--- /dev/null
+++ b/images/delete.png
Binary files differ
diff --git a/images/description.png b/images/description.png
new file mode 100644
index 0000000..7a8a1d9
--- /dev/null
+++ b/images/description.png
Binary files differ
diff --git a/images/edit.png b/images/edit.png
new file mode 100644
index 0000000..523b41d
--- /dev/null
+++ b/images/edit.png
Binary files differ
diff --git a/images/editpoints.png b/images/editpoints.png
new file mode 100644
index 0000000..4cdbf4d
--- /dev/null
+++ b/images/editpoints.png
Binary files differ
diff --git a/images/finalize.png b/images/finalize.png
new file mode 100644
index 0000000..859465c
--- /dev/null
+++ b/images/finalize.png
Binary files differ
diff --git a/images/homepage.png b/images/homepage.png
new file mode 100644
index 0000000..9a9012b
--- /dev/null
+++ b/images/homepage.png
Binary files differ
diff --git a/images/levels.png b/images/levels.png
new file mode 100644
index 0000000..19fbdc5
--- /dev/null
+++ b/images/levels.png
Binary files differ
diff --git a/images/pic1.png b/images/pic1.png
new file mode 100644
index 0000000..6a8be4a
--- /dev/null
+++ b/images/pic1.png
Binary files differ
diff --git a/images/picture.png b/images/picture.png
new file mode 100644
index 0000000..852b36e
--- /dev/null
+++ b/images/picture.png
Binary files differ
diff --git a/images/save.png b/images/save.png
new file mode 100644
index 0000000..91aa347
--- /dev/null
+++ b/images/save.png
Binary files differ
diff --git a/images/sendtoscorepad.png b/images/sendtoscorepad.png
new file mode 100644
index 0000000..7d9f479
--- /dev/null
+++ b/images/sendtoscorepad.png
Binary files differ
diff --git a/images/share.png b/images/share.png
new file mode 100644
index 0000000..0290a37
--- /dev/null
+++ b/images/share.png
Binary files differ
diff --git a/images/submit.png b/images/submit.png
new file mode 100644
index 0000000..c7d31be
--- /dev/null
+++ b/images/submit.png
Binary files differ
diff --git a/images/title.png b/images/title.png
new file mode 100644
index 0000000..ba3c158
--- /dev/null
+++ b/images/title.png
Binary files differ
diff --git a/images/update.png b/images/update.png
new file mode 100644
index 0000000..d4e9a8b
--- /dev/null
+++ b/images/update.png
Binary files differ
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..ec0f64e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from sugar.activity import bundlebuilder
+bundlebuilder.start()