The Valence API documentation specifies that Grade Objects of type Category cannot be created through the API, yet later on in the documentation there is a reference to a POST action possible on Grade Categories.
What's the story here, is there something in the documentation that I'm missing?
http://docs.valence.desire2learn.com/res/grade.html
I believe this means that you shouldn't try to use the POST route to create a grade object to create a grade category; instead, you must use the POST route to create a grade category to create a grade category. Grade category objects may be characterized as a special kind of grade object, but you should use the grade category APIs to manipulate them.
Related
We would like to read the calculated value of a specific Grade Category, as opposed to its configuration, through Valence.
According to the docs here, we can retrieve grade values through this endpoint:
GET /d2l/api/le/(version)/(orgUnitId)/grades/(gradeObjectId)/values/(userId)
Retrieve a specific grade value for a particular user assigned in an org unit.
Is it possible to use the above API on a Grade Category to get its value instead of a Grade Item?
Just to be clear, we would like to get the value for the category in one single shot without having to look into what grade items are inside the category.
The API doesn't currently expose the calculated value for a category in a single route. You'll have to get the category, and using the array of GradeObjects that comes back, grab the corresponding grade values, and then use the properties of the category to calculate the mark.
I'm trying to use valence to get all students' grades for a given grade object. But, I'm only finding actions for getting the current user's grade values. Given an instructor, is there a way to get everyone's grade values for a grade object? Or, do I need to get the class list, and individually get each student's grade for a grade object?
You are correct. Currently, you must first retrieve a list of the users in the class and then iterate over them to retrieve grade values for a specific grade object (line item in the grade book). This is a gap in the Valence Learning Framework API that others have also identified, and has been called out for implementation in a future release; precise timing of when it will be released isn't yet available, though.
When accessing the D2L Valence API as a student, /d2l/api/le/1.1/(D2LID: orgUnitId)/grades/categories/ and related GET requests return a HTTP 404 error where the orgUnitId is a class.
The route GET /d2l/api/le/1.1/(D2LID: orgUnitId)/grades/values/myGradeValues/ works however the categories and grades are displayed at the same level in the JSON hierarchy and there's nothing to associate between grade categories and grades.
On the first part of your question: the user making the call to fetch grade category information must be enrolled in the course offering with a role having permissions to see grade category data. The role permissions needed to see grade category data may not be the same as the permissions needed fetch one's own grade values. However, the '404' returned is odd, and would suggest that the orgUnitId you passed in was not found: if the user didn't have permission to retrieve the categories, then you'd expect to get a '403' error returned, not a '404'.
On the second part of your question, the call to get my grade values returns a flat array of GradeObject structures. You can distinguish between the grade object types by examining the GradeObjectTypeName property: for grade categories, it should say Category; for other grade object types, it will have the type name for that grade object (i.e. Numeric, PassFail, and so forth).
Hopefully we have good rails developer who can definitely give correct answer! For 2 days I didn't receive any valid answer for my question
I will explain in a very simple example
Customer is offering product. When he pushes create it gives form. Choose a category. Once he chooses another form will pop up.
Depending on a category, form should have totally different attributes.I can't have Product.new for every category. Reason is they have different attributes(Logicaly true). So do I have to create 100 models for 100 categories
Categories are : cars, apartments, coupons, books and many more
If you can give just one example I will be gratefull and call you expert
Thanks
It sounds like you're getting there. However, I wouldn't have a bunch of models like you're indicating in your question. I would say that you need a Product model and a Category model. The Category model will belong_to Product. The Product model would have many Categories. The Category model can use the acts_as_tree gem so that you can have categories and subcategories. Use javascript or jQuery (there was a recent Railscasts on this) to dynamically change and post a different field with a set of choices based on what was chosen.
EDIT:
I would have three Models; Product, Category, Specification
Product has many Categories
Product has many Specifications through Categories
Category belongs to Product
Category has many Specifications
Specification belongs to Category
This way I can create a product that has several categories. I can create several categories that have several specifications. Specifications are linked to the respective category. This will allow you to have three models and limited number of classes. Once your project is complete, new categories and specifications can be maintained by a web admin instead of a programmer.
This isn't the answer you want, but you're going to need a lot of models.
The attributes associated with an apartment (square meters, utilities, floor of building) are completely different from the attributes associated with a car (make, model, mileage, condition) which are completely different from a book (title, author, publisher, edition, etc). These items are so fundamentally different that there is no way to manage them in a single model.
That being said, there may be a core collection of attributes that might be associated with a product that is for sale (seller, price, terms). You have basically two paths forward:
You could decide to use Single Table Inheritance. In this case, you'd create an abstract class that defines the attributes that are common to all products that you are selling (seller, price, item). You'd then add a "type" column to your database that would be used to determine what type of product it is (mapped to your categories), and define all of the possible attributes in a single table.
You could choose a core set of attributes, and use these as a part of any other object that is considered a product. You'd have multiple tables that would have the full record for any given object.
Without knowing a lot of details about your application, it's hard to make a specific recommendation about which approach is right for you. Your best bet at this point is to spend a lot of time on google with "single table inheritance rails" and "multi table inheritance rails" and figure out which one is right for you (though my gut says multi table).
I'm a newbie on rails. How to query for a non related model field. Say I've a billing model where I need to fetch the product group while I store only product_code in the billing model. I'm using acts as api. I need to send all product_codes along with product group which is not at all related to billing model.
Thank You
Sai
Consider,
Billing.each do |r|
product = Product.find(r.billing_item)
product_group = product.product_group
end
Of course product_group above would be an AR association, you'd need to grab whatever appropriate attribute of your ProductGroup, i.e. name or title for example.