-
Notifications
You must be signed in to change notification settings - Fork 5
/
django_sakai.txt
141 lines (91 loc) · 4.24 KB
/
django_sakai.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Building Tsugi Applications in Django
-------------------------------------
Make an account on
www.pythonanywhere.com
Start a shell on PythonAnywhere and run these commands:
cd
mkvirtualenv django2 --python=/usr/bin/python3.6
workon django2
pip install django==2.1.7
We install an earlier version of Django to make sure
that the vesion of SQLite works with your Django.
Verify things worked by checing the Django version:
python3 -m django --version
git clone https://github.com/tsugiproject/djtest
cd djtest
pip install -r requirements.txt
Then create the needed database file:
python3 manage.py migrate
In the PYAW web interface navigate to the Web tab to create a new
web application. If you have not already done so, add a new web
application. Select manual configuration and Python 3.6. Once the
webapp is created, you need to make a few changes to the settings
for the web app and your application.
Create a duplicate tab in the current web browser with shell open.
In the duplicate tab in top right corner click on the three line
drop down and select Web. Click on Add a new web app. Click next
until you get to Select a Python Web Framework. Select Manual
Configuration. Select the Python version to be Python 3.6.
Click Next to finish Manual Configuration for Web App.
source code: /home/--your-account---/djtest
working directory: /home/--your-account---/djtest
virtualenv: /home/--your-account---/.virtualenvs/django2
Then edit the WGSI Configuration File and replace the contents of the file
with the following code:
import os
import sys
path = os.path.expanduser('~/djtest')
if path not in sys.path:
sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'djtest.settings'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())
Then restart your web application and attempt to go
https://--your-account--.pythonanywhere.com/grade/launch/
You should get redirected to an error detail page on
www.tsugi.org since this is the launch URL.
https://djtools.tsugicloud.org/grade/launch/
Adding to to an instance of Tsugi.
https://dev1.tsugicloud.org/tsugi/admin
Enter the password "tsugi" and select "Manage External Tools" and "Add Tool".
The "Launch Endpoint" must be unique across the whole system. The simplest thing
is to just use your account name on pythonanywhere. The name of the tool is a title
and can have several words.
The URL for receiving launches needs to be
https://--your-account--.pythonanywhere.com/grade/launch
Here are my sample settings:
Launch endpoint: drchuck
Name of the tool: Dr. Chuck's Test
Launch URL: https://drchuck.pythonanywhere.com/grade/launch
Icon: fa-random
Set the Additional Settings to the JSON shown below the field. Yes the field is
only one line - the JSON will all fit and it will look better in the edit view.
Ignore the pubic key for now - it is already hard-coded into djtest for this tutorial.
Test launch the tool from the TsugiCloud store:
https://dev1.tsugicloud.org/tsugi/store/
Find your tool, click on "Details" and then "Test". This
will test launch the tool from within Tsugi. It should work
and show a button "Open in New Window" - press it and your tool
should appear in a new tab.
Launching from an LMS
---------------------
Next we will launch your tool from Sakai.
Make an account on
https://dev1.sakaicloud.com
Make a site, add the Lessons and Gradebook tools.
Then in Lessons, "Add Content" -> "Add Learning App" and
select "Dev1" from the list. If "Dev1" is not in the
"Add Learning App" list have Chuck add it.
Once you are in the "Add Learning App" dialog, scroll down and
find your app and install it in Lessons.
If you want to test grade flow, make sure to make a second student
account to join your site and launch your tool to send back a
grade that actually makes it to the gradebook. Instructors
can't receive grades.
Then, go back to your PythonAnywhere account, and edit the file
~/djtest/grade/templates/grade/main.html
Add your name to the <h1> tag, then go into the PythonAnywhere account Web Tab
and "Reload" your application and then re-launch it from Sakai.
Congratulations - you just built, installed, and modified a Django-based
Tsugi tool.