Openedx import fails with "'NoneType' object has no attribute 'data_dir'" message - openedx

I created a course on my personal openedx instance. Then exported it, and tried to import it into an institutional platform but got the error :
There was an error while importing the new course to our database.
'NoneType' object has no attribute 'data_dir'
enter image description here
How to solve this ?
Edit: also, duplicated sections are not exported properly. You must create them my click on the create button, then move relevant content into those.

You need to fix some minor issue in the archive.
Within your archive, edit /course/policies/course/policy.json.
Somewhere within it there is a tabs object.
"tabs": [
{
"course_staff_only": false,
"name": "Home",
"type": "course_info"
},
{
"course_staff_only": false,
"name": "Course",
"type": "courseware"
},
...
]
Within it, the type courseware whould be first.
"tabs": [
{
"course_staff_only": false,
"name": "Course",
"type": "courseware"
},
{
"course_staff_only": false,
"name": "Home",
"type": "course_info"
},
...
]
Import then works :
enter image description here

Related

Jira set user using API

I have been able to find various questions similar to this one, but none of them are solving this problem.
So I have this custom field
"customfield_10039": {
"required": false,
"schema": {
"type": "user",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:userpicker",
"customId": 10039
},
"name": "user",
"key": "customfield_10039",
"autoCompleteUrl": "https://integrationtr.atlassian.net/rest/api/1.0/users/picker?fieldName=customfield_10039&fieldConfigId=10140&projectId=10001&showAvatar=true&query=",
"hasDefaultValue": false,
"operations": [
"set"
]
},
So as you can see this allows one to set the user, now I set the user using this:
{"fields":{"customfield_10039" : {"name":"admin"}}}
I have tried so many combinations for name, I have tried using email id, display name, even name by concatenating first name, second name. In each one I get the same error:
{"errorMessages":[],"errors":{"customfield_10039":"user is required."}}

Snipcart add item via JS API

I'm building a very small e-commerce website for selling customizable jewels, so I have a graphical configurator that lets you design the jewel and then you can add it to the cart. The product should have a custom field in JSON format that contains the item configuration. I see that Snipcart has data-item-custom{x} fields, but is populated only with dropdowns... is not suitable for me.
Do you think I can handle this situation with Snipcart? Can I simply update via JS the HTML data-item- fields content? Or add the item to the cart via JS?
addToCart({
name: 'Bracelet 1',
customField1: 'JSON HERE'
})
There's a Javascript API available for Snipcart.
It does allow to add product dynamically, however, the syntax for custom fields is slightly different. The example from the doc for Snipcart.api.items.add show how to use custom fields (removed unused fields for brevity):
Snipcart.api.items.add({
"id": "SMARTPHONE",
"name": "Smartphone",
"url": "/",
"price": "399.00",
"customFields": [{
"name": "Memory size",
"options": "16GB|32GB[+50.00]",
"value": "32GB"
}]
});
So instead of the flattened version with customFieldX, you can pass an array to customFields. The dropdown format is only used if you pass an options. For your use case this would become:
Snipcart.api.items.add({
"id": "SMARTPHONE",
"name": "Smartphone",
"url": "/",
"price": "399.00",
"customFields": [{
"name": "configuration",
"value": "{\"option1\":\"value1\"}" //...
}]
});
However, custom fields are shown to the customer which would not be ideal to show them the raw json data. To pass hidden data you can instead use metadata which already expect a JSON object:
Snipcart.api.items.add({
"id": "SMARTPHONE",
"name": "Smartphone",
"url": "/",
"price": "399.00",
"customFields": [{
"metadata": {
"configuration": "configuration data"
}
});

Modify Task.json at build step design time

i wanted to modify task.json on runtime means when i configure my CI task in vsts or tfs.
I created an extension that contribute a build task.
Through this build task i wanted to do something like this, i have done in jenkins. Please Refer screenshot:
1-Requirement) in this image we add global variable(fields) at runtime on clicking Add Global Variables button. It generates two fields one for GVName and another for its value.
2-Requirement) When we select global variable then respective value field change at runtime means it can be dropbox(picklist) or input field that depends on GV type.
3-Requirement) On Job design time we make an ajax call to server that return true/false on based of value we shows error like in image 2.
Is these requirements are feasible in VSTS task.json? If yes, can you help me to solve this.
No, but it can list the available items that returned from the server.
For example:
"inputs": [
{
"name": "APIURL",
"type": "connectedService:Generic",
"label": "API URL",
"required": true,
"helpMarkDown": ""
},
{
"name": "List1",
"type": "pickList",
"label": "List4",
"defaultValue": "",
"required": false,
"helpMarkDown": ""
}
],
"sourceDefinitions": [
{
"target": "List1",
"endpoint": "home/jsontest",
"selector": "jsonpath:$[*].id",
"authKey": "$(APIURL)"
}
],
A thread that may benefit you: Using a web API in task.json to fill picklists buildtask

