Create a Section in Desire 2 Learn - desire2learn

I'm trying to create a section in a course offering that does not already have sections.
I understand that I must first do a PUT request using Section.SectionPropertyData in order to initialise sections in the course offering.
The JSON request has the format:
{
"EnrollmentStyle": 1,
"EnrollmentQuantity": 0,
"AutoEnroll": false,
"RandomizeEnrollments": false
}
I am getting a BAD_REQUEST response. I suspect the values of enrollmentstyle and quantity are the issue. What should they be set to when I want to specify the members of each section and not have a maximum number of students in a section?

Turns out I needed:
{ "EnrollmentStyle": 1, "EnrollmentQuantity": 200, "AutoEnroll": false, "RandomizeEnrollments": false }
So that EnrollmentQuantity was > 0. Not sure if this limits the number of users that can be enrolled in a section, but most of our sections have a maximum of 25 students anyway so won't be an issue.

Related

not equal condtions in elasticsearch aggregation

I have a rails app that connects to elastic search and the user could define some conditions like (at least),(at most), and ... to compare and find his specific result. everything is fine but now I have to add not equal to my comparison operator list and even calculate not equal for all of my conditions described before. for example, if the user wants to search, "not equal at least" I want to calculate the result based on the user query and then make them reverse in result I know make query response reverse, it's impossible in elastic search but does it possible elastic calculate not equal by himself, assume user want to know ((the count of the specific event did not happen at most 1 time in last 30 days)) I know elastic support not equal query, but just in bool and query string query, but in my case, I should use aggregation and terms query in it. aggregation like :
body_data = {
group_by_profile_id: {
terms: {
field: "profile_id.keyword",
min_doc_count: #count_first,
size: 10000
},
aggs: {
filter: {
bucket_selector: {
buckets_path: {
docCount: "_count"
},
script: "params.docCount #{#operator} #{#counts.last}"
}
}
}
}
}
does anyone knows how can i handle not equal query in aggregation and term query.

Rails - Create order and order-rows with REST api

I just have a question regarding how to implement some logic.
Im building a API that allows the client to create orders.
This is solved by a OrderController#create so no problem!
Now, the issue is that an order can have many order-rows, all the relations are set correct but where should i create the order-rows in for the order?
Should the OrderController handle this or should i have a new controller that creates the order-rows for the particular order?
The clients post is sending the following json-data:
{
"status": "paid",
"total_sum": 20,
"payment": "card",
"order_rows": [
{
"id": 12,
},
{
"id":13
}
]
}
I ran into something similar with a project I'm working on now. The best (and long term simplest) solution was definitely to make a whole new model/controller.
*Order
status (should be an int or enum probably)
total (should loop through all order rows and total)
payment (should be an int or enum probably)
has_many order_rows
**OrderRow
belongs_to Order
item_sku
item_name
item_descr
item_cost
etc. etc.
This allows you to easily search for not just items, but orders that include items by name or sku, orders that include items by description.
Your totals are dynamic.
You can retrieve total order numbers or movement numbers on a per item basis.
It is so much easier to create and update orders.
The benefits go on.
It can easily be scoped;
scope :this_orders_rows, -> (order_id) {where(order_id: order_id)}
And it saves you from having to parse through hashes and arrays everytime.
To get technical about it, your order_controller should control ONLY your orders. If you start adding in a heap of other code to read through the arrays its going to get VERY cluttered. It's always better to move that to some other area.

Etsy API: Can I get a number of active listings by shop id without paginating through all listing items

I want to know the total number of active listings by shop id. Is there any such API available ?
I could find the API which returns paginated results for all the listings in a shop.
'/shops/:shop_id/listings/active'
I cannot give a limit of over 100 in this API and for fetching total count of all listings, I will have to make a lot of requests is the listings are lets say several thousands. A simple API endpoint that can get the count of total active listings would be really helpful
It's included in the standard response:
{
"count":integer,
"results": [
{ result object }
],
"params": { parameters },
"type":result type
}
Docs can be found here: https://www.etsy.com/developers/documentation/getting_started/api_basics#section_standard_response_format
Got it.
The response contains a count field which gives the exact count of the active listings.
100 is the highest limit you can set—you will need to use the "page" parameter to move to the next 100 and so on.

JIRA REST API 6.01 - listing all groups

I am trying to use JIRA REST API[1] to list all the groups in JIRA. I am currently using JIRA version 6.01 .
I tried /rest/api/2/groups/picker[2] in JIRA REST API 6.01 but could not find a way to specify the parameter "query" as the way I need.
If I use a whole group name in parameter "query", I receive the correct group like this.
Request 1:
GET /jira/rest/api/2/groups/picker?query=jira-users
Response 1
{
"header": "Showing 1 of 1 matching groups",
"total": 1,
"groups": [ {
"name": "jira-users",
"html": "<b>jira-users<\/b>"
}]
}
But if I use a part of the group name in "query" parameter, it does not give expected results.
Request 2
GET /jira/rest/api/2/groups/picker?query=j
According to the method spec [2] I hope to receive all groups that name contains "j" but I do not receive any result.
Response 2
{
"header": "Showing 0 of 0 matching groups",
"total": 0,
"groups": []
}
Can anyone please let me know the right way to give parameters?
Thank you
[1] https://developer.atlassian.com/static/rest/jira/6.0.1.html
[2] https://developer.atlassian.com/static/rest/jira/6.0.1.html#id150432
We're using JIRA 6.0.7 and can do:
/rest/api/2/groups/picker?maxResults=10000
Which will show you all groups up to a max of 10000 results. The the response is important part as it shows the total number of groups, this may require you to adjust the maxResults query parameter that you pass to it if you have too small of a value to show all results:
{
"header":"Showing 5014 of 5014 matching groups",
"total":5014,
"groups":{
...
}
}
If you omit the maxResults it just returns the first 20 out of 5014. However, for us doing:
/rest/api/2/groups/picker?query=j
Will result in all groups containing the letter j to show up. Maybe it wasn't properly implemented in your version. If you are unable to get the query part working properly, you could try and get all results and then do your own filter by analyzing the name for each group object returned.

Why AddGantt or AddGanttColor returns the same index for different invocations?

For some reason for certain cases when adding gantts to a TGanttSeries instance using method AddGanttColor or AddGantt the same index is returned for two different calls.
For example, the following snippet illustrates the case where the last two calls both return index of value 1.
Series.AddGanttColor(0, 100, 0, 'WA #234', clGreen); // returns value 0
Series.AddGanttColor(100, 200, 1, 'WA #235', clGreen); // returns value 1
Series.AddGanttColor(50, 200, 2, 'WA #237', clGreen); // returns value 1!
However, all three gantts are displayed. So, it seems that the third line added gantt as the second in the list, and moved the gantt added on the second line to be the last one (third, and having index 2).
Could anyone please explain how could this be remedied to ensure that returned indexes stay associated with gantts as per AddGanttColor calls. In the above example, I would expect index values 0, 1, and 2 to be associated with the first, second and third added gantt respectively.
Have just confirmed that this situation holds true for TeeChart versions 5 and 8 running under Delphi 5.
Well... after some research the cause of the problem was narrowed down to the value of property Series.XValues.Order. This property should be set to loNone in order to preserve association between index values returned from AddGantt and corresponding gantts.
IMO this is an API deficiency.

Resources