Google Cloud Endpoints REST Discovery Document missing format

I've upgraded to Cloud Endpoints 2.0 which no longer supports RPC. Therefore, I generated a new discovery document and used the service generator with the REST discovery doc as input in order to generate the client library for my iOS app.
Using the new REST discovery doc I am getting the following error when trying to generate the library:
~/workspace/google-api-objectivec-client-for-rest/Source/Tools/ServiceGenerator/build/Release/ServiceGenerator discovery/servUsApi-v1-rest.discovery --outputDir GTLAPI --gtlrFrameworkName GoogleAPIClientForREST
ERROR: Failure, exception: Looking at parameter 'creditKickbackKash:creditAmount', found a type/format pair of 'number/(null)', and don't how to map that to Objective-C
I was able to manually fix this by adding (in numerous places) in the discovery doc, the "format": "double" key and value for all double parameters. Notice creditAmount below is missing a format, like all other doubles.
The generated discovery doc looks like this:
"creditKickbackKash": {
"httpMethod": "PUT",
"id": "servUsApi.admin.creditKickbackKash",
"parameterOrder": [
"userId",
"creditAmount"
],
"parameters": {
"userId": {
"format": "int64",
"location": "path",
"required": true,
"type": "string"
},
"creditAmount": {
"location": "path",
"required": true,
"type": "number"
}
},
"path": "creditKickbackKash/{userId}/{creditAmount}",
"response": {
"$ref": "ResultDTO"
},
"scopes": [
"https://www.googleapis.com/auth/userinfo.email"
]
}
Is anyone else having this issue? How can I get the discovery document generation to properly format the document including double number types?
I had the same problem. I rolled back from 1.9.50 to 1.9.48 and the problem is gone.

How to get "Project Id" to create a Direct Link?

I have my project name, but not the numeric Project Id. The latter is needed to use HTML Direct Links.I'm using JIRA 5.0.1
How do I get the numeric Project Id for a given project name?
I've searched the Project Administration area, several other places, the documentation, Google, etc but still can't find a way to get that value.
Thanks.
This solution does not require admin rights:
Navigate to https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME and read the id in the JSON response:
{
"self":"https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME",
"id":"12345", ☜ Project Id
"key":"YOURPROJECTNAME",
"description":..
:
}
Navigate to https://jira.YOURDOMAIN.TLD/rest/api/2/project to get a JSON list of projects.
Bonus: here's a one-liner in Groovy to get the ID:
groovy -e "println new groovy.json.JsonSlurper().parseText("https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME".toURL().text)?.id ?: 'not found'"
A java.io.FileNotFoundException probably means that your JIRA server requires authentication.
Here's a one-liner to list all the visible projects and their ID:
groovy -e "new groovy.json.JsonSlurper().parseText('https://jira.YOURDOMAIN.TLD/rest/api/2/project'.toURL().text)?.each{println it.key+' = '+it.id}"
The easiest way is to do it from the web browser:
Go to the Administration page.
Select the Project from the menu.
Hover over 'Edit Project' link and check the link href (in the status bar).
It should be something like http://servername:8080/secure/project/EditProject!default.jspa?pid=10040
Where pid is the id you are looking for.
For Jira 6.x:
place the cursor on EDIT Project button and
look at the url being redirected at bottom left of the screen
This solution doesn't require admin rights and shows you all of the projects the current user can view.
https://example.com/rest/api/2/project
Responses found here.
https://docs.atlassian.com/jira/REST/latest/#d2e4972
returns a json array.
[
{
"self": "http://www.example.com/jira/rest/api/2/project/EX",
"id": "10000",
"key": "EX",
"name": "Example",
"avatarUrls": {
"24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
"16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
"32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000",
"48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
},
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
},
{
"self": "http://www.example.com/jira/rest/api/2/project/ABC",
"id": "10001",
"key": "ABC",
"name": "Alphabetical",
"avatarUrls": {
"24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10001",
"16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10001",
"32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10001",
"48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10001"
},
"projectCategory": {
"self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id": "10000",
"name": "FIRST",
"description": "First Project Category"
}
}
]
Exporting a ticket in XML reveals the project ID for me. I am not admin, so can't access the admin page. The rest/json trick didn't work for me, either. The XML of an issue has the following,
<project id="1234" key="test">TEST Project</project>

Resources